aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-09-06 18:33:23 +0100
committerGitHub <noreply@github.com>2021-09-07 01:33:23 +0800
commit4b88dfb8d9ea5d5d25649edbce2def4b1df6c553 (patch)
tree28c5b3a4ceb6dcd7890c6ab3ac8d940b01b5e0a6 /test
parentc3aef2361458941a36d217cb3181ade3b777a37e (diff)
downloadtracifyjs-4b88dfb8d9ea5d5d25649edbce2def4b1df6c553.tar.gz
tracifyjs-4b88dfb8d9ea5d5d25649edbce2def4b1df6c553.zip
tweak test & warnings (#5123)
closes #5116 closes #5117 closes #5122
Diffstat (limited to 'test')
-rw-r--r--test/mocha/reduce.js63
1 files changed, 34 insertions, 29 deletions
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js
index 8d7e72a5..abe4e782 100644
--- a/test/mocha/reduce.js
+++ b/test/mocha/reduce.js
@@ -282,35 +282,40 @@ describe("test/reduce.js", function() {
});
if (result.error) throw result.error;
assert.deepEqual(result.warnings, []);
- assert.strictEqual(result.code.replace(/function \(/g, "function("), (semver.satisfies(process.version, "<=0.10") ? [
- "// Can't reproduce test failure",
- "// minify options: {",
- '// "compress": false,',
- '// "mangle": false,',
- '// "output": {',
- '// "beautify": true',
- "// }",
- "// }",
- ] : [
- [
- "try{",
- "null[function(){}]",
- "}catch(e){",
- "console.log(e)",
- "}",
- ].join(""),
- "// output: TypeError: Cannot read property 'function(){}' of null",
- "// ",
- "// minify: TypeError: Cannot read property 'function() {}' of null",
- "// ",
- "// options: {",
- '// "compress": false,',
- '// "mangle": false,',
- '// "output": {',
- '// "beautify": true',
- "// }",
- "// }",
- ]).join("\n"));
+ if (semver.satisfies(process.version, "<=0.10")) {
+ assert.strictEqual(result.code, [
+ "// Can't reproduce test failure",
+ "// minify options: {",
+ '// "compress": false,',
+ '// "mangle": false,',
+ '// "output": {',
+ '// "beautify": true',
+ "// }",
+ "// }",
+ ].join("\n"));
+ } else {
+ var message = result.code.split(/\n/, 3)[1].slice("// output: ".length);
+ assert.strictEqual(result.code, [
+ [
+ "try{",
+ "null[function(){}]",
+ "}catch(e){",
+ "console.log(e)",
+ "}",
+ ].join(""),
+ "// output: " + message,
+ "// ",
+ "// minify: " + message.replace("(){}", "() {}"),
+ "// ",
+ "// options: {",
+ '// "compress": false,',
+ '// "mangle": false,',
+ '// "output": {',
+ '// "beautify": true',
+ "// }",
+ "// }",
+ ].join("\n"));
+ }
});
it("Should maintain block-scope for const/let", function() {
if (semver.satisfies(process.version, "<4")) return;