augment tests for `RegExp` (#3144)
authorAlex Lam S.L <alexlamsl@gmail.com>
Wed, 23 May 2018 09:24:13 +0000 (17:24 +0800)
committerGitHub <noreply@github.com>
Wed, 23 May 2018 09:24:13 +0000 (17:24 +0800)
test/compress/regexp.js [new file with mode: 0644]
test/compress/string-literal.js

diff --git a/test/compress/regexp.js b/test/compress/regexp.js
new file mode 100644 (file)
index 0000000..ac834e5
--- /dev/null
@@ -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"]'
+}
index 1138fed..5f49fb3 100644 (file)
@@ -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"]'
 }