fix collapse_vars on switch (#2578)

This commit is contained in:
Alex Lam S.L
2017-12-11 18:11:09 +08:00
committed by GitHub
parent c43118be4f
commit f2ad542679
2 changed files with 61 additions and 7 deletions

View File

@@ -1749,7 +1749,7 @@ for_init: {
}
}
switch_case: {
switch_case_1: {
options = {
collapse_vars: true,
unused: true,
@@ -1777,6 +1777,62 @@ switch_case: {
}
}
switch_case_2: {
options = {
collapse_vars: true,
}
input: {
var a = 1, b = 2;
switch (b++) {
case b:
var c = a;
var a;
break;
}
console.log(a);
}
expect: {
var a = 1, b = 2;
switch (b++) {
case b:
var c = a;
var a;
break;
}
console.log(a);
}
expect_stdout: "1"
}
switch_case_3: {
options = {
collapse_vars: true,
}
input: {
var a = 1, b = 2;
switch (a) {
case a:
var b;
break;
case b:
break;
}
console.log(b);
}
expect: {
var a = 1, b = 2;
switch (a) {
case a:
var b;
break;
case b:
break;
}
console.log(b);
}
expect_stdout: "2"
}
issue_27: {
options = {
collapse_vars: true,