diff options
author | Joseph Gentle <me@josephg.com> | 2017-06-02 20:26:25 -0400 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-06-05 18:33:49 -0400 |
commit | 7cddcc971576aa4b22654132db1c9debbcc0839e (patch) | |
tree | 5209d6cf2edd56e722b3776f11732718b5002858 /test | |
parent | 30a20bda7daf24d7ee6c1f8d07249a1f12e75aba (diff) | |
download | android-node-v8-7cddcc971576aa4b22654132db1c9debbcc0839e.tar.gz android-node-v8-7cddcc971576aa4b22654132db1c9debbcc0839e.tar.bz2 android-node-v8-7cddcc971576aa4b22654132db1c9debbcc0839e.zip |
assert: fix deepEqual similar sets and maps bug
This fixes a bug where deepEqual and deepStrictEqual would have
incorrect behaviour in sets and maps containing multiple equivalent
keys.
PR-URL: https://github.com/nodejs/node/pull/13426
Fixes: https://github.com/nodejs/node/issues/13347
Refs: https://github.com/nodejs/node/pull/12142
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-assert-deep.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index f6fed8411b..fecb5c89db 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -187,6 +187,28 @@ assertOnlyDeepEqual(new Map([['a', '1']]), new Map([['a', 1]])); assertDeepAndStrictEqual(new Set([{}]), new Set([{}])); +// Ref: https://github.com/nodejs/node/issues/13347 +assertNotDeepOrStrict( + new Set([{a: 1}, {a: 1}]), + new Set([{a: 1}, {a: 2}]) +); +assertNotDeepOrStrict( + new Set([{a: 1}, {a: 1}, {a: 2}]), + new Set([{a: 1}, {a: 2}, {a: 2}]) +); +assertNotDeepOrStrict( + new Map([[{x: 1}, 5], [{x: 1}, 5]]), + new Map([[{x: 1}, 5], [{x: 2}, 5]]) +); + +assertNotDeepOrStrict(new Set([3, '3']), new Set([3, 4])); +assertNotDeepOrStrict(new Map([[3, 0], ['3', 0]]), new Map([[3, 0], [4, 0]])); + +assertNotDeepOrStrict( + new Set([{a: 1}, {a: 1}, {a: 2}]), + new Set([{a: 1}, {a: 2}, {a: 2}]) +); + // This is an awful case, where a map contains multiple equivalent keys: assertOnlyDeepEqual( new Map([[1, 'a'], ['1', 'b']]), |