Commit e05c2c0
authored
Calculate travel_offset to align with the precision of argument to Timecop.travel (#421)
* Calculate travel_offset to align with clock precision
Subtracting two `Time`s returns a `Float`, which may not be accurate
down to subsecond resolution. Because `Float`s are stored as double-
precision values (IEEE 754), they can have resolutions much higher than
the typical minimum clock precision of 10e-9 seconds. Which can result
in two `Time` object not comparing as equal when they are the same down
to the nanosecond, when one has had a travel_offset applied to it.
* Use the realtime clock's resolution when testing travel_offset's alignment
* Improve failure message for travel_offset alignment test
* Test that time_offset keeps precision of very high times passed to Timecop.travel
* Mention this change in History.md1 parent e556094 commit e05c2c0
3 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
299 | 317 | | |
0 commit comments