1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use strategy::*;
use test_runner::*;
use rand::Rng;
#[derive(Clone, Copy, Debug)]
pub struct Any(());
pub const ANY: Any = Any(());
impl Strategy for Any {
type Value = BoolValueTree;
fn new_value(&self, runner: &mut TestRunner)
-> Result<BoolValueTree, String> {
Ok(BoolValueTree(runner.rng().gen()))
}
}
#[derive(Clone, Copy, Debug)]
pub struct BoolValueTree(bool);
impl ValueTree for BoolValueTree {
type Value = bool;
fn current(&self) -> bool { self.0 }
fn simplify(&mut self) -> bool {
let r = self.0;
self.0 = false;
r
}
fn complicate(&mut self) -> bool {
let r = self.0;
self.0 = true;
!r
}
}