Skip to content

Commit de13718

Browse files
committed
test: Add rustdoc test for enum negative overflow
1 parent 7f7b8ef commit de13718

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/rustdoc/enum/enum-variant-value.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,25 @@ pub use bar::P;
189189
//@ has - '//*[@id="variant.A"]/h3' 'A(u32)'
190190
//@ matches - '//*[@id="variant.B"]/h3' '^B$'
191191
pub use bar::Q;
192+
193+
// Ensure signed implicit discriminants are rendered correctly after a negative explicit value.
194+
//@ has 'foo/enum.R.html'
195+
//@ has - '//*[@class="rust item-decl"]/code' 'A = -2,'
196+
//@ has - '//*[@class="rust item-decl"]/code' 'B = -1,'
197+
//@ matches - '//*[@id="variant.A"]/h3' '^A = -2$'
198+
//@ matches - '//*[@id="variant.B"]/h3' '^B = -1$'
199+
pub enum R {
200+
A = -2,
201+
B,
202+
}
203+
204+
// Also check that incrementing -1 yields 0 for the next implicit variant.
205+
//@ has 'foo/enum.S.html'
206+
//@ has - '//*[@class="rust item-decl"]/code' 'A = -1,'
207+
//@ has - '//*[@class="rust item-decl"]/code' 'B = 0,'
208+
//@ matches - '//*[@id="variant.A"]/h3' '^A = -1$'
209+
//@ matches - '//*[@id="variant.B"]/h3' '^B = 0$'
210+
pub enum S {
211+
A = -1,
212+
B,
213+
}

0 commit comments

Comments
 (0)