aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/reduce.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-24 18:30:37 +0100
committerGitHub <noreply@github.com>2020-04-25 01:30:37 +0800
commit44d6912a55fecc63ab4f0a8eb28653268556851a (patch)
tree90e53bf737bd2f8e40063b4cea67ff8a315a141d /test/mocha/reduce.js
parent3a4497a1c3db3a2069d6a5a0d1d8a8295c3ef568 (diff)
downloadtracifyjs-44d6912a55fecc63ab4f0a8eb28653268556851a.tar.gz
tracifyjs-44d6912a55fecc63ab4f0a8eb28653268556851a.zip
improve `--reduce-test` on `Error.message` (#3816)
closes #3815
Diffstat (limited to 'test/mocha/reduce.js')
-rw-r--r--test/mocha/reduce.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js
index a6c8a752..779dd99f 100644
--- a/test/mocha/reduce.js
+++ b/test/mocha/reduce.js
@@ -246,4 +246,52 @@ describe("test/reduce.js", function() {
"// }",
].join("\n"));
});
+ it("Should reduce test case which differs only in Error.message", function() {
+ var code = [
+ "var a=0;",
+ "try{",
+ "null[function(){}]",
+ "}catch(e){",
+ "for(var i in e.toString())a++",
+ "}",
+ "console.log(a);",
+ ].join("");
+ var result = reduce_test(code, {
+ compress: false,
+ mangle: false,
+ output: {
+ beautify: true,
+ },
+ });
+ if (result.error) throw result.error;
+ 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"));
+ });
});