about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Murphy <kemurphy.cmu@gmail.com>2013-07-23 23:32:10 -0400
committerKevin Murphy <kemurphy.cmu@gmail.com>2013-07-24 23:54:40 -0400
commite9233d55c87185d7c0e1ee489d4dce0346770576 (patch)
tree3fda0155fcddba388aafc67c4a0f858775b784da
parent1c3dc294cefcb92b23581273c24c220c74618a02 (diff)
downloadrust-e9233d55c87185d7c0e1ee489d4dce0346770576.tar.gz
rust-e9233d55c87185d7c0e1ee489d4dce0346770576.zip
Add test for uint and negative literals as discriminants
-rw-r--r--src/test/run-pass/enum-discr.rs20
1 files changed, 20 insertions, 0 deletions
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);
+}