diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-04-25 15:15:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 15:15:50 +0800 |
commit | e5436ca5665378d67bb228704736d1fe5fa7b6ee (patch) | |
tree | 6443f5770a5b67676a26e94ad913f705d6578680 /test | |
parent | cfde686eab4ddaf0fc38b638462c3613b18c6ad4 (diff) | |
download | tracifyjs-e5436ca5665378d67bb228704736d1fe5fa7b6ee.tar.gz tracifyjs-e5436ca5665378d67bb228704736d1fe5fa7b6ee.zip |
enhance `side_effects` (#3384)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/conditionals.js | 36 | ||||
-rw-r--r-- | test/compress/sequences.js | 36 |
2 files changed, 72 insertions, 0 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index a208165f..594d956d 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -1435,3 +1435,39 @@ iife_condition: { } expect_stdout: "PASS" } + +angularjs_chain: { + options = { + conditionals: true, + passes: 2, + side_effects: true, + } + input: { + function nonComputedMember(left, right, context, create) { + var lhs = left(); + if (create && create !== 1) { + if (lhs && lhs[right] == null) { + lhs[right] = {}; + } + } + var value = lhs != null ? lhs[right] : undefined; + if (context) { + return { context: lhs, name: right, value: value }; + } else { + return value; + } + } + } + expect: { + function nonComputedMember(left, right, context, create) { + var lhs = left(); + create && 1 !== create && lhs && null == lhs[right] && (lhs[right] = {}); + var value = null != lhs ? lhs[right] : void 0; + return context ? { + context: lhs, + name: right, + value: value + } : value; + } + } +} diff --git a/test/compress/sequences.js b/test/compress/sequences.js index 29cede40..47dd4c4f 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -964,3 +964,39 @@ missing_link: { console.log(a); } } + +angularjs_chain: { + options = { + conditionals: true, + sequences: true, + side_effects: true, + } + input: { + function nonComputedMember(left, right, context, create) { + var lhs = left(); + if (create && create !== 1) { + if (lhs && lhs[right] == null) { + lhs[right] = {}; + } + } + var value = lhs != null ? lhs[right] : undefined; + if (context) { + return { context: lhs, name: right, value: value }; + } else { + return value; + } + } + } + expect: { + function nonComputedMember(left, right, context, create) { + var lhs = left(); + create && 1 !== create && lhs && null == lhs[right] && (lhs[right] = {}); + var value = null != lhs ? lhs[right] : void 0; + return context ? { + context: lhs, + name: right, + value: value + } : value; + } + } +} |