diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-27 17:35:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-27 17:35:21 +0800 |
commit | d4b701067805f5041c3b27225742a7b36c3db90c (patch) | |
tree | 6d43085a36f7eafcdcf217b717e46c8ca2c92ac2 /test/compress/collapse_vars.js | |
parent | e27493f3c2e637b8f3e9da4757e76959a8705cd9 (diff) | |
download | tracifyjs-d4b701067805f5041c3b27225742a7b36c3db90c.tar.gz tracifyjs-d4b701067805f5041c3b27225742a7b36c3db90c.zip |
fix corner case in `unsafe_regexp` (#3609)
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r-- | test/compress/collapse_vars.js | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index abdd9c2a..0f1e59a3 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -1633,21 +1633,32 @@ collapse_vars_regexp: { return rx.exec(s); }; } + function f3() { + var rx = /ab*/g; + return function() { + return rx; + }; + } (function() { var result; - var s = 'acdabcdeabbb'; + var s = "acdabcdeabbb"; var rx = /ab*/g; - while (result = rx.exec(s)) { + while (result = rx.exec(s)) console.log(result[0]); - } })(); (function() { var result; - var s = 'acdabcdeabbb'; + var s = "acdabcdeabbb"; var rx = f2(); - while (result = rx(s)) { + while (result = rx(s)) + console.log(result[0]); + })(); + (function() { + var result; + var s = "acdabcdeabbb"; + var rx = f3(); + while (result = rx().exec(s)) console.log(result[0]); - } })(); } expect: { @@ -1660,6 +1671,12 @@ collapse_vars_regexp: { return rx.exec(s); }; } + function f3() { + var rx = /ab*/g; + return function() { + return rx; + }; + } (function() { var result, rx = /ab*/g; while (result = rx.exec("acdabcdeabbb")) @@ -1670,8 +1687,23 @@ collapse_vars_regexp: { while (result = rx("acdabcdeabbb")) console.log(result[0]); })(); + (function() { + var result, rx = f3(); + while (result = rx().exec("acdabcdeabbb")) + console.log(result[0]); + })(); } - expect_stdout: true + expect_stdout: [ + "a", + "ab", + "abbb", + "a", + "ab", + "abbb", + "a", + "ab", + "abbb", + ] } issue_1537: { |