Skip to content

Commit

Permalink
Add cross-crate C-like variant test
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Oct 7, 2023
1 parent de70a77 commit b0badc1
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/rustdoc/auxiliary/enum-variant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![crate_name = "bar"]

pub enum E {
A = 12,
B,
C = 1245,
}

pub enum F {
A,
B,
}

#[repr(u32)]
pub enum G {
A = 12,
B,
C(u32),
}

pub enum H {
A,
C(u32),
}
36 changes: 36 additions & 0 deletions tests/rustdoc/enum-variant-value.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// This test ensures that the variant value is displayed with underscores but without
// a type name at the end.

// aux-build:enum-variant.rs

#![crate_name = "foo"]

extern crate bar;

// In this case, since all variants are C-like variants and at least one of them
// has its value set, we display values for all of them.

Expand Down Expand Up @@ -60,3 +64,35 @@ pub enum D {
A,
C(u32),
}

// @has 'foo/enum.E.html'
// @has - '//*[@class="rust item-decl"]/code' 'A = 12,'
// @has - '//*[@class="rust item-decl"]/code' 'B = 13,'
// @has - '//*[@class="rust item-decl"]/code' 'C = 1_245,'
// @matches - '//*[@id="variant.A"]/h3' '^A = 12$'
// @matches - '//*[@id="variant.B"]/h3' '^B = 13$'
// @matches - '//*[@id="variant.C"]/h3' '^C = 1_245$'
pub use bar::E;

// @has 'foo/enum.F.html'
// @has - '//*[@class="rust item-decl"]/code' 'A,'
// @has - '//*[@class="rust item-decl"]/code' 'B,'
// @matches - '//*[@id="variant.A"]/h3' '^A$'
// @matches - '//*[@id="variant.B"]/h3' '^B$'
pub use bar::F;

// @has 'foo/enum.G.html'
// @has - '//*[@class="rust item-decl"]/code' 'A = 12,'
// @has - '//*[@class="rust item-decl"]/code' 'B,'
// @has - '//*[@class="rust item-decl"]/code' 'C(u32),'
// @matches - '//*[@id="variant.A"]/h3' '^A = 12$'
// @matches - '//*[@id="variant.B"]/h3' '^B$'
// @has - '//*[@id="variant.C"]/h3' 'C(u32)'
pub use bar::G;

// @has 'foo/enum.H.html'
// @has - '//*[@class="rust item-decl"]/code' 'A,'
// @has - '//*[@class="rust item-decl"]/code' 'C(u32),'
// @matches - '//*[@id="variant.A"]/h3' '^A$'
// @has - '//*[@id="variant.C"]/h3' 'C(u32)'
pub use bar::H;

0 comments on commit b0badc1

Please sign in to comment.