aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-01-10 04:28:43 +0800
committerGitHub <noreply@github.com>2020-01-10 04:28:43 +0800
commit46caaa82ba955eba112fb60279129aa2f5675440 (patch)
treee1a0827c01cf31d81133467b4d8f2787a0557011 /test
parent5d258259a492d1e04c952024d3d5662c65bb0ce6 (diff)
downloadtracifyjs-46caaa82ba955eba112fb60279129aa2f5675440.tar.gz
tracifyjs-46caaa82ba955eba112fb60279129aa2f5675440.zip
enhance `collapse_vars` (#3680)
closes #3679
Diffstat (limited to 'test')
-rw-r--r--test/compress/functions.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 3b9def32..c8bced52 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -3700,3 +3700,88 @@ pr_3595_4: {
}
expect_stdout: "PASS"
}
+
+issue_3679_1: {
+ options = {
+ collapse_vars: true,
+ inline: true,
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ var f = function() {};
+ f.g = function() {
+ console.log("PASS");
+ };
+ f.g();
+ })();
+ }
+ expect: {
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}
+
+issue_3679_2: {
+ options = {
+ collapse_vars: true,
+ inline: true,
+ passes: 2,
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ "use strict";
+ var f = function() {};
+ f.g = function() {
+ console.log("PASS");
+ };
+ f.g();
+ })();
+ }
+ expect: {
+ (function() {
+ "use strict";
+ console.log("PASS");
+ })();
+ }
+ expect_stdout: "PASS"
+}
+
+issue_3679_3: {
+ options = {
+ collapse_vars: true,
+ inline: true,
+ functions: true,
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ var f = function() {};
+ f.p = "PASS";
+ f.g = function() {
+ console.log(f.p);
+ };
+ f.g();
+ })();
+ }
+ expect: {
+ (function() {
+ function f() {};
+ f.p = "PASS";
+ (f.g = function() {
+ console.log(f.p);
+ })();
+ })();
+ }
+ expect_stdout: "PASS"
+}