summaryrefslogtreecommitdiffstats
path: root/library/std/src/time/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/time/tests.rs')
-rw-r--r--library/std/src/time/tests.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/time/tests.rs b/library/std/src/time/tests.rs
index 6229556c8..2e64ae59a 100644
--- a/library/std/src/time/tests.rs
+++ b/library/std/src/time/tests.rs
@@ -88,6 +88,14 @@ fn instant_math_is_associative() {
// Changing the order of instant math shouldn't change the results,
// especially when the expression reduces to X + identity.
assert_eq!((now + offset) - now, (now - now) + offset);
+
+ // On any platform, `Instant` should have the same resolution as `Duration` (e.g. 1 nanosecond)
+ // or better. Otherwise, math will be non-associative (see #91417).
+ let now = Instant::now();
+ let provided_offset = Duration::from_nanos(1);
+ let later = now + provided_offset;
+ let measured_offset = later - now;
+ assert_eq!(measured_offset, provided_offset);
}
#[test]