diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs new file mode 100644 index 00000000000..aa977f17e69 --- /dev/null +++ b/src/test/run-pass/const-big-enum.rs @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Foo { + Bar(u32), + Baz, + Quux(u64, u16) +} + +const X: Foo = Baz; + +fn main() { + match X { + Baz => {} + _ => fail + } + match Y { + Bar(s) => assert(s == 2654435769), + _ => fail + } + match Z { + Quux(d,h) => { + assert(d == 0x123456789abcdef0); + assert(h == 0x1234); + } + _ => fail + } +} + +const Y: Foo = Bar(2654435769); +const Z: Foo = Quux(0x123456789abcdef0, 0x1234); diff --git a/src/test/run-pass/const-newtype-enum.rs b/src/test/run-pass/const-newtype-enum.rs new file mode 100644 index 00000000000..069565aa4f8 --- /dev/null +++ b/src/test/run-pass/const-newtype-enum.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Foo = u32; + +const X: Foo = Foo(17); + +fn main() { + assert(*X == 17); + assert(*Y == 23); +} + +const Y: Foo = Foo(23); diff --git a/src/test/run-pass/const-nullary-enum.rs b/src/test/run-pass/const-nullary-enum.rs index abdddfe1c62..098305bbe35 100644 --- a/src/test/run-pass/const-nullary-enum.rs +++ b/src/test/run-pass/const-nullary-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -21,5 +21,10 @@ fn main() { Bar => {} Baz | Boo => fail } + match Y { + Baz => {} + Bar | Boo => fail + } } +const Y: Foo = Baz; diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index e1db50d566b..2fa5a7760f6 100644 --- a/src/test/run-pass/const-nullary-univariant-enum.rs +++ b/src/test/run-pass/const-nullary-univariant-enum.rs @@ -16,4 +16,7 @@ const X: Foo = Bar; fn main() { assert((X as uint) == 0xDEADBEE); + assert((Y as uint) == 0xDEADBEE); } + +const Y: Foo = Bar;