Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions test/parallel/test-util-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,21 @@ assert.strictEqual(util.format(symbol), 'Symbol(foo)');
assert.strictEqual(util.format('foo', symbol), 'foo Symbol(foo)');
assert.strictEqual(util.format('%s', symbol), 'Symbol(foo)');
assert.strictEqual(util.format('%j', symbol), 'undefined');
assert.throws(function() {
util.format('%d', symbol);
}, /^TypeError: Cannot convert a Symbol value to a number$/);
assert.throws(
() => { util.format('%d', symbol); },
(e) => {
// The error should be a TypeError.
if (!(e instanceof TypeError))
return false;

// The error should be from the JS engine and not from Node.js.
// JS engine errors do not have the `code` property.
if (e.code !== undefined)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These few lines can just be return e.code === undefined;

return false;

return true;
}
);

// Number format specifier
assert.strictEqual(util.format('%d'), '%d');
Expand Down