Skip to content

Commit 805edb0

Browse files
Add test to prevent regression for fields display
1 parent 6f48526 commit 805edb0

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

tests/rustdoc-gui/fields.goml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This test checks that fields are displayed as expected (one by line).
2+
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html"
3+
store-position: ("#structfield\.a", {"y": a_y})
4+
store-position: ("#structfield\.b", {"y": b_y})
5+
assert: |a_y| < |b_y|
6+
7+
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/union.Union.html"
8+
store-position: ("#structfield\.a", {"y": a_y})
9+
store-position: ("#structfield\.b", {"y": b_y})
10+
assert: |a_y| < |b_y|
11+
12+
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/enum.Enum.html"
13+
store-position: ("#variant\.A\.field\.a", {"y": a_y})
14+
store-position: ("#variant\.A\.field\.b", {"y": b_y})
15+
assert: |a_y| < |b_y|
16+
store-position: ("#variant\.B\.field\.a", {"y": a_y})
17+
store-position: ("#variant\.B\.field\.b", {"y": b_y})
18+
assert: |a_y| < |b_y|

tests/rustdoc-gui/src/test_docs/lib.rs

+21
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,24 @@ pub mod search_results {
486486
}
487487

488488
}
489+
490+
pub mod fields {
491+
pub struct Struct {
492+
pub a: u8,
493+
pub b: u32,
494+
}
495+
pub union Union {
496+
pub a: u8,
497+
pub b: u32,
498+
}
499+
pub enum Enum {
500+
A {
501+
a: u8,
502+
b: u32,
503+
},
504+
B {
505+
a: u8,
506+
b: u32,
507+
},
508+
}
509+
}

tests/rustdoc/union-fields-html.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![crate_name = "foo"]
2+
3+
// @has 'foo/union.Union.html'
4+
// Checking that there is a whitespace after `:`.
5+
// @has - '//*[@id="structfield.a"]/code' 'a: u8'
6+
// @has - '//*[@id="structfield.b"]/code' 'b: u32'
7+
pub union Union {
8+
pub a: u8,
9+
/// tadam
10+
pub b: u32,
11+
}

0 commit comments

Comments
 (0)