Make timeout tests slightly more flexible

This commit is contained in:
Alex Crichton 2017-09-10 19:58:35 -07:00
parent 7b94cf307d
commit a4e947fba0
2 changed files with 3 additions and 3 deletions

View File

@ -19,8 +19,8 @@ fn single() {
drop(env_logger::init());
let mut l = t!(Core::new());
let dur = Duration::from_millis(10);
let interval = t!(Interval::new(dur, &l.handle()));
let start = Instant::now();
let interval = t!(Interval::new(dur, &l.handle()));
t!(l.run(interval.take(1).collect()));
assert!(start.elapsed() >= dur);
}
@ -30,8 +30,8 @@ fn two_times() {
drop(env_logger::init());
let mut l = t!(Core::new());
let dur = Duration::from_millis(10);
let interval = t!(Interval::new(dur, &l.handle()));
let start = Instant::now();
let interval = t!(Interval::new(dur, &l.handle()));
let result = t!(l.run(interval.take(2).collect()));
assert!(start.elapsed() >= dur*2);
assert_eq!(result, vec![(), ()]);

View File

@ -18,8 +18,8 @@ fn smoke() {
drop(env_logger::init());
let mut l = t!(Core::new());
let dur = Duration::from_millis(10);
let timeout = t!(Timeout::new(dur, &l.handle()));
let start = Instant::now();
let timeout = t!(Timeout::new(dur, &l.handle()));
t!(l.run(timeout));
assert!(start.elapsed() >= (dur / 2));
}