Skip to content

Commit f0d5bf5

Browse files
committed
Only run fake typed array tests if Symbol.toStringTag is supported
1 parent 2a98094 commit f0d5bf5

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

test/node/types.js

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -134,31 +134,35 @@ console.log('Testing', 'isBoxedPrimitive');
134134
assert(types.isBoxedPrimitive(entry));
135135
});
136136

137-
[
138-
'Uint8Array',
139-
'Uint8ClampedArray',
140-
'Uint16Array',
141-
'Uint32Array',
142-
'Int8Array',
143-
'Int16Array',
144-
'Int32Array',
145-
'Float32Array',
146-
'Float64Array',
147-
'BigInt64Array',
148-
'BigUint64Array'
149-
].forEach(function (typedArray) {
150-
var method = 'is' + typedArray;
151-
var constructor = 'new ' + typedArray;
152-
var array;
153-
try {
154-
array = vm.runInNewContext(constructor);
155-
} catch (e) {
156-
return;
157-
}
158-
console.log('Testing fake typed arrays', method);
159-
assert(!types[method](_defineProperty({}, Symbol.toStringTag, typedArray)));
160-
assert(types[method](array));
161-
});
137+
var SymbolSupported = typeof Symbol !== 'undefined';
138+
var SymbolToStringTagSupported = SymbolSupported && typeof Symbol.toStringTag !== 'undefined';
139+
if (SymbolToStringTagSupported) {
140+
[
141+
'Uint8Array',
142+
'Uint8ClampedArray',
143+
'Uint16Array',
144+
'Uint32Array',
145+
'Int8Array',
146+
'Int16Array',
147+
'Int32Array',
148+
'Float32Array',
149+
'Float64Array',
150+
'BigInt64Array',
151+
'BigUint64Array'
152+
].forEach(function (typedArray) {
153+
var method = 'is' + typedArray;
154+
var constructor = 'new ' + typedArray;
155+
var array;
156+
try {
157+
array = vm.runInNewContext(constructor);
158+
} catch (e) {
159+
return;
160+
}
161+
console.log('Testing fake typed arrays', method);
162+
assert(!types[method](_defineProperty({}, Symbol.toStringTag, typedArray)));
163+
assert(types[method](array));
164+
});
165+
}
162166

163167
{
164168
var primitive = function primitive() { return true; };

0 commit comments

Comments
 (0)