We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1199976 commit b85db60Copy full SHA for b85db60
tests/bool.rs
@@ -0,0 +1,26 @@
1
+#![cfg(feature = "std")]
2
+
3
+extern crate rand;
4
+extern crate libc;
5
6
+use rand::{FromEntropy, SmallRng};
7
+use rand::distributions::{Distribution, Bernoulli};
8
9
+#[link_name = "m"]
10
+extern "C" {
11
+ fn nextafter(x: f64, y: f64) -> f64;
12
+}
13
14
+/// This test should make sure that we don't accidentally have undefined
15
+/// behavior for large propabilties due to
16
+/// https://github.com/rust-lang/rust/issues/10184.
17
+#[test]
18
+fn large_probability() {
19
+ let p = unsafe { nextafter(1., 0.) };
20
+ assert!(p < 1.);
21
+ let d = Bernoulli::new(p);
22
+ let mut rng = SmallRng::from_entropy();
23
+ for _ in 0..10 {
24
+ assert!(d.sample(&mut rng));
25
+ }
26
0 commit comments