1 //! Strategies for `u128` and `i128`, since proptest doesn't provide them for the wasm target. 2 3 macro_rules! impl_num { 4 { $name:ident } => { 5 pub(crate) mod $name { 6 type InnerStrategy = crate::array::UniformArrayStrategy<proptest::num::u64::Any, [u64; 2]>; 7 use proptest::strategy::{Strategy, ValueTree, NewTree}; 8 9 10 #[must_use = "strategies do nothing unless used"] 11 #[derive(Clone, Copy, Debug)] 12 pub struct Any { 13 strategy: InnerStrategy, 14 } 15 16 pub struct BinarySearch { 17 inner: <InnerStrategy as Strategy>::Tree, 18 } 19 20 impl ValueTree for BinarySearch { 21 type Value = $name; 22 23 fn current(&self) -> $name { 24 unsafe { core::mem::transmute(self.inner.current()) } 25 } 26 27 fn simplify(&mut self) -> bool { 28 self.inner.simplify() 29 } 30 31 fn complicate(&mut self) -> bool { 32 self.inner.complicate() 33 } 34 } 35 36 impl Strategy for Any { 37 type Tree = BinarySearch; 38 type Value = $name; 39 40 fn new_tree(&self, runner: &mut proptest::test_runner::TestRunner) -> NewTree<Self> { 41 Ok(BinarySearch { inner: self.strategy.new_tree(runner)? }) 42 } 43 } 44 45 pub const ANY: Any = Any { strategy: InnerStrategy::new(proptest::num::u64::ANY) }; 46 } 47 } 48 } 49 50 impl_num! { u128 } 51 impl_num! { i128 } 52