Skip to content

Commit 6d44879

Browse files
Update jump to def tests
1 parent 3fd36bc commit 6d44879

File tree

3 files changed

+64
-12
lines changed

3 files changed

+64
-12
lines changed

tests/rustdoc-gui/source-anchor-scroll.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ set-window-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="#5-7"]'
1111
assert-property: ("html", {"scrollTop": "149"})
12-
click: '//a[text() = "bar"]'
12+
click: '//a[text() = "bar" and @href="#28-36"]'
1313
assert-property: ("html", {"scrollTop": "180"})
14-
click: '//a[text() = "sub_fn"]'
14+
click: '//a[text() = "sub_fn" and @href="#2-4"]'
1515
assert-property: ("html", {"scrollTop": "77"})
1616

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

tests/rustdoc/check-source-code-urls-to-def.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ extern crate source_code;
1414
#[path = "auxiliary/source-code-bar.rs"]
1515
pub mod bar;
1616

17-
// @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5"]' 4
17+
// @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4
1818
use bar::Bar;
19-
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13"]' 'self'
20-
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait'
19+
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self'
20+
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
2121
use bar::sub::{self, Trait};
2222

2323
pub struct Foo;
@@ -32,7 +32,8 @@ fn babar() {}
3232
// @has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html'
3333
// @has - '//pre[@class="rust"]//a/@href' '/primitive.str.html'
3434
// @count - '//pre[@class="rust"]//a[@href="#23"]' 5
35-
// @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
35+
// @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \
36+
// 'source_code::SourceCode'
3637
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
3738
let x = 12;
3839
let y: Foo = Foo;
@@ -42,15 +43,15 @@ pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::Sour
4243
y.hello();
4344
}
4445

45-
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait'
46-
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait'
46+
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait'
47+
// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
4748
pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
4849

4950
pub trait AnotherTrait {}
5051
pub trait WhyNot {}
5152

52-
// @has - '//pre[@class="rust"]//a[@href="#49"]' 'AnotherTrait'
53-
// @has - '//pre[@class="rust"]//a[@href="#50"]' 'WhyNot'
53+
// @has - '//pre[@class="rust"]//a[@href="#50"]' 'AnotherTrait'
54+
// @has - '//pre[@class="rust"]//a[@href="#51"]' 'WhyNot'
5455
pub fn foo3<T, V>(t: &T, v: &V)
5556
where
5657
T: AnotherTrait,
@@ -59,7 +60,7 @@ where
5960

6061
pub trait AnotherTrait2 {}
6162

62-
// @has - '//pre[@class="rust"]//a[@href="#60"]' 'AnotherTrait2'
63+
// @has - '//pre[@class="rust"]//a[@href="#61"]' 'AnotherTrait2'
6364
pub fn foo4() {
6465
let x: Vec<AnotherTrait2> = Vec::new();
6566
}
+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)