aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/reduce.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocha/reduce.js')
-rw-r--r--test/mocha/reduce.js32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js
index f55c278d..c7d5a7de 100644
--- a/test/mocha/reduce.js
+++ b/test/mocha/reduce.js
@@ -2,6 +2,7 @@ var assert = require("assert");
var exec = require("child_process").exec;
var fs = require("fs");
var reduce_test = require("../reduce");
+var semver = require("semver");
function read(path) {
return fs.readFileSync(path, "utf8");
@@ -43,7 +44,6 @@ describe("test/reduce.js", function() {
"// {",
'// "toplevel": true',
"// }",
- "",
].join("\n"));
});
it("Should handle test result of NaN", function() {
@@ -55,7 +55,6 @@ describe("test/reduce.js", function() {
'// "compress": {},',
'// "mangle": false',
"// }",
- "",
].join("\n"));
});
it("Should print correct output for irreducible test case", function() {
@@ -136,4 +135,33 @@ describe("test/reduce.js", function() {
"// }",
].join("\n"));
});
+ it("Should reduce infinite loops with reasonable performance", function() {
+ if (semver.satisfies(process.version, "0.10")) return;
+ this.timeout(120000);
+ var code = [
+ "var a = 9007199254740992, b = 1;",
+ "",
+ "while (a++ + (1 - b) < a) {",
+ " 0;",
+ "}",
+ ].join("\n");
+ var result = reduce_test(code, {
+ compress: {
+ unsafe_math: true,
+ },
+ mangle: false,
+ });
+ if (result.error) throw result.error;
+ assert.strictEqual(result.code.replace(/ timed out after [0-9]+ms/, " timed out."), [
+ code,
+ "// output: ",
+ "// minify: Error: Script execution timed out.",
+ "// options: {",
+ '// "compress": {',
+ '// "unsafe_math": true',
+ "// },",
+ '// "mangle": false',
+ "// }",
+ ].join("\n"));
+ });
});
d>Pierre Neidhardt 2022-07-03gnu: abcl: Fix loading of cl-* packages....Pierre Neidhardt 2022-06-25gnu: Add java-commons-text....Artyom V. Poptsov 2022-06-18gnu: Add java-asm-commons....Artyom V. Poptsov 2022-06-13gnu: java-commons-lang3: Update to 3.12.0...Artyom V. Poptsov 2022-06-12gnu: java-plexus-component-metadata: Fix package....Julien Lepiller 2022-06-08gnu: java-plexus-component-metadata: Fix package....Julien Lepiller 2022-05-29gnu: openjdk: Update to 17.0.3....Danny Milosavljevic