test: make url-util-format engine agnostic · nodejs/node@9c3a7bf
@@ -44,9 +44,18 @@ assert.strictEqual(util.format(symbol), 'Symbol(foo)');
4444assert.strictEqual(util.format('foo', symbol), 'foo Symbol(foo)');
4545assert.strictEqual(util.format('%s', symbol), 'Symbol(foo)');
4646assert.strictEqual(util.format('%j', symbol), 'undefined');
47-assert.throws(function() {
48-util.format('%d', symbol);
49-}, /^TypeError: Cannot convert a Symbol value to a number$/);
47+assert.throws(
48+() => { util.format('%d', symbol); },
49+(e) => {
50+// The error should be a TypeError.
51+if (!(e instanceof TypeError))
52+return false;
53+54+// The error should be from the JS engine and not from Node.js.
55+// JS engine errors do not have the `code` property.
56+return e.code === undefined;
57+}
58+);
50595160// Number format specifier
5261assert.strictEqual(util.format('%d'), '%d');