aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-util-format.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-util-format.js')
-rw-r--r--test/parallel/test-util-format.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js
index f99f85b78c..a8adf93671 100644
--- a/test/parallel/test-util-format.js
+++ b/test/parallel/test-util-format.js
@@ -44,9 +44,18 @@ 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.
+ return e.code === undefined;
+ }
+);
// Number format specifier
assert.strictEqual(util.format('%d'), '%d');