@@ -13,6 +13,10 @@ tmpdir.refresh();
1313
1414let testIndex = 0 ;
1515
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+
1620function getFilename ( ) {
1721 const filename = path . join ( tmpdir . path , `test-file-${ ++ testIndex } ` ) ;
1822 fs . writeFileSync ( filename , 'test' ) ;
@@ -26,8 +30,8 @@ function verifyStats(bigintStats, numStats) {
2630 const time = val . getTime ( ) ;
2731 const time2 = bigintStats [ key ] . getTime ( ) ;
2832 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` +
3135 `Number version ${ time } , BigInt version ${ time2 } n` ) ;
3236 } else if ( key === 'mode' ) {
3337 assert . strictEqual ( bigintStats [ key ] , BigInt ( val ) ) ;
@@ -65,17 +69,14 @@ function verifyStats(bigintStats, numStats) {
6569 const nsFromBigInt = bigintStats [ nsKey ] ;
6670 const msFromBigIntNs = Number ( nsFromBigInt / ( 10n ** 6n ) ) ;
6771 const msFromNum = numStats [ key ] ;
68- // The difference between the millisecond-precision values should be
69- // smaller than 2
72+
7073 assert (
71- Math . abs ( msFromNum - Number ( msFromBigInt ) ) < 2 ,
74+ Math . abs ( msFromNum - Number ( msFromBigInt ) ) < allowableDelta ,
7275 `Number version ${ key } = ${ msFromNum } , ` +
7376 `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+
7778 assert (
78- Math . abs ( msFromNum - Number ( msFromBigIntNs ) ) < 2 ,
79+ Math . abs ( msFromNum - Number ( msFromBigIntNs ) ) < allowableDelta ,
7980 `Number version ${ key } = ${ msFromNum } , ` +
8081 `BigInt version ${ nsKey } = ${ nsFromBigInt } n` +
8182 ` = ${ msFromBigIntNs } ms` ) ;
0 commit comments