rust/tests/run-pass/c_enums.rs

40 lines
670 B
Rust
Raw Normal View History

#![feature(custom_attribute)]
#![allow(dead_code, unused_attributes)]
enum Foo {
Bar = 42,
Baz,
Quux = 100,
}
enum Signed {
Bar = -42,
Baz,
Quux = 100,
}
#[miri_run]
fn foo() -> [u8; 3] {
[Foo::Bar as u8, Foo::Baz as u8, Foo::Quux as u8]
}
#[miri_run]
fn signed() -> [i8; 3] {
[Signed::Bar as i8, Signed::Baz as i8, Signed::Quux as i8]
}
#[miri_run]
fn unsafe_match() -> bool {
match unsafe { std::mem::transmute::<u8, Foo>(43) } {
Foo::Baz => true,
_ => false,
}
}
2016-04-22 03:34:14 -05:00
2016-04-22 07:38:46 -05:00
#[miri_run]
fn main() {
// assert_eq!(foo(), [42, 43, 100]);
// assert_eq!(signed(), [-42, -41, 100]);
2016-04-22 07:38:46 -05:00
assert!(unsafe_match());
}