summaryrefslogtreecommitdiff
path: root/test/parallel/test-util-format.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2018-06-04 14:07:52 -0700
committerRich Trott <rtrott@gmail.com>2018-06-07 16:59:53 -0700
commit5d32c1a8dc758a7c6f028a08789ef8436ed8a053 (patch)
tree54a13ba63b3bc490871e333dfc20fe393b3ba648 /test/parallel/test-util-format.js
parent214ff0a9d5848cca202ea3590fc667a5b0c9fa4e (diff)
downloadandroid-node-v8-5d32c1a8dc758a7c6f028a08789ef8436ed8a053.tar.gz
android-node-v8-5d32c1a8dc758a7c6f028a08789ef8436ed8a053.tar.bz2
android-node-v8-5d32c1a8dc758a7c6f028a08789ef8436ed8a053.zip
test: make url-util-format engine agnostic
test-util-format checks the message of an error that is generated by the JavaScript engine. Error messages that change in the underlying JavaScript engine should not be breaking changes in Node.js and therefore should not cause tests to fail. Remove the message check and replace it with a check of the type of the Error object along with the absence of a `code` property. (If a `code` property were present, it would indicate that the error was coming from Node.js rather than the JavaScript engine.) This also makes this test usable without modification in the ChakraCore fork of Node.js. PR-URL: https://github.com/nodejs/node/pull/21141 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
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');