aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-12-31 23:39:24 +0800
committerGitHub <noreply@github.com>2019-12-31 23:39:24 +0800
commitd83d3d741ac8ea41a3776c9ca8d60e752180d420 (patch)
tree8fcc54acf1987c051dc51c186a0f0f77fab1966a /test/compress
parent99ac73a635d641935331e71d519c24297b50dd32 (diff)
downloadtracifyjs-d83d3d741ac8ea41a3776c9ca8d60e752180d420.tar.gz
tracifyjs-d83d3d741ac8ea41a3776c9ca8d60e752180d420.zip
enhance `unused` (#3662)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/drop-unused.js81
-rw-r--r--test/compress/functions.js7
2 files changed, 82 insertions, 6 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index b9eea0ed..2e131f7d 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -2254,3 +2254,84 @@ issue_3598: {
}
expect_stdout: "PASS"
}
+
+self_assign: {
+ options = {
+ passes: 2,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ function d(a) {
+ a = a;
+ }
+ function e(a, b) {
+ a = b;
+ b = a;
+ }
+ function f(a, b, c) {
+ a = b;
+ b = c;
+ c = a;
+ }
+ function g(a, b, c) {
+ a = a * b + c;
+ }
+ }
+ expect: {
+ function d(a) {}
+ function e(a, b) {}
+ function f(a, b, c) {}
+ function g(a, b, c) {}
+ }
+}
+
+function_argument_reference: {
+ options = {
+ keep_fargs: false,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var a = 1, b = 42;
+ function f(a) {
+ b <<= a;
+ }
+ f();
+ console.log(a, b);
+ }
+ expect: {
+ var a = 1, b = 42;
+ function f(a) {
+ b <<= a;
+ }
+ f();
+ console.log(a, b);
+ }
+ expect_stdout: "1 42"
+}
+
+function_parameter_ie8: {
+ options = {
+ ie8: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ var a;
+ function f() {
+ console.log("PASS");
+ }
+ f(a = 1 + a);
+ })();
+ }
+ expect: {
+ (function() {
+ (function f() {
+ console.log("PASS");
+ })(0);
+ })();
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 30569847..3b9def32 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -266,12 +266,7 @@ issue_2084: {
}
expect: {
var c = 0;
- !function() {
- var c;
- c = 1 + (c = -1),
- c = 1 + (c = 0),
- 0 !== 23..toString() && (c = 1 + c);
- }(),
+ 23..toString(),
console.log(c);
}
expect_stdout: "0"