Skip to content

Commit 1fa953e

Browse files
Add tests for "jump to definition" feature extension
1 parent db8d34b commit 1fa953e

File tree

3 files changed

+56
-5
lines changed

3 files changed

+56
-5
lines changed

src/test/rustdoc-gui/source-anchor-scroll.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ size: (600, 800)
77
// We check that the scroll is at the top first.
88
assert-property: ("html", {"scrollTop": "0"})
99

10-
click: '//a[text() = "barbar"]'
10+
click: '//a[text() = "barbar" and @href="../../src/link_to_definition/lib.rs.html#4-6"]'
1111
assert-property: ("html", {"scrollTop": "125"})
12-
click: '//a[text() = "bar"]'
12+
click: '//a[text() = "bar" and @href="../../src/link_to_definition/lib.rs.html#27-35"]'
1313
assert-property: ("html", {"scrollTop": "166"})
14-
click: '//a[text() = "sub_fn"]'
14+
click: '//a[text() = "sub_fn" and @href="../../src/link_to_definition/lib.rs.html#1-3"]'
1515
assert-property: ("html", {"scrollTop": "53"})
1616

1717
// We now check that clicking on lines doesn't change the scroll

src/test/rustdoc/check-source-code-urls-to-def.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ impl Foo {
2828

2929
fn babar() {}
3030

31-
// @has - '//a/@href' '/struct.String.html'
31+
// @has - '//a/@href' '/string.rs.html'
3232
// @has - '//a/@href' '/primitive.u32.html'
3333
// @has - '//a/@href' '/primitive.str.html'
3434
// @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#23"]' 5
35-
// @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
35+
// @has - '//a[@href="../../src/source_code/source_code.rs.html#1"]' 'source_code::SourceCode'
3636
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
3737
let x = 12;
3838
let y: Foo = Foo;
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// compile-flags: -Zunstable-options --generate-link-to-definition
2+
3+
#![crate_name = "foo"]
4+
5+
// @has 'src/foo/jump-to-def-doc-links.rs.html'
6+
7+
// @has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar'
8+
// @has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo'
9+
pub struct Bar; pub struct Foo;
10+
11+
// @has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum'
12+
pub enum Enum {
13+
Variant1(String),
14+
Variant2(u8),
15+
}
16+
17+
// @has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct'
18+
pub struct Struct {
19+
pub a: u8,
20+
b: Foo,
21+
}
22+
23+
impl Struct {
24+
pub fn foo() {}
25+
pub fn foo2(&self) {}
26+
fn bar() {}
27+
fn bar(&self) {}
28+
}
29+
30+
// @has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait'
31+
pub trait Trait {
32+
fn foo();
33+
}
34+
35+
impl Trait for Struct {
36+
fn foo() {}
37+
}
38+
39+
// @has - '//a[@href="../../foo/union.Union.html"]' 'Union'
40+
pub union Union {
41+
pub a: u16,
42+
pub f: u32,
43+
}
44+
45+
// @has - '//a[@href="../../foo/fn.bar.html"]' 'bar'
46+
pub fn bar(b: Bar) {
47+
let x = Foo;
48+
}
49+
50+
// @has - '//a[@href="../../foo/bar/index.html"]' 'bar'
51+
pub mod bar {}

0 commit comments

Comments
 (0)