aboutsummaryrefslogtreecommitdiff
path: root/test/compress/merge_vars.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/merge_vars.js')
-rw-r--r--test/compress/merge_vars.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js
index 0494acfb..dc526c5f 100644
--- a/test/compress/merge_vars.js
+++ b/test/compress/merge_vars.js
@@ -3301,3 +3301,80 @@ issue_4761: {
}
expect_stdout: "undefined"
}
+
+issue_4956_1: {
+ options = {
+ merge_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var a, b;
+ function f(c) {
+ switch (c) {
+ case 0:
+ a = { p: 42 };
+
+ case 1:
+ b = a.p;
+ console.log(b);
+ }
+ }
+ f(0);
+ f(1);
+ }
+ expect: {
+ var a, b;
+ function f(c) {
+ switch (c) {
+ case 0:
+ a = { p: 42 };
+
+ case 1:
+ b = a.p;
+ console.log(b);
+ }
+ }
+ f(0);
+ f(1);
+ }
+ expect_stdout: [
+ "42",
+ "42",
+ ]
+}
+
+issue_4956_2: {
+ options = {
+ merge_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var a, b;
+ function f(c) {
+ if (0 == c) {
+ console;
+ a = { p: 42 };
+ }
+ b = a.p;
+ if (1 == c)
+ console.log(b);
+ }
+ f(0);
+ f(1);
+ }
+ expect: {
+ var a, b;
+ function f(c) {
+ if (0 == c) {
+ console;
+ a = { p: 42 };
+ }
+ b = a.p;
+ if (1 == c)
+ console.log(b);
+ }
+ f(0);
+ f(1);
+ }
+ expect_stdout: "42"
+}