MCPcopy Index your code
hub / github.com/nodejs/node / closeEnough

Function closeEnough

test/parallel/test-fs-stat-date.mjs:28–43  ·  view source on GitHub ↗
(actual, expected, margin)

Source from the content-addressed store, hash-verified

26
27// Date might round down timestamp
28function closeEnough(actual, expected, margin) {
29 // On ppc64, value is rounded to seconds
30 if (process.arch === 'ppc64') {
31 margin += 1000;
32 }
33
34 // Filesystems without support for timestamps before 1970-01-01, such as NFSv3,
35 // should return 0 for negative numbers. Do not treat it as error.
36 if (actual === 0 && expected < 0) {
37 console.log(`ignored 0 while expecting ${expected}`);
38 return;
39 }
40
41 assert.ok(Math.abs(Number(actual - expected)) < margin,
42 `expected ${expected} ± ${margin}, got ${actual}`);
43}
44
45// Ensure that accessed atime and mtime are enumerable
46function validateEnumerability(stats) {

Callers 1

runTestFunction · 0.70

Calls 2

logMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…