-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I ran the unit tests on the module and got a random failure in the section should renew the item's timeout on every single 'get'. The assertion is too narrow. For example, timeout + timeout * 4/3 = 233.3333...., while you check that new Date().getTime() - now = 233 should be greater. Since the value's precision is not high enough, it does not account for the 0.3333 nanoseconds, it may be greater if and only if the time required to run the test is greater than 5000 nanoseconds. This is not the case on fast computers. Therefore, the test is fails.
You should round down the value and check for "greater or equal" instead :
assert.ok(Math.floor(timeout + timeout * 4/3) <= new Date().getTime() - now);The same thing happens for the test case should expire an item by timeout where the test
assert.ok( timeout < delta);should be
assert.ok( timeout <= delta);for the same reason.
Metadata
Metadata
Assignees
Labels
No labels