2023-09-25 07:59:41 -05:00
|
|
|
// This test ensures that the variant value is displayed with underscores but without
|
|
|
|
// a type name at the end.
|
|
|
|
|
2023-10-07 07:37:47 -05:00
|
|
|
//@ aux-build:enum-variant.rs
|
|
|
|
|
2023-09-25 07:59:41 -05:00
|
|
|
#![crate_name = "foo"]
|
|
|
|
|
2023-10-07 07:37:47 -05:00
|
|
|
extern crate bar;
|
|
|
|
|
2023-10-06 17:25:34 -05:00
|
|
|
// 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.
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.A.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$'
|
2023-10-06 17:25:34 -05:00
|
|
|
pub enum A {
|
2023-09-25 07:59:41 -05:00
|
|
|
A = 12,
|
|
|
|
B,
|
|
|
|
C = 1245,
|
|
|
|
}
|
2023-10-06 17:25:34 -05:00
|
|
|
|
|
|
|
// In this case, all variants are C-like variants but none of them has its value set.
|
|
|
|
// Therefore we don't display values.
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.B.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$'
|
2023-10-06 17:25:34 -05:00
|
|
|
pub enum B {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
|
|
|
// In this case, not all variants are C-like variants so we don't display values.
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.C.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)'
|
2023-10-06 17:25:34 -05:00
|
|
|
#[repr(u32)]
|
|
|
|
pub enum C {
|
|
|
|
A = 12,
|
|
|
|
B,
|
|
|
|
C(u32),
|
|
|
|
}
|
|
|
|
|
|
|
|
// In this case, not all variants are C-like variants and no C-like variant has its
|
|
|
|
// value set, so we don't display values.
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.D.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)'
|
2023-10-06 17:25:34 -05:00
|
|
|
pub enum D {
|
|
|
|
A,
|
|
|
|
C(u32),
|
|
|
|
}
|
2023-10-07 07:37:47 -05:00
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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$'
|
2023-10-07 07:37:47 -05:00
|
|
|
pub use bar::E;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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$'
|
2023-10-07 07:37:47 -05:00
|
|
|
pub use bar::F;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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)'
|
2023-10-07 07:37:47 -05:00
|
|
|
pub use bar::G;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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)'
|
2023-10-07 07:37:47 -05:00
|
|
|
pub use bar::H;
|
2023-10-09 07:33:04 -05:00
|
|
|
|
|
|
|
// Testing more complex cases.
|
|
|
|
pub const X: isize = 2;
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.I.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A = 2,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B = 4,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'C = 9,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'D = -1,'
|
|
|
|
//@ matches - '//*[@id="variant.A"]/h3' '^A = 2$'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B = 4$'
|
|
|
|
//@ matches - '//*[@id="variant.C"]/h3' '^C = 9$'
|
|
|
|
//@ matches - '//*[@id="variant.D"]/h3' '^D = -1$'
|
2023-10-09 07:33:04 -05:00
|
|
|
#[repr(isize)]
|
|
|
|
pub enum I {
|
|
|
|
A = X,
|
|
|
|
B = X * 2,
|
|
|
|
C = Self::B as isize + X + 3,
|
|
|
|
D = -1,
|
|
|
|
}
|
2023-10-10 09:55:39 -05:00
|
|
|
|
|
|
|
// Testing `repr`.
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.J.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,'
|
|
|
|
//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$'
|
2023-10-10 09:55:39 -05:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum J {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.K.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B,'
|
|
|
|
//@ has - '//*[@id="variant.A"]/h3' 'A(u32)'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B$'
|
2023-10-10 09:55:39 -05:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum K {
|
|
|
|
A(u32),
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.L.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,'
|
|
|
|
//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$'
|
2023-10-10 09:55:39 -05:00
|
|
|
#[repr(u32)]
|
|
|
|
pub enum L {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.M.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B,'
|
|
|
|
//@ has - '//*[@id="variant.A"]/h3' 'A(u32)'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B$'
|
2023-10-10 09:55:39 -05:00
|
|
|
#[repr(u32)]
|
|
|
|
pub enum M {
|
|
|
|
A(u32),
|
|
|
|
B,
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.N.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,'
|
|
|
|
//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$'
|
2023-10-10 09:55:39 -05:00
|
|
|
pub use bar::N;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.O.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B,'
|
|
|
|
//@ has - '//*[@id="variant.A"]/h3' 'A(u32)'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B$'
|
2023-10-10 09:55:39 -05:00
|
|
|
pub use bar::O;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.P.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,'
|
|
|
|
//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$'
|
2023-10-10 09:55:39 -05:00
|
|
|
pub use bar::P;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'foo/enum.Q.html'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),'
|
|
|
|
//@ has - '//*[@class="rust item-decl"]/code' 'B,'
|
|
|
|
//@ has - '//*[@id="variant.A"]/h3' 'A(u32)'
|
|
|
|
//@ matches - '//*[@id="variant.B"]/h3' '^B$'
|
2023-10-10 09:55:39 -05:00
|
|
|
pub use bar::Q;
|