Rebase discriminant_value test. Add case for a specialized repr.

This commit is contained in:
Felix S. Klock II 2015-04-10 16:14:00 +02:00
parent 800c5f8038
commit ea2739176b

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(core)]
extern crate core;
use core::intrinsics::discriminant_value;
@ -25,6 +27,14 @@ enum CLike2 {
D
}
#[repr(i8)]
enum CLike3 {
A = 5,
B,
C = -1,
D
}
enum ADT {
First(u32, u32),
Second(u64)
@ -50,6 +60,11 @@ pub fn main() {
assert_eq!(discriminant_value(&CLike2::C), 19);
assert_eq!(discriminant_value(&CLike2::D), 20);
assert_eq!(discriminant_value(&CLike3::A), 5);
assert_eq!(discriminant_value(&CLike3::B), 6);
assert_eq!(discriminant_value(&CLike3::C), -1_i8 as u64);
assert_eq!(discriminant_value(&CLike3::D), 0);
assert_eq!(discriminant_value(&ADT::First(0,0)), 0);
assert_eq!(discriminant_value(&ADT::Second(5)), 1);