diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-04-10 17:36:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 00:36:53 +0800 |
commit | 3d72663689a7e58d3e7c57508a30d9d297cc507c (patch) | |
tree | ca6243b44677abe03696cf5dc2429f24789764f1 /test/compress/issue-3768.js | |
parent | a2b16e89a475d3f7744481a5e07e1c7168d878af (diff) | |
download | tracifyjs-3d72663689a7e58d3e7c57508a30d9d297cc507c.tar.gz tracifyjs-3d72663689a7e58d3e7c57508a30d9d297cc507c.zip |
add tests for `eval()` (#3769)
closes #3768
Diffstat (limited to 'test/compress/issue-3768.js')
-rw-r--r-- | test/compress/issue-3768.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/test/compress/issue-3768.js b/test/compress/issue-3768.js new file mode 100644 index 00000000..c3475aca --- /dev/null +++ b/test/compress/issue-3768.js @@ -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" +} |