Skip to content

Commit c64868e

Browse files
committed
Only run typed array tests against supported types
1 parent 20c88bb commit c64868e

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

test/node/types.js

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -107,44 +107,31 @@ console.log('Testing', 'isBoxedPrimitive');
107107
assert(types.isBoxedPrimitive(entry))
108108
});
109109

110-
{
111-
assert(!types.isUint8Array({ [Symbol.toStringTag]: 'Uint8Array' }));
112-
assert(types.isUint8Array(vm.runInNewContext('new Uint8Array')));
113-
114-
assert(!types.isUint8ClampedArray({
115-
[Symbol.toStringTag]: 'Uint8ClampedArray'
116-
}));
117-
assert(types.isUint8ClampedArray(
118-
vm.runInNewContext('new Uint8ClampedArray')
119-
));
120-
121-
assert(!types.isUint16Array({ [Symbol.toStringTag]: 'Uint16Array' }));
122-
assert(types.isUint16Array(vm.runInNewContext('new Uint16Array')));
123-
124-
assert(!types.isUint32Array({ [Symbol.toStringTag]: 'Uint32Array' }));
125-
assert(types.isUint32Array(vm.runInNewContext('new Uint32Array')));
126-
127-
assert(!types.isInt8Array({ [Symbol.toStringTag]: 'Int8Array' }));
128-
assert(types.isInt8Array(vm.runInNewContext('new Int8Array')));
129-
130-
assert(!types.isInt16Array({ [Symbol.toStringTag]: 'Int16Array' }));
131-
assert(types.isInt16Array(vm.runInNewContext('new Int16Array')));
132-
133-
assert(!types.isInt32Array({ [Symbol.toStringTag]: 'Int32Array' }));
134-
assert(types.isInt32Array(vm.runInNewContext('new Int32Array')));
135-
136-
assert(!types.isFloat32Array({ [Symbol.toStringTag]: 'Float32Array' }));
137-
assert(types.isFloat32Array(vm.runInNewContext('new Float32Array')));
138-
139-
assert(!types.isFloat64Array({ [Symbol.toStringTag]: 'Float64Array' }));
140-
assert(types.isFloat64Array(vm.runInNewContext('new Float64Array')));
141-
142-
assert(!types.isBigInt64Array({ [Symbol.toStringTag]: 'BigInt64Array' }));
143-
assert(types.isBigInt64Array(vm.runInNewContext('new BigInt64Array')));
144-
145-
assert(!types.isBigUint64Array({ [Symbol.toStringTag]: 'BigUint64Array' }));
146-
assert(types.isBigUint64Array(vm.runInNewContext('new BigUint64Array')));
147-
}
110+
[
111+
'Uint8Array',
112+
'Uint8ClampedArray',
113+
'Uint16Array',
114+
'Uint32Array',
115+
'Int8Array',
116+
'Int16Array',
117+
'Int32Array',
118+
'Float32Array',
119+
'Float64Array',
120+
'BigInt64Array',
121+
'BigUint64Array'
122+
].forEach(typedArray => {
123+
const method = 'is' + typedArray;
124+
const constructor = 'new ' + typedArray;
125+
let array;
126+
try {
127+
array = vm.runInNewContext(constructor);
128+
} catch (e) {
129+
return;
130+
}
131+
console.log('Testing', method);
132+
assert(!types[method]({ [Symbol.toStringTag]: typedArray }));
133+
assert(types[method](array));
134+
});
148135

149136
{
150137
const primitive = true;

0 commit comments

Comments
 (0)