aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/reduce.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-02-29 17:33:48 +0000
committerGitHub <noreply@github.com>2020-02-29 17:33:48 +0000
commitc8d60d698310aa263c4f6684b18680af07e07c87 (patch)
treeb0b78e274c5928487b656de925b1e3f2eeadfae5 /test/mocha/reduce.js
parent6092bf23de6608ad225cad61b934570604a5d3a4 (diff)
downloadtracifyjs-c8d60d698310aa263c4f6684b18680af07e07c87.tar.gz
tracifyjs-c8d60d698310aa263c4f6684b18680af07e07c87.zip
detect `toplevel` option properly (#3735)
fixes #3730
Diffstat (limited to 'test/mocha/reduce.js')
-rw-r--r--test/mocha/reduce.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js
index c7d5a7de..7eacbd7f 100644
--- a/test/mocha/reduce.js
+++ b/test/mocha/reduce.js
@@ -46,6 +46,44 @@ describe("test/reduce.js", function() {
"// }",
].join("\n"));
});
+ it("Should handle test cases with --compress toplevel", function() {
+ var result = reduce_test([
+ "var NaN = 42;",
+ "console.log(NaN);",
+ ].join("\n"), {
+ compress: {
+ toplevel: true,
+ },
+ });
+ if (result.error) throw result.error;
+ assert.strictEqual(result.code, [
+ "// Can't reproduce test failure with minify options provided:",
+ "// {",
+ '// "compress": {',
+ '// "toplevel": true',
+ "// }",
+ "// }",
+ ].join("\n"));
+ });
+ it("Should handle test cases with --mangle toplevel", function() {
+ var result = reduce_test([
+ "var undefined = 42;",
+ "console.log(undefined);",
+ ].join("\n"), {
+ mangle: {
+ toplevel: true,
+ },
+ });
+ if (result.error) throw result.error;
+ assert.strictEqual(result.code, [
+ "// Can't reproduce test failure with minify options provided:",
+ "// {",
+ '// "mangle": {',
+ '// "toplevel": true',
+ "// }",
+ "// }",
+ ].join("\n"));
+ });
it("Should handle test result of NaN", function() {
var result = reduce_test("throw 0 / 0;");
if (result.error) throw result.error;