1 #![allow(unused_imports)] // FIXME for macOS
5 use rand::{SeedableRng, FromEntropy, Rng, rngs::SmallRng};
12 // Having more than 1 test does seem to make a difference
13 // (i.e., this calls ptr::swap which having just one test does not).
16 let mut rng = rand::rngs::StdRng::seed_from_u64(0xdeadcafe);
17 let x: u32 = rng.gen();
18 let y: u32 = rng.gen();
24 #[cfg(not(target_os="macos"))] // FIXME entropy does not work on macOS
25 // (Not disabling the entire test as that would change the output.)
27 // Use this opportunity to test querying the RNG (needs an external crate, hence tested here and not in the compiletest suite)
28 let mut rng = SmallRng::from_entropy();
29 let _val = rng.gen::<i32>();
31 // Also try per-thread RNG.
32 let mut rng = rand::thread_rng();
33 let _val = rng.gen::<i32>();
37 // A test that won't work on miri
40 fn does_not_work_on_miri() {
42 assert!(&x as *const _ as usize % 4 < 4);