From: Alex Lam S.L Date: Wed, 23 May 2018 09:24:13 +0000 (+0800) Subject: augment tests for `RegExp` (#3144) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=8c62d854ce90210d278707c9aff58f10c26e3c27;p=UglifyJS.git augment tests for `RegExp` (#3144) --- diff --git a/test/compress/regexp.js b/test/compress/regexp.js new file mode 100644 index 00000000..ac834e5d --- /dev/null +++ b/test/compress/regexp.js @@ -0,0 +1,37 @@ +regexp_simple: { + input: { + /rx/ig + } + expect_exact: "/rx/gi;" +} + +regexp_slashes: { + input: { + /\\\/rx\/\\/ig + } + expect_exact: "/\\\\\\/rx\\/\\\\/gi;" +} + +regexp_1: { + input: { + console.log(JSON.stringify("COMPASS? Overpass.".match(/([Sap]+)/ig))); + } + expect: { + console.log(JSON.stringify("COMPASS? Overpass.".match(/([Sap]+)/gi))); + } + expect_stdout: '["PASS","pass"]' +} + +regexp_2: { + options = { + evaluate: true, + unsafe: true, + } + input: { + console.log(JSON.stringify("COMPASS? Overpass.".match(new RegExp("([Sap]+)", "ig")))); + } + expect: { + console.log(JSON.stringify("COMPASS? Overpass.".match(/([Sap]+)/gi))); + } + expect_stdout: '["PASS","pass"]' +} diff --git a/test/compress/string-literal.js b/test/compress/string-literal.js index 1138fed8..5f49fb3e 100644 --- a/test/compress/string-literal.js +++ b/test/compress/string-literal.js @@ -14,6 +14,13 @@ issue_1929: { function f(s) { return s.split(/[\\/]/); } + console.log(JSON.stringify(f("A/B\\C\\D/E\\F"))); } - expect_exact: "function f(s){return s.split(/[\\\\/]/)}" + expect: { + function f(s) { + return s.split(/[\\/]/); + } + console.log(JSON.stringify(f("A/B\\C\\D/E\\F"))); + } + expect_stdout: '["A","B","C","D","E","F"]' }