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
mod array;
#[cfg(feature = "std")]
mod boxed;
mod reference;
#[cfg(feature = "async")]
mod sink;
mod slice;
mod tuple;
pub trait Reactor<S> {
type Error;
fn react(&mut self, state: &S) -> Result<(), Self::Error>;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::mock::*;
use proptest::prelude::*;
proptest! {
#[test]
fn react(states: Vec<u8>) {
let mut mock = Mock::<_>::default();
for (i, state) in states.iter().enumerate() {
let reactor: &mut dyn Reactor<_, Error = _> = &mut mock;
assert_eq!(reactor.react(state), Ok(()));
assert_eq!(mock.calls(), &states[0..=i]);
}
}
}
}