aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-19 22:19:33 +0800
committerGitHub <noreply@github.com>2017-12-19 22:19:33 +0800
commit2273655c17b41ab276172afecd652a297c550c00 (patch)
tree8eb6f69c9ba928bff8b7c27e1cb7ba7779ec68dd /test
parent01057cf76d799edc5c7dd45d42a2e7bf44589948 (diff)
downloadtracifyjs-2273655c17b41ab276172afecd652a297c550c00.tar.gz
tracifyjs-2273655c17b41ab276172afecd652a297c550c00.zip
fix `inline` after single-use `reduce_vars` (#2623)
Diffstat (limited to 'test')
-rw-r--r--test/compress/functions.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 41dfc6a9..bd65a11d 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1101,3 +1101,74 @@ issue_2616: {
}
expect_stdout: "PASS"
}
+
+issue_2620_1: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var c = "FAIL";
+ (function() {
+ function f(a) {
+ var b = function g(a) {
+ a && a();
+ }();
+ if (a) {
+ var d = c = "PASS";
+ }
+ }
+ f(1);
+ })();
+ console.log(c);
+ }
+ expect: {
+ var c = "FAIL";
+ (function() {
+ (function(a) {
+ if (function(a) {
+ a && a();
+ }(), a) c = "PASS";
+ })(1);
+ })(),
+ console.log(c);
+ }
+ expect_stdout: "PASS"
+}
+
+issue_2620_2: {
+ options = {
+ conditionals: true,
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var c = "FAIL";
+ (function() {
+ function f(a) {
+ var b = function g(a) {
+ a && a();
+ }();
+ if (a) {
+ var d = c = "PASS";
+ }
+ }
+ f(1);
+ })();
+ console.log(c);
+ }
+ expect: {
+ var c = "FAIL";
+ c = "PASS",
+ console.log(c);
+ }
+ expect_stdout: "PASS"
+}