From 411cf560c930571aebc7979304d34e04564fbb6d Mon Sep 17 00:00:00 2001 From: Andrei Cioromila Date: Sun, 7 May 2017 14:12:30 +0300 Subject: [PATCH 1/3] test: update test for url.parse() to match the exact error through regexp check --- test/parallel/test-url-parse-invalid-input.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 688d48beb6c2b4..356c62fdbbc160 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -13,8 +13,8 @@ const url = require('url'); 0, [], {} -].forEach(function(val) { - assert.throws(function() { url.parse(val); }, TypeError); +].forEach((val) => { + assert.throws(() => { url.parse(val); }, /^TypeError: Parameter "url" must be a string, not undefined|boolean|number|object$/); }); -assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/); +assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/); From 5b86bd5d17a0161f674f123f481653771d9e1b4f Mon Sep 17 00:00:00 2001 From: Andrei Cioromila Date: Sun, 7 May 2017 14:54:29 +0300 Subject: [PATCH 2/3] test: allign the function and regexp vertically to keep lines short --- test/parallel/test-url-parse-invalid-input.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 356c62fdbbc160..4b0daffb3fa278 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -14,7 +14,8 @@ const url = require('url'); [], {} ].forEach((val) => { - assert.throws(() => { url.parse(val); }, /^TypeError: Parameter "url" must be a string, not undefined|boolean|number|object$/); + assert.throws(() => { url.parse(val); }, + /^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object)$/); }); assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/); From ef07ba488431f0675cf480f10e3b18292ddee5cb Mon Sep 17 00:00:00 2001 From: Andrei Cioromila Date: Wed, 10 May 2017 15:57:56 +0300 Subject: [PATCH 3/3] test: add function and symbol validation for url.parse() --- test/parallel/test-url-parse-invalid-input.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 4b0daffb3fa278..a6de25e10c1501 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -12,10 +12,13 @@ const url = require('url'); 0.0, 0, [], - {} + {}, + () => {}, + Symbol('foo') ].forEach((val) => { assert.throws(() => { url.parse(val); }, - /^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object)$/); + /^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object|function|symbol)$/); }); -assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/); +assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, + /^URIError: URI malformed$/);