aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-10 17:34:45 +0100
committerGitHub <noreply@github.com>2020-04-11 00:34:45 +0800
commita2b16e89a475d3f7744481a5e07e1c7168d878af (patch)
treea2dfdb279ace186b7725c3e479bc0994ee0ee62b /test/compress
parentb35f4c5a83247251922e1d695576db29e821aee1 (diff)
downloadtracifyjs-a2b16e89a475d3f7744481a5e07e1c7168d878af.tar.gz
tracifyjs-a2b16e89a475d3f7744481a5e07e1c7168d878af.zip
fix corner cases in `inline` (#3773)
fixes #3770 fixes #3771 fixes #3772
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/functions.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 4a192d59..c1522e2e 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -3928,3 +3928,89 @@ preserve_binding_2: {
}
expect_stdout: "PASS"
}
+
+issue_3770: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (function() {
+ function f(a, a) {
+ var b = function() {
+ return a || "PASS";
+ }();
+ console.log(b);
+ }
+ f("FAIL");
+ })();
+ }
+ expect: {
+ (function() {
+ b = a || "PASS",
+ console.log(b);
+ var a, b;
+ })();
+ }
+ expect_stdout: "PASS"
+}
+
+issue_3771: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ try {
+ function f(a) {
+ var a = f(1234);
+ }
+ f();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect: {
+ try {
+ (function f(a) {
+ f();
+ })();
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect_stdout: "PASS"
+}
+
+issue_3772: {
+ options = {
+ collapse_vars: true,
+ dead_code: true,
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = "PASS";
+ function f() {
+ return a;
+ }
+ var b = f();
+ function g() {
+ console.log(f());
+ }
+ g();
+ }
+ expect: {
+ var a = "PASS";
+ console.log(a);
+ }
+ expect_stdout: "PASS"
+}