Skip to content

Commit

Permalink
Add test to prevent regression for fields display
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 21, 2023
1 parent 6f48526 commit 805edb0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/rustdoc-gui/fields.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This test checks that fields are displayed as expected (one by line).
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html"
store-position: ("#structfield\.a", {"y": a_y})
store-position: ("#structfield\.b", {"y": b_y})
assert: |a_y| < |b_y|

go-to: "file://" + |DOC_PATH| + "/test_docs/fields/union.Union.html"
store-position: ("#structfield\.a", {"y": a_y})
store-position: ("#structfield\.b", {"y": b_y})
assert: |a_y| < |b_y|

go-to: "file://" + |DOC_PATH| + "/test_docs/fields/enum.Enum.html"
store-position: ("#variant\.A\.field\.a", {"y": a_y})
store-position: ("#variant\.A\.field\.b", {"y": b_y})
assert: |a_y| < |b_y|
store-position: ("#variant\.B\.field\.a", {"y": a_y})
store-position: ("#variant\.B\.field\.b", {"y": b_y})
assert: |a_y| < |b_y|
21 changes: 21 additions & 0 deletions tests/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,24 @@ pub mod search_results {
}

}

pub mod fields {
pub struct Struct {
pub a: u8,
pub b: u32,
}
pub union Union {
pub a: u8,
pub b: u32,
}
pub enum Enum {
A {
a: u8,
b: u32,
},
B {
a: u8,
b: u32,
},
}
}
11 changes: 11 additions & 0 deletions tests/rustdoc/union-fields-html.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![crate_name = "foo"]

// @has 'foo/union.Union.html'
// Checking that there is a whitespace after `:`.
// @has - '//*[@id="structfield.a"]/code' 'a: u8'
// @has - '//*[@id="structfield.b"]/code' 'b: u32'
pub union Union {
pub a: u8,
/// tadam
pub b: u32,
}

0 comments on commit 805edb0

Please sign in to comment.