diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-12-28 20:26:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-28 20:26:15 +0000 |
commit | d9cd3d33c8f2b769da922d355373d466f8b30704 (patch) | |
tree | 095c4497bfeaacb24437c950e685df180645687c /test | |
parent | 22b47cdd639263313317b77a3166afad767a7ef6 (diff) | |
download | tracifyjs-d9cd3d33c8f2b769da922d355373d466f8b30704.tar.gz tracifyjs-d9cd3d33c8f2b769da922d355373d466f8b30704.zip |
enhance `evaluate` (#3649)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/hoist_props.js | 2 | ||||
-rw-r--r-- | test/compress/numbers.js | 82 |
2 files changed, 81 insertions, 3 deletions
diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js index 0d8e771a..c647ccc1 100644 --- a/test/compress/hoist_props.js +++ b/test/compress/hoist_props.js @@ -664,7 +664,7 @@ issue_2519: { } expect: { function testFunc() { - return 1 * ((6 + 5) / 2); + return +((6 + 5) / 2); } console.log(testFunc()); } diff --git a/test/compress/numbers.js b/test/compress/numbers.js index 673ce23a..c432a435 100644 --- a/test/compress/numbers.js +++ b/test/compress/numbers.js @@ -91,7 +91,7 @@ evaluate_1: { expect: { console.log( x + 1 + 2, - 1 * x * 2, + 2 * x, +x + 1 + 2, 1 + x + 2 + 3, 3 | x, @@ -173,7 +173,7 @@ evaluate_2: { var x = "42", y = null; [ x + 1 + 2, - 1 * x * 2, + 2 * x, +x + 1 + 2, 1 + x + 2 + 3, 3 | x, @@ -979,3 +979,81 @@ unsafe_math_swap_constant: { } expect_stdout: "6 6 7 6 6 8 9 10" } + +identity_1: { + options = { + evaluate: true, + } + input: { + 0 + a; + a + 0; + 0 - a; + a - 0; + 1 * a; + a * 1; + 1 / a; + a / 1; + } + expect: { + 0 + a; + a + 0; + -a; + +a; + +a; + +a; + 1 / a; + +a; + } +} + +identity_2: { + options = { + evaluate: true, + } + input: { + 0 + !a; + !a + 0; + 0 - !a; + !a - 0; + 1 * !a; + !a * 1; + 1 / !a; + !a / 1; + } + expect: { + +!a; + +!a; + -!a; + +!a; + +!a; + +!a; + 1 / !a; + +!a; + } +} + +identity_3: { + options = { + evaluate: true, + } + input: { + 0 + --a; + --a + 0; + 0 - --a; + --a - 0; + 1 * --a; + --a * 1; + 1 / --a; + --a / 1; + } + expect: { + --a; + --a; + - --a; + --a; + --a; + --a; + 1 / --a; + --a; + } +} |