diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-02-18 19:35:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-18 19:35:37 +0000 |
commit | 7052ce5aefefffbf8745a3ac13040448196b4b6c (patch) | |
tree | 39d6a23846af79bfe06cb93ff148bbe765d0952c /test/compress | |
parent | d13b71297ed2f118b0557bb9b4cb7b1702abb746 (diff) | |
download | tracifyjs-7052ce5aefefffbf8745a3ac13040448196b4b6c.tar.gz tracifyjs-7052ce5aefefffbf8745a3ac13040448196b4b6c.zip |
fix corner case in `evaluate` (#3728)
- augment `ufuzz` for further `RegExp` testing
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/regexp.js | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/test/compress/regexp.js b/test/compress/regexp.js index defc0079..e8b2da73 100644 --- a/test/compress/regexp.js +++ b/test/compress/regexp.js @@ -255,3 +255,171 @@ issue_3434_4: { "false true", ] } + +exec: { + options = { + evaluate: true, + loops: true, + unsafe: true, + } + input: { + while (/a/.exec("AAA")) + console.log("FAIL"); + console.log("PASS"); + } + expect: { + for (;null;) + console.log("FAIL"); + console.log("PASS"); + } + expect_stdout: "PASS" +} + +exec_global: { + options = { + evaluate: true, + loops: true, + unsafe: true, + } + input: { + while (/a/g.exec("AAA")) + console.log("FAIL"); + console.log("PASS"); + } + expect: { + for (;null;) + console.log("FAIL"); + console.log("PASS"); + } + expect_stdout: "PASS" +} + +test: { + options = { + evaluate: true, + unsafe: true, + } + input: { + while (/a/.test("AAA")) + console.log("FAIL"); + console.log("PASS"); + } + expect: { + while (false) + console.log("FAIL"); + console.log("PASS"); + } + expect_stdout: "PASS" +} + +test_global: { + options = { + evaluate: true, + unsafe: true, + } + input: { + while (/a/g.test("AAA")) + console.log("FAIL"); + console.log("PASS"); + } + expect: { + while (false) + console.log("FAIL"); + console.log("PASS"); + } + expect_stdout: "PASS" +} + +var_exec: { + options = { + evaluate: true, + loops: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + } + input: { + var r = /a/; + while (r.exec("AAA")) + console.log("FAIL"); + console.log("PASS"); + } + expect: { + var r = /a/; + for (;null;) + console.log("FAIL"); + console.log("PASS"); + } + expect_stdout: "PASS" +} + +var_exec_global: { + options = { + evaluate: true, + loops: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + } + input: { + var r = /a/g; + while (r.exec("aaa")) + console.log("PASS"); + } + expect: { + var r = /a/g; + for (;r.exec("aaa");) + console.log("PASS"); + } + expect_stdout: [ + "PASS", + "PASS", + "PASS", + ] +} + +var_test: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + } + input: { + var r = /a/; + while (r.test("AAA")) + console.log("FAIL"); + console.log("PASS"); + } + expect: { + var r = /a/; + while (false) + console.log("FAIL"); + console.log("PASS"); + } + expect_stdout: "PASS" +} + +var_test_global: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + } + input: { + var r = /a/g; + while (r.test("aaa")) + console.log("PASS"); + } + expect: { + var r = /a/g; + while (r.test("aaa")) + console.log("PASS"); + } + expect_stdout: [ + "PASS", + "PASS", + "PASS", + ] +} |