From cb5d9745bab0fe532e0405b5bfe7a9a830a5d50c Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 16 Dec 2018 10:04:44 +0100 Subject: [PATCH 1/3] make version check work with prerelease versions semver.satisfies does not match a prerelease version against a non-prerelease one, e.g. 12.0.0-pre does not match >= 10. Use a regex match to workaround this fact. --- tools/colorless-console.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/colorless-console.js b/tools/colorless-console.js index f64e208e1..b65bb6275 100644 --- a/tools/colorless-console.js +++ b/tools/colorless-console.js @@ -1,8 +1,6 @@ "use strict" -var semver = require("semver"); - -if (semver.satisfies(process.version, ">=10")) { +if (Number((/([0-9]+)\./.exec(process.version) || [])[1]) >= 10) { var Console = require("console").Console; global.console = new Console({ stdout: process.stdout, From 00de155552985c77951292fb542ad4afa20338e9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 16 Dec 2018 10:11:20 +0100 Subject: [PATCH 2/3] make tests compatible with Node.js 12 In Node.js 12, the formatting of console arguments will change slightly. Previously, a string other than the first argument was formatted using single quotes if the first argument was non-string. Now, quotes are never added regardless of position of a string argument. To make test compatible in all Node.js versions, I work around by ensuring the first argument to console.log is a string which prevents the quotes from being added on older versions of Node.js. Ref: https://github.com/nodejs/node/pull/23162 --- test/compress/evaluate.js | 12 ++++++------ test/compress/reduce_vars.js | 6 +++--- test/compress/string-literal.js | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index b1f30f3aa..d23d57397 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -1406,12 +1406,12 @@ self_comparison_1: { } input: { var o = { n: NaN }; - console.log(o.n == o.n, o.n === o.n, o.n != o.n, o.n !== o.n, typeof o.n); + console.log(typeof o.n, o.n == o.n, o.n === o.n, o.n != o.n, o.n !== o.n); } expect: { - console.log(false, false, true, true, "number"); + console.log("number", false, false, true, true); } - expect_stdout: "false false true true 'number'" + expect_stdout: "number false false true true" } self_comparison_2: { @@ -1426,12 +1426,12 @@ self_comparison_2: { } input: { var o = { n: NaN }; - console.log(o.n == o.n, o.n === o.n, o.n != o.n, o.n !== o.n, typeof o.n); + console.log(typeof o.n, o.n == o.n, o.n === o.n, o.n != o.n, o.n !== o.n); } expect: { - console.log(false, false, true, true, "number"); + console.log("number", false, false, true, true); } - expect_stdout: "false false true true 'number'" + expect_stdout: "number false false true true" } issue_2535_1: { diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index ac11ad8c1..c1c038d25 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -2724,7 +2724,7 @@ issue_1814_2: { !function() { var b = a + 1; !function(a) { - console.log(a++, b); + console.log(b, a++); }(0); }(); } @@ -2732,11 +2732,11 @@ issue_1814_2: { const a = "32"; !function() { !function(a) { - console.log(a++, "321"); + console.log("321", a++); }(0); }(); } - expect_stdout: "0 '321'" + expect_stdout: "321 0" } try_abort: { diff --git a/test/compress/string-literal.js b/test/compress/string-literal.js index 27cd873da..4f4e2026c 100644 --- a/test/compress/string-literal.js +++ b/test/compress/string-literal.js @@ -15,14 +15,14 @@ issue_1929: { return s.split(/[\\/]/); } var r = f("A/B\\C\\D/E\\F"); - console.log(r.length, r[5], r[4], r[3], r[2], r[1], r[0]); + console.log(r[5], r[4], r[3], r[2], r[1], r[0], r.length); } expect: { function f(s) { return s.split(/[\\/]/); } var r = f("A/B\\C\\D/E\\F"); - console.log(r.length, r[5], r[4], r[3], r[2], r[1], r[0]); + console.log(r[5], r[4], r[3], r[2], r[1], r[0], r.length); } - expect_stdout: "6 'F' 'E' 'D' 'C' 'B' 'A'" + expect_stdout: "F E D C B A 6" } From 08ca958cdf9e56ef18d98fbf3fd17c06ee1eebea Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 16 Dec 2018 20:27:15 +0100 Subject: [PATCH 3/3] restart travis