aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-29 13:31:41 +0800
committerGitHub <noreply@github.com>2017-11-29 13:31:41 +0800
commitbc5047c1e70594ea2fa8e747945a577298715926 (patch)
tree8109b4339adcf09625cc61efb0a5527f35f40a96 /test/compress
parent206a54a7461b76683d690fd7016943fcb461a4fa (diff)
downloadtracifyjs-bc5047c1e70594ea2fa8e747945a577298715926.tar.gz
tracifyjs-bc5047c1e70594ea2fa8e747945a577298715926.zip
fix `inline` on nested substitutions (#2533)
fixes #2531
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/functions.js99
1 files changed, 99 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 3e5562a2..3ecb4bc3 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -554,3 +554,102 @@ issue_2428: {
"PASS",
]
}
+
+issue_2531_1: {
+ options = {
+ evaluate: true,
+ inline: true,
+ reduce_funcs: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ function outer() {
+ function inner(value) {
+ function closure() {
+ return value;
+ }
+ return function() {
+ return closure();
+ };
+ }
+ return inner("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect: {
+ function outer() {
+ return function(value) {
+ return function() {
+ return value;
+ };
+ }("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect_stdout: "Greeting: Hello"
+}
+
+issue_2531_2: {
+ options = {
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ reduce_funcs: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ function outer() {
+ function inner(value) {
+ function closure() {
+ return value;
+ }
+ return function() {
+ return closure();
+ };
+ }
+ return inner("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect: {
+ function outer() {
+ return function() {
+ return "Hello";
+ };
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect_stdout: "Greeting: Hello"
+}
+
+issue_2531_3: {
+ options = {
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ reduce_funcs: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function outer() {
+ function inner(value) {
+ function closure() {
+ return value;
+ }
+ return function() {
+ return closure();
+ };
+ }
+ return inner("Hello");
+ }
+ console.log("Greeting:", outer()());
+ }
+ expect: {
+ console.log("Greeting:", "Hello");
+ }
+ expect_stdout: "Greeting: Hello"
+}