Add test for uint and negative literals as discriminants
This commit is contained in:
parent
1c3dc294ce
commit
e9233d55c8
20
src/test/run-pass/enum-discr.rs
Normal file
20
src/test/run-pass/enum-discr.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
enum Animal {
|
||||||
|
Cat = 0u,
|
||||||
|
Dog = 1u,
|
||||||
|
Horse = 2u,
|
||||||
|
Snake = 3u
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Hero {
|
||||||
|
Batman = -1,
|
||||||
|
Superman = -2,
|
||||||
|
Ironman = -3,
|
||||||
|
Spiderman = -4
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let pet: Animal = Snake;
|
||||||
|
let hero: Hero = Superman;
|
||||||
|
assert!(pet as uint == 3);
|
||||||
|
assert!(hero as int == -2);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user