Skip to content

Commit

Permalink
add tests for eval() (#3769)
Browse files Browse the repository at this point in the history
closes #3768
  • Loading branch information
alexlamsl authored Apr 10, 2020
1 parent a2b16e8 commit 3d72663
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/compress/issue-3768.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
mangle: {
mangle = {
toplevel: true,
}
input: {
var e = eval, x = 42;
(function() {
console.log(e("typeof x"));
})();
}
expect: {
var o = eval, e = 42;
(function() {
console.log(o("typeof x"));
})();
}
expect_stdout: "undefined"
}

compress: {
options = {
collapse_vars: true,
inline: true,
unused: true,
}
input: {
console.log(function() {
var a = 42;
return eval("typeof a");
}(), function(e) {
var a = null;
return e("typeof a");
}(eval), function(eval) {
var a = false;
return eval("typeof a");
}(eval), function(f) {
var a = "STRING";
var eval = f;
return eval("typeof a");
}(eval), function(g) {
var a = eval;
function eval() {
return g;
}
return eval()("typeof a");
}(eval));
}
expect: {
console.log(function() {
var a = 42;
return eval("typeof a");
}(), eval("typeof a"), function(eval) {
var a = false;
return eval("typeof a");
}(eval), function(f) {
var a = "STRING";
var eval = f;
return eval("typeof a");
}(eval), function(g) {
var a = eval;
function eval() {
return g;
}
return eval()("typeof a");
}(eval));
}
expect_stdout: "number undefined boolean string undefined"
}

0 comments on commit 3d72663

Please sign in to comment.