| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | require('../common'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | + const { test, suite } = require('node:test'); | ||
| 5 | 6 | ||
| 6 | 7 | function makeBlock(f) { | |
| 7 | 8 | const args = Array.prototype.slice.call(arguments, 1); | |
@@ -10,82 +11,94 @@ function makeBlock(f) { | |||
| 10 | 11 | }; | |
| 11 | 12 | } | |
| 12 | 13 | ||
| 13 | - const equalArrayPairs = [ | ||
| 14 | - [new Uint8Array(1e5), new Uint8Array(1e5)], | ||
| 15 | - [new Uint16Array(1e5), new Uint16Array(1e5)], | ||
| 16 | - [new Uint32Array(1e5), new Uint32Array(1e5)], | ||
| 17 | - [new Uint8ClampedArray(1e5), new Uint8ClampedArray(1e5)], | ||
| 18 | - [new Int8Array(1e5), new Int8Array(1e5)], | ||
| 19 | - [new Int16Array(1e5), new Int16Array(1e5)], | ||
| 20 | - [new Int32Array(1e5), new Int32Array(1e5)], | ||
| 21 | - [new Float32Array(1e5), new Float32Array(1e5)], | ||
| 22 | - [new Float64Array(1e5), new Float64Array(1e5)], | ||
| 23 | - [new Float32Array([+0.0]), new Float32Array([+0.0])], | ||
| 24 | - [new Uint8Array([1, 2, 3, 4]).subarray(1), new Uint8Array([2, 3, 4])], | ||
| 25 | - [new Uint16Array([1, 2, 3, 4]).subarray(1), new Uint16Array([2, 3, 4])], | ||
| 26 | - [new Uint32Array([1, 2, 3, 4]).subarray(1, 3), new Uint32Array([2, 3])], | ||
| 27 | - [new ArrayBuffer(3), new ArrayBuffer(3)], | ||
| 28 | - [new SharedArrayBuffer(3), new SharedArrayBuffer(3)], | ||
| 29 | - ]; | ||
| 14 | + suite('equalArrayPairs', () => { | ||
| 15 | + const equalArrayPairs = [ | ||
| 16 | + [new Uint8Array(1e5), new Uint8Array(1e5)], | ||
| 17 | + [new Uint16Array(1e5), new Uint16Array(1e5)], | ||
| 18 | + [new Uint32Array(1e5), new Uint32Array(1e5)], | ||
| 19 | + [new Uint8ClampedArray(1e5), new Uint8ClampedArray(1e5)], | ||
| 20 | + [new Int8Array(1e5), new Int8Array(1e5)], | ||
| 21 | + [new Int16Array(1e5), new Int16Array(1e5)], | ||
| 22 | + [new Int32Array(1e5), new Int32Array(1e5)], | ||
| 23 | + [new Float32Array(1e5), new Float32Array(1e5)], | ||
| 24 | + [new Float64Array(1e5), new Float64Array(1e5)], | ||
| 25 | + [new Float32Array([+0.0]), new Float32Array([+0.0])], | ||
| 26 | + [new Uint8Array([1, 2, 3, 4]).subarray(1), new Uint8Array([2, 3, 4])], | ||
| 27 | + [new Uint16Array([1, 2, 3, 4]).subarray(1), new Uint16Array([2, 3, 4])], | ||
| 28 | + [new Uint32Array([1, 2, 3, 4]).subarray(1, 3), new Uint32Array([2, 3])], | ||
| 29 | + [new ArrayBuffer(3), new ArrayBuffer(3)], | ||
| 30 | + [new SharedArrayBuffer(3), new SharedArrayBuffer(3)], | ||
| 31 | + ]; | ||
| 30 | 32 | ||
| 31 | - const looseEqualArrayPairs = [ | ||
| 32 | - [new Float32Array([+0.0]), new Float32Array([-0.0])], | ||
| 33 | - [new Float64Array([+0.0]), new Float64Array([-0.0])], | ||
| 34 | - ]; | ||
| 33 | + for (const arrayPair of equalArrayPairs) { | ||
| 34 | + test('', () => { | ||
| 35 | + // eslint-disable-next-line no-restricted-properties | ||
| 36 | + assert.deepEqual(arrayPair[0], arrayPair[1]); | ||
| 37 | + assert.deepStrictEqual(arrayPair[0], arrayPair[1]); | ||
| 38 | + }); | ||
| 39 | + } | ||
| 40 | + }); | ||
| 35 | 41 | ||
| 36 | - const notEqualArrayPairs = [ | ||
| 37 | - [new ArrayBuffer(3), new SharedArrayBuffer(3)], | ||
| 38 | - [new Int16Array(256), new Uint16Array(256)], | ||
| 39 | - [new Int16Array([256]), new Uint16Array([256])], | ||
| 40 | - [new Float64Array([+0.0]), new Float32Array([-0.0])], | ||
| 41 | - [new Uint8Array(2), new Uint8Array(3)], | ||
| 42 | - [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])], | ||
| 43 | - [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])], | ||
| 44 | - [new Uint16Array([2]), new Uint16Array([3])], | ||
| 45 | - [new Uint16Array([0]), new Uint16Array([256])], | ||
| 46 | - [new Int16Array([0]), new Uint16Array([256])], | ||
| 47 | - [new Int16Array([-256]), new Uint16Array([0xff00])], // same bits | ||
| 48 | - [new Int32Array([-256]), new Uint32Array([0xffffff00])], // ditto | ||
| 49 | - [new Float32Array([0.1]), new Float32Array([0.0])], | ||
| 50 | - [new Float32Array([0.1]), new Float32Array([0.1, 0.2])], | ||
| 51 | - [new Float64Array([0.1]), new Float64Array([0.0])], | ||
| 52 | - [new Uint8Array([1, 2, 3]).buffer, new Uint8Array([4, 5, 6]).buffer], | ||
| 53 | - [ | ||
| 54 | - new Uint8Array(new SharedArrayBuffer(3)).fill(1).buffer, | ||
| 55 | - new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer, | ||
| 56 | - ], | ||
| 57 | - [new ArrayBuffer(2), new ArrayBuffer(3)], | ||
| 58 | - [new SharedArrayBuffer(2), new SharedArrayBuffer(3)], | ||
| 59 | - [new ArrayBuffer(2), new SharedArrayBuffer(3)], | ||
| 60 | - [ | ||
| 61 | - new Uint8Array(new ArrayBuffer(3)).fill(1).buffer, | ||
| 62 | - new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer, | ||
| 63 | - ], | ||
| 64 | - ]; | ||
| 42 | + suite('looseEqualArrayPairs', () => { | ||
| 43 | + const looseEqualArrayPairs = [ | ||
| 44 | + [new Float32Array([+0.0]), new Float32Array([-0.0])], | ||
| 45 | + [new Float64Array([+0.0]), new Float64Array([-0.0])], | ||
| 46 | + ]; | ||
| 65 | 47 | ||
| 66 | - for (const arrayPair of equalArrayPairs) { | ||
| 67 | - // eslint-disable-next-line no-restricted-properties | ||
| 68 | - assert.deepEqual(arrayPair[0], arrayPair[1]); | ||
| 69 | - assert.deepStrictEqual(arrayPair[0], arrayPair[1]); | ||
| 70 | - } | ||
| 48 | + for (const arrayPair of looseEqualArrayPairs) { | ||
| 49 | + test('', () => { | ||
| 50 | + // eslint-disable-next-line no-restricted-properties | ||
| 51 | + assert.deepEqual(arrayPair[0], arrayPair[1]); | ||
| 52 | + assert.throws( | ||
| 53 | + makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]), | ||
| 54 | + assert.AssertionError | ||
| 55 | + ); | ||
| 56 | + }); | ||
| 57 | + } | ||
| 58 | + }); | ||
| 71 | 59 | ||
| 72 | - for (const arrayPair of looseEqualArrayPairs) { | ||
| 73 | - // eslint-disable-next-line no-restricted-properties | ||
| 74 | - assert.deepEqual(arrayPair[0], arrayPair[1]); | ||
| 75 | - assert.throws( | ||
| 76 | - makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]), | ||
| 77 | - assert.AssertionError | ||
| 78 | - ); | ||
| 79 | - } | ||
| 60 | + suite('notEqualArrayPairs', () => { | ||
| 61 | + const notEqualArrayPairs = [ | ||
| 62 | + [new ArrayBuffer(3), new SharedArrayBuffer(3)], | ||
| 63 | + [new Int16Array(256), new Uint16Array(256)], | ||
| 64 | + [new Int16Array([256]), new Uint16Array([256])], | ||
| 65 | + [new Float64Array([+0.0]), new Float32Array([-0.0])], | ||
| 66 | + [new Uint8Array(2), new Uint8Array(3)], | ||
| 67 | + [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])], | ||
| 68 | + [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])], | ||
| 69 | + [new Uint16Array([2]), new Uint16Array([3])], | ||
| 70 | + [new Uint16Array([0]), new Uint16Array([256])], | ||
| 71 | + [new Int16Array([0]), new Uint16Array([256])], | ||
| 72 | + [new Int16Array([-256]), new Uint16Array([0xff00])], // same bits | ||
| 73 | + [new Int32Array([-256]), new Uint32Array([0xffffff00])], // ditto | ||
| 74 | + [new Float32Array([0.1]), new Float32Array([0.0])], | ||
| 75 | + [new Float32Array([0.1]), new Float32Array([0.1, 0.2])], | ||
| 76 | + [new Float64Array([0.1]), new Float64Array([0.0])], | ||
| 77 | + [new Uint8Array([1, 2, 3]).buffer, new Uint8Array([4, 5, 6]).buffer], | ||
| 78 | + [ | ||
| 79 | + new Uint8Array(new SharedArrayBuffer(3)).fill(1).buffer, | ||
| 80 | + new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer, | ||
| 81 | + ], | ||
| 82 | + [new ArrayBuffer(2), new ArrayBuffer(3)], | ||
| 83 | + [new SharedArrayBuffer(2), new SharedArrayBuffer(3)], | ||
| 84 | + [new ArrayBuffer(2), new SharedArrayBuffer(3)], | ||
| 85 | + [ | ||
| 86 | + new Uint8Array(new ArrayBuffer(3)).fill(1).buffer, | ||
| 87 | + new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer, | ||
| 88 | + ], | ||
| 89 | + ]; | ||
| 80 | 90 | ||
| 81 | - for (const arrayPair of notEqualArrayPairs) { | ||
| 82 | - assert.throws( | ||
| 83 | - // eslint-disable-next-line no-restricted-properties | ||
| 84 | - makeBlock(assert.deepEqual, arrayPair[0], arrayPair[1]), | ||
| 85 | - assert.AssertionError | ||
| 86 | - ); | ||
| 87 | - assert.throws( | ||
| 88 | - makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]), | ||
| 89 | - assert.AssertionError | ||
| 90 | - ); | ||
| 91 | - } | ||
| 91 | + for (const arrayPair of notEqualArrayPairs) { | ||
| 92 | + test('', () => { | ||
| 93 | + assert.throws( | ||
| 94 | + // eslint-disable-next-line no-restricted-properties | ||
| 95 | + makeBlock(assert.deepEqual, arrayPair[0], arrayPair[1]), | ||
| 96 | + assert.AssertionError | ||
| 97 | + ); | ||
| 98 | + assert.throws( | ||
| 99 | + makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]), | ||
| 100 | + assert.AssertionError | ||
| 101 | + ); | ||
| 102 | + }); | ||
| 103 | + } | ||
| 104 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments