diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-05-10 15:23:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-10 22:23:09 +0800 |
commit | 63adfb1590886b9b03827805e1226bfe235e5868 (patch) | |
tree | 47009d844dfc6f78bbdff2871a99eb6d3df25d76 /test | |
parent | f9806b43c33400b73e19d5bd216a2b5653dfcfbd (diff) | |
download | tracifyjs-63adfb1590886b9b03827805e1226bfe235e5868.tar.gz tracifyjs-63adfb1590886b9b03827805e1226bfe235e5868.zip |
fix corner case in `hoist_props` (#3872)
fixes #3871
Diffstat (limited to 'test')
-rw-r--r-- | test/compress.js | 3 | ||||
-rw-r--r-- | test/compress/hoist_props.js | 32 |
2 files changed, 34 insertions, 1 deletions
diff --git a/test/compress.js b/test/compress.js index 8a6dd228..2fe02806 100644 --- a/test/compress.js +++ b/test/compress.js @@ -14,7 +14,6 @@ var file = process.argv[2]; var dir = path.resolve(path.dirname(module.filename), "compress"); if (file) { var minify_options = require("./ufuzz/options.json").map(JSON.stringify); - U.AST_Node.enable_validation(); log("--- {file}", { file: file }); var tests = parse_test(path.resolve(dir, file)); process.exit(Object.keys(tests).filter(function(name) { @@ -189,6 +188,7 @@ function reminify(orig_options, input_code, input_formatted, stdout) { } }); var options_formatted = JSON.stringify(options, null, 4); + options.validate = true; var result = U.minify(input_code, options); if (result.error) { log([ @@ -252,6 +252,7 @@ function run_code(code, toplevel) { function test_case(test) { log(" Running test [{name}]", { name: test.name }); + U.AST_Node.enable_validation(); var output_options = test.beautify || {}; var expect; if (test.expect) { diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js index cc7ef020..a73df1f5 100644 --- a/test/compress/hoist_props.js +++ b/test/compress/hoist_props.js @@ -940,3 +940,35 @@ issue_3868: { } expect_stdout: "PASS" } + +issue_3871: { + options = { + hoist_props: true, + reduce_vars: true, + } + input: { + console.log(function() { + do { + var b = { + get null() { + c; + } + }; + } while (!b); + return "PASS"; + }()); + } + expect: { + console.log(function() { + do { + var b = { + get null() { + c; + } + }; + } while (!b); + return "PASS"; + }()); + } + expect_stdout: "PASS" +} |