diff options
| author | Kevin Murphy <kemurphy.cmu@gmail.com> | 2013-07-23 23:32:10 -0400 |
|---|---|---|
| committer | Kevin Murphy <kemurphy.cmu@gmail.com> | 2013-07-24 23:54:40 -0400 |
| commit | e9233d55c87185d7c0e1ee489d4dce0346770576 (patch) | |
| tree | 3fda0155fcddba388aafc67c4a0f858775b784da | |
| parent | 1c3dc294cefcb92b23581273c24c220c74618a02 (diff) | |
| download | rust-e9233d55c87185d7c0e1ee489d4dce0346770576.tar.gz rust-e9233d55c87185d7c0e1ee489d4dce0346770576.zip | |
Add test for uint and negative literals as discriminants
| -rw-r--r-- | src/test/run-pass/enum-discr.rs | 20 |
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); +} |
