mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 20:29:23 +01:00
test: update test-assert-typedarray-deepequal to use node:test
PR-URL: https://github.com/nodejs/node/pull/54585 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
cf1d5c3a32
commit
5060bbfabc
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { test, suite } = require('node:test');
|
||||||
|
|
||||||
function makeBlock(f) {
|
function makeBlock(f) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1);
|
const args = Array.prototype.slice.call(arguments, 1);
|
||||||
@ -10,7 +11,8 @@ function makeBlock(f) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const equalArrayPairs = [
|
suite('equalArrayPairs', () => {
|
||||||
|
const equalArrayPairs = [
|
||||||
[new Uint8Array(1e5), new Uint8Array(1e5)],
|
[new Uint8Array(1e5), new Uint8Array(1e5)],
|
||||||
[new Uint16Array(1e5), new Uint16Array(1e5)],
|
[new Uint16Array(1e5), new Uint16Array(1e5)],
|
||||||
[new Uint32Array(1e5), new Uint32Array(1e5)],
|
[new Uint32Array(1e5), new Uint32Array(1e5)],
|
||||||
@ -26,14 +28,37 @@ const equalArrayPairs = [
|
|||||||
[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 ArrayBuffer(3), new ArrayBuffer(3)],
|
||||||
[new SharedArrayBuffer(3), new SharedArrayBuffer(3)],
|
[new SharedArrayBuffer(3), new SharedArrayBuffer(3)],
|
||||||
];
|
];
|
||||||
|
|
||||||
const looseEqualArrayPairs = [
|
for (const arrayPair of equalArrayPairs) {
|
||||||
|
test('', () => {
|
||||||
|
// eslint-disable-next-line no-restricted-properties
|
||||||
|
assert.deepEqual(arrayPair[0], arrayPair[1]);
|
||||||
|
assert.deepStrictEqual(arrayPair[0], arrayPair[1]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
suite('looseEqualArrayPairs', () => {
|
||||||
|
const looseEqualArrayPairs = [
|
||||||
[new Float32Array([+0.0]), new Float32Array([-0.0])],
|
[new Float32Array([+0.0]), new Float32Array([-0.0])],
|
||||||
[new Float64Array([+0.0]), new Float64Array([-0.0])],
|
[new Float64Array([+0.0]), new Float64Array([-0.0])],
|
||||||
];
|
];
|
||||||
|
|
||||||
const notEqualArrayPairs = [
|
for (const arrayPair of looseEqualArrayPairs) {
|
||||||
|
test('', () => {
|
||||||
|
// eslint-disable-next-line no-restricted-properties
|
||||||
|
assert.deepEqual(arrayPair[0], arrayPair[1]);
|
||||||
|
assert.throws(
|
||||||
|
makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]),
|
||||||
|
assert.AssertionError
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
suite('notEqualArrayPairs', () => {
|
||||||
|
const notEqualArrayPairs = [
|
||||||
[new ArrayBuffer(3), new SharedArrayBuffer(3)],
|
[new ArrayBuffer(3), new SharedArrayBuffer(3)],
|
||||||
[new Int16Array(256), new Uint16Array(256)],
|
[new Int16Array(256), new Uint16Array(256)],
|
||||||
[new Int16Array([256]), new Uint16Array([256])],
|
[new Int16Array([256]), new Uint16Array([256])],
|
||||||
@ -61,24 +86,10 @@ const notEqualArrayPairs = [
|
|||||||
new Uint8Array(new ArrayBuffer(3)).fill(1).buffer,
|
new Uint8Array(new ArrayBuffer(3)).fill(1).buffer,
|
||||||
new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer,
|
new Uint8Array(new SharedArrayBuffer(3)).fill(2).buffer,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const arrayPair of equalArrayPairs) {
|
for (const arrayPair of notEqualArrayPairs) {
|
||||||
// eslint-disable-next-line no-restricted-properties
|
test('', () => {
|
||||||
assert.deepEqual(arrayPair[0], arrayPair[1]);
|
|
||||||
assert.deepStrictEqual(arrayPair[0], arrayPair[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const arrayPair of looseEqualArrayPairs) {
|
|
||||||
// eslint-disable-next-line no-restricted-properties
|
|
||||||
assert.deepEqual(arrayPair[0], arrayPair[1]);
|
|
||||||
assert.throws(
|
|
||||||
makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]),
|
|
||||||
assert.AssertionError
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const arrayPair of notEqualArrayPairs) {
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
// eslint-disable-next-line no-restricted-properties
|
// eslint-disable-next-line no-restricted-properties
|
||||||
makeBlock(assert.deepEqual, arrayPair[0], arrayPair[1]),
|
makeBlock(assert.deepEqual, arrayPair[0], arrayPair[1]),
|
||||||
@ -88,4 +99,6 @@ for (const arrayPair of notEqualArrayPairs) {
|
|||||||
makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]),
|
makeBlock(assert.deepStrictEqual, arrayPair[0], arrayPair[1]),
|
||||||
assert.AssertionError
|
assert.AssertionError
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user