diff options
| author | bors <bors@rust-lang.org> | 2013-11-13 13:31:24 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-13 13:31:24 -0800 |
| commit | 2b2a89d97f72aa6f1b1fc9849c4322f294747e12 (patch) | |
| tree | 219cda823066d805573b5d1fe373db24fcf80434 /src | |
| parent | a79ed57beb759bf1753d80a801756d82bea7ec10 (diff) | |
| parent | b9b908f62fa4c68d58c4c67c5f397914674bc196 (diff) | |
| download | rust-2b2a89d97f72aa6f1b1fc9849c4322f294747e12.tar.gz rust-2b2a89d97f72aa6f1b1fc9849c4322f294747e12.zip | |
auto merge of #10447 : alexcrichton/rust/flaky-time-test, r=catamorphism
This test was failing periodically on windows and other platforms, and in debugging the issue locally I've found that the previous test was failing at the assertion `ns0 <= ns1`. Upon inspecting the values, the two numbers were very close to one another, but off by a little bit. I believe that this is because `precise_time_s` goes from `u64` -> `f64` and then we go again back to `u64` for the assertion. This conversion is a lossy one that's not always guaranteed to succeed, so instead I've changed the test to only compare against u64 instances.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libextra/time.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libextra/time.rs b/src/libextra/time.rs index 901daba84ed..c79c21f0bf6 100644 --- a/src/libextra/time.rs +++ b/src/libextra/time.rs @@ -1005,18 +1005,17 @@ mod tests { fn test_precise_time() { let s0 = precise_time_s(); - let ns1 = precise_time_ns(); - debug!("s0={} sec", f64::to_str_digits(s0, 9u)); assert!(s0 > 0.); - let ns0 = (s0 * 1000000000.) as u64; - debug!("ns0={:?} ns", ns0); - debug!("ns1={:?} ns", ns0); + let ns0 = precise_time_ns(); + let ns1 = precise_time_ns(); + debug!("ns0={:?} ns", ns0); + debug!("ns1={:?} ns", ns1); assert!(ns1 >= ns0); let ns2 = precise_time_ns(); - debug!("ns2={:?} ns", ns0); + debug!("ns2={:?} ns", ns2); assert!(ns2 >= ns1); } |
