Skip to content

Commit d473981

Browse files
committed
fix test
1 parent 9458edf commit d473981

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tests/pass/shims/time-with-isolation.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
use std::time::{Duration, Instant};
22

3-
fn duration_sanity(diff: Duration) {
4-
// On my laptop, I observed times around 15-40ms. Add 10x lee-way both ways.
5-
assert!(diff.as_millis() > 1);
6-
assert!(diff.as_millis() < 500);
7-
}
8-
93
fn test_sleep() {
104
let before = Instant::now();
115
std::thread::sleep(Duration::from_millis(100));
@@ -26,7 +20,9 @@ fn main() {
2620
let diff = now2.duration_since(now1);
2721
assert_eq!(now1 + diff, now2);
2822
assert_eq!(now2 - diff, now1);
29-
duration_sanity(diff);
23+
// The virtual clock is deterministic and I got 29us. This should be updated if
24+
// `NANOSECONDS_PER_BASIC_BLOCK` changes.
25+
assert_eq!(diff.as_micros(), 29);
3026

3127
test_sleep();
3228
}

0 commit comments

Comments
 (0)