Skip to content

Commit 4e28243

Browse files
committed
Skip Symbol tests if Symbol is unsupported
1 parent c40e528 commit 4e28243

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

test/parallel/test-assert.js

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ testShortAssertionMessage(Infinity, 'Infinity');
284284
testShortAssertionMessage('a', '"a"');
285285
testShortAssertionMessage('foo', '\'foo\'');
286286
testShortAssertionMessage(0, '0');
287-
testShortAssertionMessage(Symbol(), 'Symbol()');
287+
if (common.symbolSupported) {
288+
testShortAssertionMessage(Symbol(), 'Symbol()');
289+
}
288290
testAssertionMessage([], '[]');
289291
testAssertionMessage(/a/, '/a/');
290292
testAssertionMessage(/abc/gim, '/abc/gim');
@@ -400,7 +402,7 @@ assert.throws(() => {
400402
// `+ '${'A'.repeat(1000)}'\n- ''`
401403
});
402404

403-
{
405+
if (common.symbolSupported) {
404406
// Bad args to AssertionError constructor should throw TypeError.
405407
const args = [1, true, false, '', null, Infinity, Symbol('test'), undefined];
406408
args.forEach((input) => {
@@ -662,15 +664,17 @@ common.expectsError(
662664
}
663665
);
664666

665-
common.expectsError(
666-
() => assert(false, Symbol('foo')),
667-
{
668-
code: 'ERR_ASSERTION',
669-
// type: assert.AssertionError,
670-
generatedMessage: false,
671-
// message: 'Symbol(foo)'
672-
}
673-
);
667+
if (common.symbolSupported) {
668+
common.expectsError(
669+
() => assert(false, Symbol('foo')),
670+
{
671+
code: 'ERR_ASSERTION',
672+
// type: assert.AssertionError,
673+
generatedMessage: false,
674+
// message: 'Symbol(foo)'
675+
}
676+
);
677+
}
674678

675679
// [browserify]
676680
// This test uses internal Node.js functionality so we have to skip it.
@@ -862,20 +866,22 @@ common.expectsError(
862866
}
863867
);
864868

865-
[
866-
1,
867-
false,
868-
Symbol()
869-
].forEach((input) => {
870-
assert.throws(
871-
() => assert.throws(() => {}, input),
872-
{
873-
code: 'ERR_INVALID_ARG_TYPE',
874-
// message: 'The "error" argument must be one of type Object, Error, ' +
875-
// `Function, or RegExp. Received type ${typeof input}`
876-
}
877-
);
878-
});
869+
if (common.symbolSupported) {
870+
[
871+
1,
872+
false,
873+
Symbol()
874+
].forEach((input) => {
875+
assert.throws(
876+
() => assert.throws(() => {}, input),
877+
{
878+
code: 'ERR_INVALID_ARG_TYPE',
879+
// message: 'The "error" argument must be one of type Object, Error, ' +
880+
// `Function, or RegExp. Received type ${typeof input}`
881+
}
882+
);
883+
});
884+
}
879885

880886
{
881887

@@ -1199,10 +1205,12 @@ assert.throws(
11991205
{ code: 'ERR_MISSING_ARGS' }
12001206
);
12011207

1202-
assert.throws(
1203-
() => a.deepStrictEqual(Symbol()),
1204-
{ code: 'ERR_MISSING_ARGS' }
1205-
);
1208+
if (common.symbolSupported) {
1209+
assert.throws(
1210+
() => a.deepStrictEqual(Symbol()),
1211+
{ code: 'ERR_MISSING_ARGS' }
1212+
);
1213+
}
12061214

12071215
if (common.bigIntSupported) {
12081216
assert.throws(

0 commit comments

Comments
 (0)