Skip to content

Commit 8b83548

Browse files
committed
Only run isType tests against supported types
1 parent d6dab2f commit 8b83548

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

test/node/types.js

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,53 @@ const inspect = value => {
2323

2424
const wasmBuffer = Buffer.from('0061736d01000000', 'hex');
2525

26-
for (const [ value, _method ] of [
26+
for (const [ getValue, _method ] of [
2727
// [ external, 'isExternal' ],
28-
[ new Date() ],
29-
[ (function() { return arguments; })(), 'isArgumentsObject' ],
30-
[ new Boolean(), 'isBooleanObject' ],
31-
[ new Number(), 'isNumberObject' ],
32-
[ new String(), 'isStringObject' ],
33-
[ Object(Symbol()), 'isSymbolObject' ],
34-
[ Object(BigInt(0)), 'isBigIntObject' ],
35-
[ new Error(), 'isNativeError' ],
36-
[ new RegExp() ],
37-
[ async function() {}, 'isAsyncFunction' ],
38-
[ function*() {}, 'isGeneratorFunction' ],
39-
[ (function*() {})(), 'isGeneratorObject' ],
40-
[ Promise.resolve() ],
41-
[ new Map() ],
42-
[ new Set() ],
43-
[ (new Map())[Symbol.iterator](), 'isMapIterator' ],
44-
[ (new Set())[Symbol.iterator](), 'isSetIterator' ],
45-
[ new WeakMap() ],
46-
[ new WeakSet() ],
47-
[ new ArrayBuffer() ],
48-
[ new Uint8Array() ],
49-
[ new Uint8ClampedArray() ],
50-
[ new Uint16Array() ],
51-
[ new Uint32Array() ],
52-
[ new Int8Array() ],
53-
[ new Int16Array() ],
54-
[ new Int32Array() ],
55-
[ new Float32Array() ],
56-
[ new Float64Array() ],
57-
[ new BigInt64Array() ],
58-
[ new BigUint64Array() ],
59-
[ Object.defineProperty(new Uint8Array(),
28+
[ function() { return new Date(); } ],
29+
[ function() { return (function() { return arguments; })(); }, 'isArgumentsObject' ],
30+
[ function() { return new Boolean(); }, 'isBooleanObject' ],
31+
[ function() { return new Number(); }, 'isNumberObject' ],
32+
[ function() { return new String(); }, 'isStringObject' ],
33+
[ function() { return Object(Symbol()); }, 'isSymbolObject' ],
34+
[ function() { return Object(BigInt(0)); }, 'isBigIntObject' ],
35+
[ function() { return new Error(); }, 'isNativeError' ],
36+
[ function() { return new RegExp(); } ],
37+
[ function() { return async function() {}; }, 'isAsyncFunction' ],
38+
[ function() { return function*() {}; }, 'isGeneratorFunction' ],
39+
[ function() { return (function*() {})(); }, 'isGeneratorObject' ],
40+
[ function() { return Promise.resolve(); } ],
41+
[ function() { return new Map(); } ],
42+
[ function() { return new Set(); } ],
43+
[ function() { return (new Map())[Symbol.iterator](); }, 'isMapIterator' ],
44+
[ function() { return (new Set())[Symbol.iterator](); }, 'isSetIterator' ],
45+
[ function() { return new WeakMap(); } ],
46+
[ function() { return new WeakSet(); } ],
47+
[ function() { return new ArrayBuffer(); } ],
48+
[ function() { return new Uint8Array(); } ],
49+
[ function() { return new Uint8ClampedArray(); } ],
50+
[ function() { return new Uint16Array(); } ],
51+
[ function() { return new Uint32Array(); } ],
52+
[ function() { return new Int8Array(); } ],
53+
[ function() { return new Int16Array(); } ],
54+
[ function() { return new Int32Array(); } ],
55+
[ function() { return new Float32Array(); } ],
56+
[ function() { return new Float64Array(); } ],
57+
[ function() { return new BigInt64Array(); } ],
58+
[ function() { return new BigUint64Array(); } ],
59+
[ function() { return Object.defineProperty(new Uint8Array(),
6060
Symbol.toStringTag,
61-
{ value: 'foo' }) ],
62-
[ new DataView(new ArrayBuffer()) ],
63-
[ new SharedArrayBuffer() ],
61+
{ value: 'foo' }); } ],
62+
[ function() { return new DataView(new ArrayBuffer()); } ],
63+
[ function() { return new SharedArrayBuffer(); } ],
6464
// [ new Proxy({}, {}), 'isProxy' ],
65-
[ new WebAssembly.Module(wasmBuffer), 'isWebAssemblyCompiledModule' ],
65+
[ function() { return new WebAssembly.Module(wasmBuffer); }, 'isWebAssemblyCompiledModule' ],
6666
]) {
67+
let value;
68+
try {
69+
value = getValue();
70+
} catch (e) {
71+
continue;
72+
}
6773
const method = _method || `is${value.constructor.name}`;
6874
console.log('Testing', method);
6975
assert(method in types, `Missing ${method} for ${inspect(value)}`);

0 commit comments

Comments
 (0)