From e9233d55c87185d7c0e1ee489d4dce0346770576 Mon Sep 17 00:00:00 2001 From: Kevin Murphy Date: Tue, 23 Jul 2013 23:32:10 -0400 Subject: [PATCH] Add test for uint and negative literals as discriminants --- src/test/run-pass/enum-discr.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/run-pass/enum-discr.rs diff --git a/src/test/run-pass/enum-discr.rs b/src/test/run-pass/enum-discr.rs new file mode 100644 index 00000000000..5a14f0050e8 --- /dev/null +++ b/src/test/run-pass/enum-discr.rs @@ -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); +}