diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-10-17 18:33:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-17 18:33:03 +0800 |
commit | f2b9c11e2a0ab3597f798cf85770e24733609b1f (patch) | |
tree | 78118e2eaf5efa16279cf1b013e88925575d27d8 /test/compress | |
parent | fe647b083e0def2bf6445534c7017baed09541a9 (diff) | |
download | tracifyjs-f2b9c11e2a0ab3597f798cf85770e24733609b1f.tar.gz tracifyjs-f2b9c11e2a0ab3597f798cf85770e24733609b1f.zip |
fix `AST_PropAccess` in `collapse_vars` (#2370)
fixes #2364
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index ec94e9f0..baa18ea1 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -2601,7 +2601,7 @@ prop_side_effects_2: { ] } -issue_2364: { +issue_2365: { options = { collapse_vars: true, pure_getters: true, @@ -2652,3 +2652,62 @@ issue_2364: { "1", ] } + +issue_2364_1: { + options = { + collapse_vars: true, + pure_getters: true, + } + input: { + function inc(obj) { + return obj.count++; + } + function foo() { + var first = arguments[0]; + var result = inc(first); + return foo.amount = first.count, result; + } + var data = { + count: 0, + }; + var answer = foo(data); + console.log(foo.amount, answer); + } + expect: { + function inc(obj) { + return obj.count++; + } + function foo() { + var first = arguments[0]; + var result = inc(first); + return foo.amount = first.count, result; + } + var data = { + count: 0 + }; + var answer = foo(data); + console.log(foo.amount, answer); + } + expect_stdout: "1 0" +} + +issue_2364_2: { + options = { + collapse_vars: true, + pure_getters: true, + } + input: { + function callValidate() { + var validate = compilation.validate; + var result = validate.apply(null, arguments); + return callValidate.errors = validate.errors, result; + } + } + expect: { + function callValidate() { + var validate = compilation.validate; + var result = validate.apply(null, arguments); + return callValidate.errors = validate.errors, result; + } + } +} |