|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const common = require('../common'); |
| 4 | +const assert = require('assert'); |
| 5 | +const a = require('assert'); |
| 6 | + |
| 7 | +function makeBlock(f) { |
| 8 | + var args = Array.prototype.slice.call(arguments, 1); |
| 9 | + return function() { |
| 10 | + return f.apply(this, args); |
| 11 | + }; |
| 12 | +} |
| 13 | + |
| 14 | +const equalArrayPairs = [ |
| 15 | + [new Uint8Array(1e5), new Uint8Array(1e5)], |
| 16 | + [new Uint16Array(1e5), new Uint16Array(1e5)], |
| 17 | + [new Uint32Array(1e5), new Uint32Array(1e5)], |
| 18 | + [new Uint8ClampedArray(1e5), new Uint8ClampedArray(1e5)], |
| 19 | + [new Int8Array(1e5), new Int8Array(1e5)], |
| 20 | + [new Int16Array(1e5), new Int16Array(1e5)], |
| 21 | + [new Int32Array(1e5), new Int32Array(1e5)], |
| 22 | + [new Float32Array(1e5), new Float32Array(1e5)], |
| 23 | + [new Float64Array(1e5), new Float64Array(1e5)] |
| 24 | +]; |
| 25 | + |
| 26 | +const notEqualArrayPairs = [ |
| 27 | + [new Uint8Array(2), new Uint8Array(3)], |
| 28 | + [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])], |
| 29 | + [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])] |
| 30 | +]; |
| 31 | + |
| 32 | +equalArrayPairs.forEach((arrayPair) => { |
| 33 | + assert.deepEqual(arrayPair[0], arrayPair[1]); |
| 34 | +}); |
| 35 | + |
| 36 | +notEqualArrayPairs.forEach((arrayPair) => { |
| 37 | + assert.throws( |
| 38 | + makeBlock(a.deepEqual, arrayPair[0], arrayPair[1]), |
| 39 | + a.AssertionError |
| 40 | + ); |
| 41 | +}); |
0 commit comments