aboutsummaryrefslogtreecommitdiff
path: root/test/compress/drop-unused.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-07-14 00:39:34 +0800
committerGitHub <noreply@github.com>2017-07-14 00:39:34 +0800
commit5229cb2b1b345a4cedbdeacb02f114033f4c69b7 (patch)
treecc667492dc416f08c182ee0b1252835408285d51 /test/compress/drop-unused.js
parent458e3e15f0f315dcd4a99b02bed0fb740ffdfc17 (diff)
downloadtracifyjs-5229cb2b1b345a4cedbdeacb02f114033f4c69b7.tar.gz
tracifyjs-5229cb2b1b345a4cedbdeacb02f114033f4c69b7.zip
drop `unused` compound assignments (#2230)
fixes #2226
Diffstat (limited to 'test/compress/drop-unused.js')
-rw-r--r--test/compress/drop-unused.js90
1 files changed, 88 insertions, 2 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index a44107ae..34d47d0d 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1090,6 +1090,7 @@ var_catch_toplevel: {
a--;
try {
a++;
+ x();
} catch(a) {
if (a) var a;
var a = 10;
@@ -1099,9 +1100,8 @@ var_catch_toplevel: {
}
expect: {
!function() {
- a--;
try {
- a++;
+ x();
} catch(a) {
var a;
}
@@ -1153,3 +1153,89 @@ issue_2105: {
}
expect_stdout: "PASS"
}
+
+issue_2226_1: {
+ options = {
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ function f1() {
+ var a = b;
+ a += c;
+ }
+ function f2(a) {
+ a <<= b;
+ }
+ function f3(a) {
+ --a;
+ }
+ function f4() {
+ var a = b;
+ return a *= c;
+ }
+ function f5(a) {
+ x(a /= b);
+ }
+ }
+ expect: {
+ function f1() {
+ b;
+ c;
+ }
+ function f2(a) {
+ b;
+ }
+ function f3(a) {
+ 0;
+ }
+ function f4() {
+ var a = b;
+ return a *= c;
+ }
+ function f5(a) {
+ x(a /= b);
+ }
+ }
+}
+
+issue_2226_2: {
+ options = {
+ cascade: true,
+ sequences: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ console.log(function(a, b) {
+ a += b;
+ return a;
+ }(1, 2));
+ }
+ expect: {
+ console.log(function(a, b) {
+ return a += b;
+ }(1, 2));
+ }
+ expect_stdout: "3"
+}
+
+issue_2226_3: {
+ options = {
+ collapse_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ console.log(function(a, b) {
+ a += b;
+ return a;
+ }(1, 2));
+ }
+ expect: {
+ console.log(function(a, b) {
+ return a += 2;
+ }(1));
+ }
+ expect_stdout: "3"
+}