summaryrefslogtreecommitdiff
path: root/test/parallel/test-assert-typedarray-deepequal.js
diff options
context:
space:
mode:
authorCaleb Sander <caleb.sander@gmail.com>2018-08-10 23:38:21 -0700
committerRuben Bridgewater <ruben@bridgewater.de>2018-08-20 12:03:08 +0200
commit439b75b9c07405457798c1d6acb7dc144f46ea32 (patch)
tree0769e04cfe415003006a66b8a29267566242d8c7 /test/parallel/test-assert-typedarray-deepequal.js
parent6bc43aeea79353a42ea1d678040fc3a64be9af4a (diff)
downloadandroid-node-v8-439b75b9c07405457798c1d6acb7dc144f46ea32.tar.gz
android-node-v8-439b75b9c07405457798c1d6acb7dc144f46ea32.tar.bz2
android-node-v8-439b75b9c07405457798c1d6acb7dc144f46ea32.zip
assert, util: *DeepEqual() handles ArrayBuffers
Previously, all ArrayBuffers were considered equal in assert.deepEqual() and assert.deepStrictEqual(). Now, ArrayBuffers and SharedArrayBuffers must have the same byte lengths and contents to be considered equal. In loose mode, an ArrayBuffer is considered equal to a SharedArrayBuffer if they have the same contents, whereas in strict mode, the buffers must be both ArrayBuffers or both SharedArrayBuffers. PR-URL: https://github.com/nodejs/node/pull/22266 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-assert-typedarray-deepequal.js')
-rw-r--r--test/parallel/test-assert-typedarray-deepequal.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js
index b648f07d32..78394bb91f 100644
--- a/test/parallel/test-assert-typedarray-deepequal.js
+++ b/test/parallel/test-assert-typedarray-deepequal.js
@@ -23,7 +23,9 @@ const equalArrayPairs = [
[new Float32Array([+0.0]), new Float32Array([+0.0])],
[new Uint8Array([1, 2, 3, 4]).subarray(1), new Uint8Array([2, 3, 4])],
[new Uint16Array([1, 2, 3, 4]).subarray(1), new Uint16Array([2, 3, 4])],
- [new Uint32Array([1, 2, 3, 4]).subarray(1, 3), new Uint32Array([2, 3])]
+ [new Uint32Array([1, 2, 3, 4]).subarray(1, 3), new Uint32Array([2, 3])],
+ [new ArrayBuffer(3), new ArrayBuffer(3)],
+ [new SharedArrayBuffer(3), new SharedArrayBuffer(3)]
];
const looseEqualArrayPairs = [
@@ -31,7 +33,8 @@ const looseEqualArrayPairs = [
[new Int16Array(256), new Uint16Array(256)],
[new Int16Array([256]), new Uint16Array([256])],
[new Float32Array([+0.0]), new Float32Array([-0.0])],
- [new Float64Array([+0.0]), new Float64Array([-0.0])]
+ [new Float64Array([+0.0]), new Float64Array([-0.0])],
+ [new ArrayBuffer(3), new SharedArrayBuffer(3)]
];
const notEqualArrayPairs = [
@@ -44,7 +47,19 @@ const notEqualArrayPairs = [
[new Int16Array([-256]), new Uint16Array([0xff00])], // same bits
[new Int32Array([-256]), new Uint32Array([0xffffff00])], // ditto
[new Float32Array([0.1]), new Float32Array([0.0])],
- [new Float64Array([0.1]), new Float64Array([0.0])]
+ [new Float64Array([0.1]), new Float64Array([0.0])],
+ [new Uint8Array([1, 2, 3]).buffer, new Uint8Array([4, 5, 6]).buffer],
+ [
+ new Uint8Array(new SharedArrayBuffer(3)).fill(1).buffer,
+ new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer
+ ],
+ [new ArrayBuffer(2), new ArrayBuffer(3)],
+ [new SharedArrayBuffer(2), new SharedArrayBuffer(3)],
+ [new ArrayBuffer(2), new SharedArrayBuffer(3)],
+ [
+ new Uint8Array(new ArrayBuffer(3)).fill(1).buffer,
+ new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer
+ ]
];
equalArrayPairs.forEach((arrayPair) => {