diff options
author | Anna Henningsen <sqrt@entless.org> | 2016-03-26 03:29:13 +0100 |
---|---|---|
committer | Benjamin Gruenbaum <inglor@gmail.com> | 2016-03-31 21:48:02 +0300 |
commit | cf949293ba55e5d8193e26623c6e9201b14cd819 (patch) | |
tree | 2e3e3bd0dd392cb925ef20e8e541f32cd5dd81c9 /test | |
parent | d6c9f64e98092bbca41209bb1babe22bee64be42 (diff) | |
download | android-node-v8-cf949293ba55e5d8193e26623c6e9201b14cd819.tar.gz android-node-v8-cf949293ba55e5d8193e26623c6e9201b14cd819.tar.bz2 android-node-v8-cf949293ba55e5d8193e26623c6e9201b14cd819.zip |
assert: Check typed array view type in deepEqual
Do not convert typed arrays to `Buffer` for deepEqual since
their values may not be accurately represented by 8-bit ints.
Instead perform binary comparison of underlying `ArrayBuffer`s,
but only when the array types match.
Never apply any kind of optimization for floating-point typed
arrays since bit pattern equality is not the right kind of check
for them.
PR-URL: https://github.com/nodejs/node/pull/5910
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Fixes: https://github.com/nodejs/node/issues/5907
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-assert-typedarray-deepequal.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js index 68edefdc17..be4462de5d 100644 --- a/test/parallel/test-assert-typedarray-deepequal.js +++ b/test/parallel/test-assert-typedarray-deepequal.js @@ -20,13 +20,25 @@ const equalArrayPairs = [ [new Int16Array(1e5), new Int16Array(1e5)], [new Int32Array(1e5), new Int32Array(1e5)], [new Float32Array(1e5), new Float32Array(1e5)], - [new Float64Array(1e5), new Float64Array(1e5)] + [new Float64Array(1e5), new Float64Array(1e5)], + [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 Float32Array([-0.0])], + [new Float64Array([+0.0]), new Float64Array([-0.0])] ]; const notEqualArrayPairs = [ [new Uint8Array(2), new Uint8Array(3)], [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])], - [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])] + [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])], + [new Uint16Array([2]), new Uint16Array([3])], + [new Uint16Array([0]), new Uint16Array([256])], + [new Int16Array([0]), new Uint16Array([256])], + [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])] ]; equalArrayPairs.forEach((arrayPair) => { |