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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
macro_rules! default {
($type: ty, $val: expr) => {
impl Default for $type {
fn default() -> Self { $val.into() }
}
};
}
macro_rules! valuetree {
() => {
type ValueTree =
<Self::Strategy as $crate::proptest::strategy::Strategy>::Value;
};
}
macro_rules! arbitrary {
([$($bounds : tt)*] $typ: ty, $strat: ty, $params: ty;
$args: ident => $logic: expr) => {
impl<'a, $($bounds)*> $crate::Arbitrary<'a> for $typ {
valuetree!();
type Parameters = $params;
type Strategy = $strat;
fn arbitrary_with($args: Self::Parameters) -> Self::Strategy {
$logic
}
}
};
([$($bounds : tt)*] $typ: ty, $strat: ty; $logic: expr) => {
arbitrary!([$($bounds)*] $typ, $strat, (); _args => $logic);
};
([$($bounds : tt)*] $strat: ty; $logic: expr) => {
arbitrary!([$($bounds)*] $strat,
$crate::proptest::strategy::Just<Self>, ();
_args => $crate::proptest::strategy::Just($logic)
);
};
($typ: ty, $strat: ty, $params: ty; $args: ident => $logic: expr) => {
arbitrary!([] $typ, $strat, $params; $args => $logic);
};
($typ: ty, $strat: ty; $logic: expr) => {
arbitrary!([] $typ, $strat; $logic);
};
($strat: ty; $logic: expr) => {
arbitrary!([] $strat; $logic);
};
($($typ: ident),*) => {
$(arbitrary!($typ, $typ::Any; $typ::ANY);)*
};
}
macro_rules! wrap_ctor {
($wrap: ident) => {
wrap_ctor!([] $wrap);
};
($wrap: ident, $maker: expr) => {
wrap_ctor!([] $wrap, $maker);
};
([$($bound : tt)*] $wrap: ident) => {
wrap_ctor!([$($bound)*] $wrap, $wrap::new);
};
([$($bound : tt)*] $wrap: ident, $maker: expr) => {
arbitrary!([A: $crate::Arbitrary<'a> + $($bound)*] $wrap<A>,
$crate::SMapped<'a, A, Self>, A::Parameters;
args => $crate::any_with_smap(args, $maker));
};
}
macro_rules! wrap_from {
($wrap: ident) => {
wrap_from!([] $wrap);
};
([$($bound : tt)*] $wrap: ident) => {
arbitrary!([A: $crate::Arbitrary<'a> + $($bound)*] $wrap<A>,
$crate::FMapped<'a, A, Self>, A::Parameters;
args => $crate::any_with_sinto::<A, $wrap<A>>(args));
};
}
macro_rules! generator {
($($self: ty, $fun: expr);+) => {
$(
arbitrary!($self, $crate::GenStrategy<Self>;
$crate::GenStrategy::new($fun));
)+
};
}