Skip to content

Commit b0badc1

Browse files
Add cross-crate C-like variant test
1 parent de70a77 commit b0badc1

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![crate_name = "bar"]
2+
3+
pub enum E {
4+
A = 12,
5+
B,
6+
C = 1245,
7+
}
8+
9+
pub enum F {
10+
A,
11+
B,
12+
}
13+
14+
#[repr(u32)]
15+
pub enum G {
16+
A = 12,
17+
B,
18+
C(u32),
19+
}
20+
21+
pub enum H {
22+
A,
23+
C(u32),
24+
}

tests/rustdoc/enum-variant-value.rs

+36
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// This test ensures that the variant value is displayed with underscores but without
22
// a type name at the end.
33

4+
// aux-build:enum-variant.rs
5+
46
#![crate_name = "foo"]
57

8+
extern crate bar;
9+
610
// In this case, since all variants are C-like variants and at least one of them
711
// has its value set, we display values for all of them.
812

@@ -60,3 +64,35 @@ pub enum D {
6064
A,
6165
C(u32),
6266
}
67+
68+
// @has 'foo/enum.E.html'
69+
// @has - '//*[@class="rust item-decl"]/code' 'A = 12,'
70+
// @has - '//*[@class="rust item-decl"]/code' 'B = 13,'
71+
// @has - '//*[@class="rust item-decl"]/code' 'C = 1_245,'
72+
// @matches - '//*[@id="variant.A"]/h3' '^A = 12$'
73+
// @matches - '//*[@id="variant.B"]/h3' '^B = 13$'
74+
// @matches - '//*[@id="variant.C"]/h3' '^C = 1_245$'
75+
pub use bar::E;
76+
77+
// @has 'foo/enum.F.html'
78+
// @has - '//*[@class="rust item-decl"]/code' 'A,'
79+
// @has - '//*[@class="rust item-decl"]/code' 'B,'
80+
// @matches - '//*[@id="variant.A"]/h3' '^A$'
81+
// @matches - '//*[@id="variant.B"]/h3' '^B$'
82+
pub use bar::F;
83+
84+
// @has 'foo/enum.G.html'
85+
// @has - '//*[@class="rust item-decl"]/code' 'A = 12,'
86+
// @has - '//*[@class="rust item-decl"]/code' 'B,'
87+
// @has - '//*[@class="rust item-decl"]/code' 'C(u32),'
88+
// @matches - '//*[@id="variant.A"]/h3' '^A = 12$'
89+
// @matches - '//*[@id="variant.B"]/h3' '^B$'
90+
// @has - '//*[@id="variant.C"]/h3' 'C(u32)'
91+
pub use bar::G;
92+
93+
// @has 'foo/enum.H.html'
94+
// @has - '//*[@class="rust item-decl"]/code' 'A,'
95+
// @has - '//*[@class="rust item-decl"]/code' 'C(u32),'
96+
// @matches - '//*[@id="variant.A"]/h3' '^A$'
97+
// @has - '//*[@id="variant.C"]/h3' 'C(u32)'
98+
pub use bar::H;

0 commit comments

Comments
 (0)