diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-13 13:15:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-13 21:15:11 +0800 |
commit | 94e8944f677f624d8ab4ae2b8731e87244f9476e (patch) | |
tree | fe98fd1093ee1cb82f69c4cfafa0ac9d80f2e81a /test/mocha | |
parent | 83197ffdb3c9055b5699674e111d2dee390d5560 (diff) | |
download | tracifyjs-94e8944f677f624d8ab4ae2b8731e87244f9476e.tar.gz tracifyjs-94e8944f677f624d8ab4ae2b8731e87244f9476e.zip |
avoid false positive in `--reduce-test` (#4648)
Diffstat (limited to 'test/mocha')
-rw-r--r-- | test/mocha/reduce.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js index e3653314..587aa7be 100644 --- a/test/mocha/reduce.js +++ b/test/mocha/reduce.js @@ -294,6 +294,39 @@ describe("test/reduce.js", function() { "// }", ]).join("\n")); }); + it("Should maintain block-scope for const & let", function() { + if (semver.satisfies(process.version, "<4")) return; + var code = [ + '"use strict";', + "", + "L: for (let a = (1 - .8).toString(); ;) {", + " if (!console.log(a)) {", + " break L;", + " }", + "}", + ].join("\n"); + var result = reduce_test(code, { + compress: { + unsafe_math: true, + }, + mangle: false, + }); + if (result.error) throw result.error; + assert.strictEqual(result.code, [ + "// (beautified)", + code, + "// output: 0.19999999999999996", + "// ", + "// minify: 0.2", + "// ", + "// options: {", + '// "compress": {', + '// "unsafe_math": true', + '// },', + '// "mangle": false', + "// }", + ].join("\n")); + }); it("Should handle corner cases when intermediate case differs only in Error.message", function() { if (semver.satisfies(process.version, "<=0.10")) return; var result = reduce_test(read("test/input/reduce/diff_error.js"), { |