diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-11-30 10:21:14 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-12-03 13:03:44 +0100 |
commit | 4dd56a39f1f1c0e98b223b611c3a869775177c68 (patch) | |
tree | f40edd317a3885fd079f59ae9ec2d68cb2466725 /test/parallel/test-assert-deep.js | |
parent | 2eff120f6d4d88c29e692f67e396916ea71418e2 (diff) | |
download | android-node-v8-4dd56a39f1f1c0e98b223b611c3a869775177c68.tar.gz android-node-v8-4dd56a39f1f1c0e98b223b611c3a869775177c68.tar.bz2 android-node-v8-4dd56a39f1f1c0e98b223b611c3a869775177c68.zip |
assert,util: fix sparse array comparison
Comparing sparse arrays did not work properly. That is fixed and
tests were added to verify that everything works as expected.
This had an impact on `util.isDeepStrictEqual()` and
`assert.deepStrictEqual()` and their counterpart
`assert.notDeepStrictEqual()`.
PR-URL: https://github.com/nodejs/node/pull/24749
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-assert-deep.js')
-rw-r--r-- | test/parallel/test-assert-deep.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index db93f3b6e7..38f3179d40 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -571,9 +571,20 @@ assertNotDeepOrStrict( assertDeepAndStrictEqual(m3, m4); } -// Handle sparse arrays -assertDeepAndStrictEqual([1, , , 3], [1, , , 3]); -assertOnlyDeepEqual([1, , , 3], [1, , , 3, , , ]); +// Handle sparse arrays. +{ + assertDeepAndStrictEqual([1, , , 3], [1, , , 3]); + assertOnlyDeepEqual([1, , , 3], [1, , , 3, , , ]); + const a = new Array(3); + const b = new Array(3); + a[2] = true; + b[1] = true; + assertNotDeepOrStrict(a, b); + b[2] = true; + assertNotDeepOrStrict(a, b); + a[0] = true; + assertNotDeepOrStrict(a, b); +} // Handle different error messages { |