Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: test/mjsunit/harmony/regexp-dotall.js

Issue 2780173002: [regexp] Add support for dotAll flag (Closed)
Patch Set: Address comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | test/mjsunit/harmony/regexp-dotall-disabled.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/regexp-dotall.js
diff --git a/test/mjsunit/harmony/regexp-dotall.js b/test/mjsunit/harmony/regexp-dotall.js
new file mode 100644
index 0000000000000000000000000000000000000000..9bf78431a9dca19fc0f4bdb34dff48193c731a00
--- /dev/null
+++ b/test/mjsunit/harmony/regexp-dotall.js
@@ -0,0 +1,129 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-regexp-dotall
+
+function toSlowMode(re) {
+ re.exec = (str) => RegExp.prototype.exec.call(re, str);
+ return re;
+}
+
+// Construction does not throw.
+{
+ let re = /./s;
+ re = RegExp(".", "s");
+ re = new RegExp(".", "s");
+ assertThrows(() => new RegExp(".", "wtf"), SyntaxError);
+}
+
+// The flags accessors.
+{
+ let re = /./s;
+ assertEquals("s", re.flags);
+ assertFalse(re.global);
+ assertFalse(re.ignoreCase);
+ assertFalse(re.multiline);
+ assertFalse(re.sticky);
+ assertFalse(re.unicode);
+ assertTrue(re.dotAll);
+
+ re = toSlowMode(/./s);
+ assertEquals("s", re.flags);
+ assertFalse(re.global);
+ assertFalse(re.ignoreCase);
+ assertFalse(re.multiline);
+ assertFalse(re.sticky);
+ assertFalse(re.unicode);
+ assertTrue(re.dotAll);
+
+ re = /./gimyus;
+ assertEquals("gimsuy", re.flags);
+ assertTrue(re.global);
+ assertTrue(re.ignoreCase);
+ assertTrue(re.multiline);
+ assertTrue(re.sticky);
+ assertTrue(re.unicode);
+ assertTrue(re.dotAll);
+
+ re = /./gimyu;
+ assertEquals("gimuy", re.flags);
+ assertTrue(re.global);
+ assertTrue(re.ignoreCase);
+ assertTrue(re.multiline);
+ assertTrue(re.sticky);
+ assertTrue(re.unicode);
+ assertFalse(re.dotAll);
+}
+
+// Default '.' behavior.
+{
+ let re = /^.$/;
+ assertTrue(re.test("a"));
+ assertTrue(re.test("3"));
+ assertTrue(re.test("π"));
+ assertTrue(re.test("\u2027"));
+ assertTrue(re.test("\u0085"));
+ assertTrue(re.test("\v"));
+ assertTrue(re.test("\f"));
+ assertTrue(re.test("\u180E"));
+ assertFalse(re.test("\u{10300}")); // Supplementary plane.
+ assertFalse(re.test("\n"));
+ assertFalse(re.test("\r"));
+ assertFalse(re.test("\u2028"));
+ assertFalse(re.test("\u2029"));
+}
+
+// Default '.' behavior (unicode).
+{
+ let re = /^.$/u;
+ assertTrue(re.test("a"));
+ assertTrue(re.test("3"));
+ assertTrue(re.test("π"));
+ assertTrue(re.test("\u2027"));
+ assertTrue(re.test("\u0085"));
+ assertTrue(re.test("\v"));
+ assertTrue(re.test("\f"));
+ assertTrue(re.test("\u180E"));
+ assertTrue(re.test("\u{10300}")); // Supplementary plane.
+ assertFalse(re.test("\n"));
+ assertFalse(re.test("\r"));
+ assertFalse(re.test("\u2028"));
+ assertFalse(re.test("\u2029"));
+}
+
+// DotAll '.' behavior.
+{
+ let re = /^.$/s;
+ assertTrue(re.test("a"));
+ assertTrue(re.test("3"));
+ assertTrue(re.test("π"));
+ assertTrue(re.test("\u2027"));
+ assertTrue(re.test("\u0085"));
+ assertTrue(re.test("\v"));
+ assertTrue(re.test("\f"));
+ assertTrue(re.test("\u180E"));
+ assertFalse(re.test("\u{10300}")); // Supplementary plane.
+ assertTrue(re.test("\n"));
+ assertTrue(re.test("\r"));
+ assertTrue(re.test("\u2028"));
+ assertTrue(re.test("\u2029"));
+}
+
+// DotAll '.' behavior (unicode).
+{
+ let re = /^.$/su;
+ assertTrue(re.test("a"));
+ assertTrue(re.test("3"));
+ assertTrue(re.test("π"));
+ assertTrue(re.test("\u2027"));
+ assertTrue(re.test("\u0085"));
+ assertTrue(re.test("\v"));
+ assertTrue(re.test("\f"));
+ assertTrue(re.test("\u180E"));
+ assertTrue(re.test("\u{10300}")); // Supplementary plane.
+ assertTrue(re.test("\n"));
+ assertTrue(re.test("\r"));
+ assertTrue(re.test("\u2028"));
+ assertTrue(re.test("\u2029"));
+}
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | test/mjsunit/harmony/regexp-dotall-disabled.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698