account for eval & with in reduce_vars (#2441)

fixes #2440
This commit is contained in:
Alex Lam S.L
2017-11-06 16:10:57 +08:00
committed by GitHub
parent 6c45101870
commit 2cfb5aa7da
2 changed files with 120 additions and 7 deletions

View File

@@ -3542,3 +3542,115 @@ issue_2423_6: {
"2",
]
}
issue_2440_eval_1: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function foo() {
return bar();
}
baz = {
quux: foo
};
exec = function() {
return eval("foo()");
};
}
expect: {
function foo() {
return bar();
}
baz = {
quux: foo
};
exec = function() {
return eval("foo()");
};
}
}
issue_2440_eval_2: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
baz = {
quux: foo
};
exec = function() {
return eval("foo()");
};
function foo() {
return bar();
}
}
expect: {
baz = {
quux: foo
};
exec = function() {
return eval("foo()");
};
function foo() {
return bar();
}
}
}
issue_2440_with_1: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function foo() {
return bar();
}
baz = {
quux: foo
};
with (o) whatever();
}
expect: {
function foo() {
return bar();
}
baz = {
quux: foo
};
with (o) whatever();
}
}
issue_2440_with_2: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
baz = {
quux: foo
};
with (o) whatever();
function foo() {
return bar();
}
}
expect: {
baz = {
quux: foo
};
with (o) whatever();
function foo() {
return bar();
}
}
}