@@ -13,6 +13,10 @@ tmpdir.refresh();
13
13
14
14
let testIndex = 0 ;
15
15
16
+ // It's possible that the file stats are updated between the two statSync()
17
+ // calls so allow for a small difference.
18
+ const allowableDelta = 5 ;
19
+
16
20
function getFilename ( ) {
17
21
const filename = path . join ( tmpdir . path , `test-file-${ ++ testIndex } ` ) ;
18
22
fs . writeFileSync ( filename , 'test' ) ;
@@ -26,8 +30,8 @@ function verifyStats(bigintStats, numStats) {
26
30
const time = val . getTime ( ) ;
27
31
const time2 = bigintStats [ key ] . getTime ( ) ;
28
32
assert (
29
- Math . abs ( time - time2 ) < 2 ,
30
- `difference of ${ key } .getTime() should < 2 .\n` +
33
+ Math . abs ( time - time2 ) < allowableDelta ,
34
+ `difference of ${ key } .getTime() should < ${ allowableDelta } .\n` +
31
35
`Number version ${ time } , BigInt version ${ time2 } n` ) ;
32
36
} else if ( key === 'mode' ) {
33
37
assert . strictEqual ( bigintStats [ key ] , BigInt ( val ) ) ;
@@ -65,17 +69,14 @@ function verifyStats(bigintStats, numStats) {
65
69
const nsFromBigInt = bigintStats [ nsKey ] ;
66
70
const msFromBigIntNs = Number ( nsFromBigInt / ( 10n ** 6n ) ) ;
67
71
const msFromNum = numStats [ key ] ;
68
- // The difference between the millisecond-precision values should be
69
- // smaller than 2
72
+
70
73
assert (
71
- Math . abs ( msFromNum - Number ( msFromBigInt ) ) < 2 ,
74
+ Math . abs ( msFromNum - Number ( msFromBigInt ) ) < allowableDelta ,
72
75
`Number version ${ key } = ${ msFromNum } , ` +
73
76
`BigInt version ${ key } = ${ msFromBigInt } n` ) ;
74
- // The difference between the millisecond-precision value and the
75
- // nanosecond-precision value scaled down to milliseconds should be
76
- // smaller than 2
77
+
77
78
assert (
78
- Math . abs ( msFromNum - Number ( msFromBigIntNs ) ) < 2 ,
79
+ Math . abs ( msFromNum - Number ( msFromBigIntNs ) ) < allowableDelta ,
79
80
`Number version ${ key } = ${ msFromNum } , ` +
80
81
`BigInt version ${ nsKey } = ${ nsFromBigInt } n` +
81
82
` = ${ msFromBigIntNs } ms` ) ;
0 commit comments