Skip to content

Commit c2fd49c

Browse files
committed
test: fix common.mustNotCall error message
When using `util.inspect` as a callback, the array index (second argument) is picked up as the `showHidden` param, and the argument array (third argument) as the `depth` param. This fails with a seemingly unrelated error message when the argument array contains a `Symbol`-related property.
1 parent 68fb0bf commit c2fd49c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

test/common/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ function mustNotCall(msg) {
512512
const callSite = getCallSite(mustNotCall);
513513
return function mustNotCall(...args) {
514514
const argsInfo = args.length > 0 ?
515-
`\ncalled with arguments: ${args.map(util.inspect).join(', ')}` : '';
515+
`\ncalled with arguments: ${args.map((arg) => util.inspect(arg)).join(', ')}` : '';
516516
assert.fail(
517517
`${msg || 'function should not have been called'} at ${callSite}` +
518518
argsInfo);

test/parallel/test-common-must-not-call.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,8 @@ try {
3939
} catch (e) {
4040
validate2(e);
4141
}
42+
43+
assert.throws(
44+
() => new Proxy({ prop: Symbol() }, { get: common.mustNotCall() }).prop,
45+
{ code: 'ERR_ASSERTION' }
46+
);

0 commit comments

Comments
 (0)