test: only inspect on failure

The inspection was done in all cases so far and that's not necessary.
Therefore this changed this behavior to only inspect the input on
failure cases.

PR-URL: https://github.com/nodejs/node/pull/26360
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Ruben Bridgewater 2019-01-27 04:02:46 +01:00
parent f871c80a6d
commit 6c38fcff1d
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
2 changed files with 10 additions and 8 deletions

View File

@ -131,11 +131,12 @@ joinTests.forEach((test) => {
} else {
os = 'posix';
}
const message =
`path.${os}.join(${test[0].map(JSON.stringify).join(',')})\n expect=${
if (actual !== expected && actualAlt !== expected) {
const delimiter = test[0].map(JSON.stringify).join(',');
const message = `path.${os}.join(${delimiter})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
if (actual !== expected && actualAlt !== expected)
failures.push(`\n${message}`);
}
});
});
});

View File

@ -56,12 +56,13 @@ relativeTests.forEach((test) => {
test[1].forEach((test) => {
const actual = relative(test[0], test[1]);
const expected = test[2];
const os = relative === path.win32.relative ? 'win32' : 'posix';
const message = `path.${os}.relative(${
test.slice(0, 2).map(JSON.stringify).join(',')})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
if (actual !== expected)
if (actual !== expected) {
const os = relative === path.win32.relative ? 'win32' : 'posix';
const message = `path.${os}.relative(${
test.slice(0, 2).map(JSON.stringify).join(',')})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
failures.push(`\n${message}`);
}
});
});
assert.strictEqual(failures.length, 0, failures.join(''));