aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-05-23 17:24:13 +0800
committerGitHub <noreply@github.com>2018-05-23 17:24:13 +0800
commit8c62d854ce90210d278707c9aff58f10c26e3c27 (patch)
treed69d09aaee2e5bcb99e7c9c644f73a742175bae4 /test
parent69931574e14d3ec58141b9ce2ef679f21caf5991 (diff)
downloadtracifyjs-8c62d854ce90210d278707c9aff58f10c26e3c27.tar.gz
tracifyjs-8c62d854ce90210d278707c9aff58f10c26e3c27.zip
augment tests for `RegExp` (#3144)
Diffstat (limited to 'test')
-rw-r--r--test/compress/regexp.js37
-rw-r--r--test/compress/string-literal.js9
2 files changed, 45 insertions, 1 deletions
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"]'
}