update discriminant_value
usage in tests
This commit is contained in:
parent
3188ca7dd9
commit
ff2940a9f4
@ -51,31 +51,31 @@ enum Mixed {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(discriminant_value(&CLike1::A), 0);
|
||||
assert_eq!(discriminant_value(&CLike1::A), 0isize);
|
||||
assert_eq!(discriminant_value(&CLike1::B), 1);
|
||||
assert_eq!(discriminant_value(&CLike1::C), 2);
|
||||
assert_eq!(discriminant_value(&CLike1::D), 3);
|
||||
|
||||
assert_eq!(discriminant_value(&CLike2::A), 5);
|
||||
assert_eq!(discriminant_value(&CLike2::A), 5isize);
|
||||
assert_eq!(discriminant_value(&CLike2::B), 2);
|
||||
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::A), 5i8);
|
||||
assert_eq!(discriminant_value(&CLike3::B), 6);
|
||||
assert_eq!(discriminant_value(&CLike3::C), -1_i8 as u64);
|
||||
assert_eq!(discriminant_value(&CLike3::C), -1);
|
||||
assert_eq!(discriminant_value(&CLike3::D), 0);
|
||||
|
||||
assert_eq!(discriminant_value(&ADT::First(0,0)), 0);
|
||||
assert_eq!(discriminant_value(&ADT::First(0,0)), 0isize);
|
||||
assert_eq!(discriminant_value(&ADT::Second(5)), 1);
|
||||
|
||||
assert_eq!(discriminant_value(&NullablePointer::Nothing), 1);
|
||||
assert_eq!(discriminant_value(&NullablePointer::Nothing), 1isize);
|
||||
assert_eq!(discriminant_value(&NullablePointer::Something(&CONST)), 0);
|
||||
|
||||
assert_eq!(discriminant_value(&10), 0);
|
||||
assert_eq!(discriminant_value(&"test"), 0);
|
||||
assert_eq!(discriminant_value(&10), 0u8);
|
||||
assert_eq!(discriminant_value(&"test"), 0u8);
|
||||
|
||||
assert_eq!(3, discriminant_value(&Mixed::Unit));
|
||||
assert_eq!(2, discriminant_value(&Mixed::Tuple(5)));
|
||||
assert_eq!(1, discriminant_value(&Mixed::Struct{a: 7, b: 11}));
|
||||
assert_eq!(discriminant_value(&Mixed::Unit), 3isize);
|
||||
assert_eq!(discriminant_value(&Mixed::Tuple(5)), 2);
|
||||
assert_eq!(discriminant_value(&Mixed::Struct{a: 7, b: 11}), 1);
|
||||
}
|
||||
|
@ -13,5 +13,5 @@ enum MyWeirdOption<T> {
|
||||
|
||||
fn main() {
|
||||
assert_eq!(discriminant_value(&MyWeirdOption::<()>::None), 0);
|
||||
assert_eq!(discriminant_value(&MyWeirdOption::Some(())), core::mem::size_of::<usize>() as u64);
|
||||
assert_eq!(discriminant_value(&MyWeirdOption::Some(())), core::mem::size_of::<usize>());
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
// run-pass
|
||||
|
||||
#![feature(generators, generator_trait, core_intrinsics)]
|
||||
#![feature(generators, generator_trait, core_intrinsics, discriminant_kind)]
|
||||
|
||||
use std::intrinsics::discriminant_value;
|
||||
use std::marker::Unpin;
|
||||
use std::marker::{Unpin, DiscriminantKind};
|
||||
use std::mem::size_of_val;
|
||||
use std::{cmp, ops::*};
|
||||
|
||||
@ -65,7 +65,10 @@ macro_rules! yield250 {
|
||||
};
|
||||
}
|
||||
|
||||
fn cycle(gen: impl Generator<()> + Unpin, expected_max_discr: u64) {
|
||||
fn cycle(
|
||||
gen: impl Generator<()> + Unpin + DiscriminantKind<Discriminant = i32>,
|
||||
expected_max_discr: i32
|
||||
) {
|
||||
let mut gen = Box::pin(gen);
|
||||
let mut max_discr = 0;
|
||||
loop {
|
||||
|
Loading…
x
Reference in New Issue
Block a user