diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-02 02:18:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 02:18:33 +0800 |
commit | 8da3754e51140c0eee80f02fcf3f5d99a74ca86e (patch) | |
tree | 3e1e381f2e650cf648d9b184a22a7561e4aa2754 /test/compress/typeof.js | |
parent | 9a6b11f8e628c66731c4037ff408bb969003e6f7 (diff) | |
download | tracifyjs-8da3754e51140c0eee80f02fcf3f5d99a74ca86e.tar.gz tracifyjs-8da3754e51140c0eee80f02fcf3f5d99a74ca86e.zip |
improve `evaluate` on `typeof` (#2550)
- gated through `typeofs`
Diffstat (limited to 'test/compress/typeof.js')
-rw-r--r-- | test/compress/typeof.js | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/test/compress/typeof.js b/test/compress/typeof.js index 34949fbe..180e5451 100644 --- a/test/compress/typeof.js +++ b/test/compress/typeof.js @@ -1,6 +1,7 @@ typeof_evaluation: { options = { - evaluate: true + evaluate: true, + typeofs: true, }; input: { a = typeof 1; @@ -60,3 +61,80 @@ issue_1668: { if (1); } } + +typeof_defun_1: { + options = { + evaluate: true, + inline: true, + passes: 2, + reduce_vars: true, + side_effects: true, + toplevel: true, + typeofs: true, + unused: true, + } + input: { + function f() { + console.log("YES"); + } + function g() { + h = 42; + console.log("NOPE"); + } + function h() { + console.log("YUP"); + } + g = 42; + "function" == typeof f && f(); + "function" == typeof g && g(); + "function" == typeof h && h(); + } + expect: { + function g() { + h = 42; + console.log("NOPE"); + } + function h() { + console.log("YUP"); + } + g = 42; + console.log("YES"); + "function" == typeof g && g(); + h(); + } + expect_stdout: [ + "YES", + "YUP", + ] +} + +typeof_defun_2: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + typeofs: true, + } + input: { + var f = function() { + console.log(x); + }; + var x = 0; + x++ < 2 && typeof f == "function" && f(); + x++ < 2 && typeof f == "function" && f(); + x++ < 2 && typeof f == "function" && f(); + } + expect: { + var f = function() { + console.log(x); + }; + var x = 0; + x++ < 2 && f(); + x++ < 2 && f(); + x++ < 2 && f(); + } + expect_stdout: [ + "1", + "2", + ] +} |