diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-06-03 16:05:37 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-06-12 19:50:03 -0700 |
commit | 81496567e76006a7d07a8552215fc6333c183480 (patch) | |
tree | 6c080c0da1be8b0ced5a01814c181fddcda78f70 /test | |
parent | e4ec4f2656f14d3992da154c46f6c0c44025f30d (diff) | |
download | android-node-v8-81496567e76006a7d07a8552215fc6333c183480.tar.gz android-node-v8-81496567e76006a7d07a8552215fc6333c183480.tar.bz2 android-node-v8-81496567e76006a7d07a8552215fc6333c183480.zip |
assert: print more lines in the error diff
So far consequitive identical lines were collapsed if there were at
least three. Now they are only collapsed from five identical lines on.
This also simplifies the implementation a tiny bit by abstracting some
logic.
PR-URL: https://github.com/nodejs/node/pull/28058
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-assert-deep.js | 38 | ||||
-rw-r--r-- | test/parallel/test-assert.js | 9 | ||||
-rw-r--r-- | test/pseudo-tty/test-assert-colors.js | 3 |
3 files changed, 31 insertions, 19 deletions
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 7cd57b0a05..f0af085c6a 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -53,7 +53,7 @@ assert.throws( code: 'ERR_ASSERTION', message: `${defaultMsgStartFull} ... Lines skipped\n\n` + '+ Uint8Array [\n' + - '- Buffer [Uint8Array] [\n 120,\n...\n 10\n ]' + '- Buffer [Uint8Array] [\n 120,\n...\n 122,\n 10\n ]' } ); assert.deepEqual(arr, buf); @@ -66,9 +66,11 @@ assert.deepEqual(arr, buf); () => assert.deepStrictEqual(buf2, buf), { code: 'ERR_ASSERTION', - message: `${defaultMsgStartFull} ... Lines skipped\n\n` + + message: `${defaultMsgStartFull}\n\n` + ' Buffer [Uint8Array] [\n' + - '...\n' + + ' 120,\n' + + ' 121,\n' + + ' 122,\n' + ' 10,\n' + '+ prop: 1\n' + ' ]' @@ -84,9 +86,11 @@ assert.deepEqual(arr, buf); () => assert.deepStrictEqual(arr, arr2), { code: 'ERR_ASSERTION', - message: `${defaultMsgStartFull} ... Lines skipped\n\n` + + message: `${defaultMsgStartFull}\n\n` + ' Uint8Array [\n' + - '...\n' + + ' 120,\n' + + ' 121,\n' + + ' 122,\n' + ' 10,\n' + '- prop: 5\n' + ' ]' @@ -932,17 +936,19 @@ assert.deepStrictEqual(obj1, obj2); ), { message: 'Expected values to be strictly deep-equal:\n' + - '+ actual - expected ... Lines skipped\n' + - '\n' + - ' Comparison {\n' + - '...\n' + - " \"+ foo: 'bar'\\n\" +\n" + - "+ \"- foo: 'baz.'\\n\" +\n" + - "- \"- foo: 'baz'\\n\" +\n" + - " ' }',\n" + - "+ operator: 'deepStrictEqual'\n" + - "- operator: 'throws'\n" + - ' }' + '+ actual - expected ... Lines skipped\n' + + '\n' + + ' Comparison {\n' + + " message: 'Expected values to be strictly deep-equal:\\n' +\n" + + '...\n' + + " ' [TypeError: foo] {\\n' +\n" + + " \"+ foo: 'bar'\\n\" +\n" + + "+ \"- foo: 'baz.'\\n\" +\n" + + "- \"- foo: 'baz'\\n\" +\n" + + " ' }',\n" + + "+ operator: 'deepStrictEqual'\n" + + "- operator: 'throws'\n" + + ' }' } ); } diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index d9ba3716a2..52e8572479 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -482,12 +482,14 @@ assert.throws( '', ' [', ' [', - '...', + ' [', + ' 1,', ' 2,', '+ 3', "- '3'", ' ]', '...', + ' 4,', ' 5', ' ]'].join('\n'); assert.throws( @@ -501,10 +503,12 @@ assert.throws( ' [', ' 1,', '...', + ' 1,', ' 0,', '- 1,', ' 1,', '...', + ' 1,', ' 1', ' ]' ].join('\n'); @@ -521,10 +525,11 @@ assert.throws( ' [', ' 1,', '...', + ' 1,', ' 0,', '+ 1,', ' 1,', - '...', + ' 1,', ' 1', ' ]' ].join('\n'); diff --git a/test/pseudo-tty/test-assert-colors.js b/test/pseudo-tty/test-assert-colors.js index 76001bf786..a241542c34 100644 --- a/test/pseudo-tty/test-assert-colors.js +++ b/test/pseudo-tty/test-assert-colors.js @@ -9,7 +9,7 @@ try { // active. process.env.TERM = 'FOOBAR'; delete process.env.NODE_DISABLE_COLORS; - assert.deepStrictEqual([1, 2, 2, 2], [2, 2, 2, 2]); + assert.deepStrictEqual([1, 2, 2, 2, 2], [2, 2, 2, 2, 2]); } catch (err) { const expected = 'Expected values to be strictly deep-equal:\n' + '\u001b[32m+ actual\u001b[39m \u001b[31m- expected\u001b[39m' + @@ -19,6 +19,7 @@ try { '\u001b[31m-\u001b[39m 2,\n' + ' 2,\n' + '\u001b[34m...\u001b[39m\n' + + ' 2,\n' + ' 2\n' + ' ]'; assert.strictEqual(err.message, expected); |