diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-26 03:14:47 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-29 17:05:51 +0200 |
commit | f0a6cb0593eae7743edac8e7b3304a09dde2cba6 (patch) | |
tree | 7d94030550afa76b99a224e7f4488819fc872d14 /lib | |
parent | 564048dc2984c45884e5eb58c903f9a0ebe29ab4 (diff) | |
download | android-node-v8-f0a6cb0593eae7743edac8e7b3304a09dde2cba6.tar.gz android-node-v8-f0a6cb0593eae7743edac8e7b3304a09dde2cba6.tar.bz2 android-node-v8-f0a6cb0593eae7743edac8e7b3304a09dde2cba6.zip |
assert: minor error message improvements
Adjust indentations and fix a typo.
PR-URL: https://github.com/nodejs/node/pull/20315
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/errors.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 51acc211d9..f7b62c89d9 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -360,13 +360,10 @@ function createErrDiff(actual, expected, operator) { // Strict equal with identical objects that are not identical by reference. if (identical === maxLines) { - let base = 'Input object identical but not reference equal:'; - - if (operator !== 'strictEqual') { - // This code path should not be possible to reach. - // The output is identical but it is not clear why. - base = 'Input objects not identical:'; - } + // E.g., assert.deepStrictEqual(Symbol(), Symbol()) + const base = operator === 'strictEqual' ? + 'Input objects identical but not reference equal:' : + 'Input objects not identical:'; // We have to get the result again. The lines were all removed before. const actualLines = inspectValue(actual); @@ -380,7 +377,7 @@ function createErrDiff(actual, expected, operator) { } } - return `${base}\n\n ${actualLines.join('\n ')}\n`; + return `${base}\n\n${actualLines.join('\n')}\n`; } return `${msg}${skipped ? skippedMsg : ''}\n${res}${other}${end}`; } @@ -448,7 +445,7 @@ class AssertionError extends Error { if (res.length === 1) { super(`${base} ${res[0]}`); } else { - super(`${base}\n\n ${res.join('\n ')}\n`); + super(`${base}\n\n${res.join('\n')}\n`); } } else { let res = util.inspect(actual); |