summaryrefslogtreecommitdiff
path: root/test/parallel/test-assert.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-09-10 08:58:46 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-09-19 13:22:32 +0200
commit28902f33aa916e12b094431a56e825ba649edbc4 (patch)
tree04ff958960ae29387bb9014e182a9e2cabee3a4c /test/parallel/test-assert.js
parentb95b0d87c3582eee82600d076874c9d4afeb4b72 (diff)
downloadandroid-node-v8-28902f33aa916e12b094431a56e825ba649edbc4.tar.gz
android-node-v8-28902f33aa916e12b094431a56e825ba649edbc4.tar.bz2
android-node-v8-28902f33aa916e12b094431a56e825ba649edbc4.zip
assert: improve diff output
The output is now a tiny bit improved by sorting object properties when inspecting the values that are compared with each other. That reduces the overall diff for identical objects with a different property insertion order. PR-URL: https://github.com/nodejs/node/pull/22788 Refs: https://github.com/nodejs/node/issues/22763 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test/parallel/test-assert.js')
-rw-r--r--test/parallel/test-assert.js39
1 files changed, 26 insertions, 13 deletions
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index 13043ae2f7..ed6af5310f 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -293,7 +293,7 @@ testAssertionMessage(-Infinity, '-Infinity');
testAssertionMessage([1, 2, 3], '[\n+ 1,\n+ 2,\n+ 3\n+ ]');
testAssertionMessage(function f() {}, '[Function: f]');
testAssertionMessage(function() {}, '[Function]');
-testAssertionMessage(circular, '{\n+ y: 1,\n+ x: [Circular]\n+ }');
+testAssertionMessage(circular, '{\n+ x: [Circular],\n+ y: 1\n+ }');
testAssertionMessage({ a: undefined, b: null },
'{\n+ a: undefined,\n+ b: null\n+ }');
testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity },
@@ -602,8 +602,8 @@ assert.throws(
'\n' +
'+ {}\n' +
'- {\n' +
- "- loop: 'forever',\n" +
- '- [Symbol(nodejs.util.inspect.custom)]: [Function]\n' +
+ '- [Symbol(nodejs.util.inspect.custom)]: [Function],\n' +
+ "- loop: 'forever'\n" +
'- }'
});
@@ -885,9 +885,12 @@ common.expectsError(
code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]',
message: `${start}\n${actExp}\n\n` +
- " Comparison {\n name: 'TypeError',\n" +
- " message: 'Wrong value',\n+ code: 404\n" +
- '- code: 404,\n- foo: undefined\n }'
+ ' Comparison {\n' +
+ ' code: 404,\n' +
+ '- foo: undefined,\n' +
+ " message: 'Wrong value',\n" +
+ " name: 'TypeError'\n" +
+ ' }'
}
);
@@ -899,9 +902,13 @@ common.expectsError(
code: 'ERR_ASSERTION',
name: 'AssertionError [ERR_ASSERTION]',
message: `${start}\n${actExp}\n\n` +
- " Comparison {\n name: 'TypeError',\n" +
- " message: 'Wrong value',\n+ code: 404\n" +
- "- code: '404',\n- foo: undefined\n }"
+ ' Comparison {\n' +
+ '+ code: 404,\n' +
+ "- code: '404',\n" +
+ '- foo: undefined,\n' +
+ " message: 'Wrong value',\n" +
+ " name: 'TypeError'\n" +
+ ' }'
}
);
@@ -931,8 +938,11 @@ common.expectsError(
name: 'AssertionError [ERR_ASSERTION]',
code: 'ERR_ASSERTION',
message: `${start}\n${actExp}\n\n` +
- " Comparison {\n+ name: 'TypeError',\n- name: 'Error'," +
- "\n message: 'e'\n }"
+ ' Comparison {\n' +
+ " message: 'e',\n" +
+ "+ name: 'TypeError'\n" +
+ "- name: 'Error'\n" +
+ ' }'
}
);
assert.throws(
@@ -942,8 +952,11 @@ common.expectsError(
code: 'ERR_ASSERTION',
generatedMessage: true,
message: `${start}\n${actExp}\n\n` +
- " Comparison {\n name: 'Error',\n+ message: 'foo'" +
- "\n- message: ''\n }"
+ ' Comparison {\n' +
+ "+ message: 'foo',\n" +
+ "- message: '',\n" +
+ " name: 'Error'\n" +
+ ' }'
}
);