diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-10-26 01:16:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-26 01:16:12 +0800 |
commit | ee082ace1b69bff228ff43065333b8703c0505dc (patch) | |
tree | 60f980684c2895b70177b6e8c5f080e21e2dc50b /test/compress | |
parent | ae67a4985073dcdaa2788c86e576202923514e0d (diff) | |
download | tracifyjs-ee082ace1b69bff228ff43065333b8703c0505dc.tar.gz tracifyjs-ee082ace1b69bff228ff43065333b8703c0505dc.zip |
compress self comparisons (#2398)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/comparing.js | 39 | ||||
-rw-r--r-- | test/compress/evaluate.js | 37 |
2 files changed, 75 insertions, 1 deletions
diff --git a/test/compress/comparing.js b/test/compress/comparing.js index c51fac31..11804cbb 100644 --- a/test/compress/comparing.js +++ b/test/compress/comparing.js @@ -73,4 +73,41 @@ dont_change_in_or_instanceof_expressions: { 1 instanceof 1; null instanceof null; } -}
\ No newline at end of file +} + +self_comparison_1: { + options = { + comparisons: true, + } + input: { + a === a; + a !== b; + b.c === a.c; + b.c !== b.c; + } + expect: { + a == a; + a !== b; + b.c === a.c; + b.c != b.c; + } +} + +self_comparison_2: { + options = { + comparisons: true, + reduce_vars: true, + toplevel: true, + } + input: { + function f() {} + var o = {}; + console.log(f != f, o === o); + } + expect: { + function f() {} + var o = {}; + console.log(false, true); + } + expect_stdout: "false true" +} diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index fe9464bc..dc8ceb62 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -1195,3 +1195,40 @@ issue_2231_2: { } expect_stdout: true } + +self_comparison_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + unused: true, + } + input: { + var o = { n: NaN }; + console.log(o.n == o.n, o.n === o.n, o.n != o.n, o.n !== o.n, typeof o.n); + } + expect: { + console.log(false, false, true, true, "number"); + } + expect_stdout: "false false true true 'number'" +} + +self_comparison_2: { + options = { + evaluate: true, + hoist_props: true, + passes: 2, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var o = { n: NaN }; + console.log(o.n == o.n, o.n === o.n, o.n != o.n, o.n !== o.n, typeof o.n); + } + expect: { + console.log(false, false, true, true, "number"); + } + expect_stdout: "false false true true 'number'" +} |