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

Unified Diff: test/mjsunit/regress/regress-3756.js

Issue 802313003: RegExpParser: Fix Reset()ting to the end. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: long lines Created 6 years 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/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-3756.js
diff --git a/test/mjsunit/regress/regress-3756.js b/test/mjsunit/regress/regress-3756.js
new file mode 100644
index 0000000000000000000000000000000000000000..6b1f029093a40ece5f3d666dcac44a78a62f6f7a
--- /dev/null
+++ b/test/mjsunit/regress/regress-3756.js
@@ -0,0 +1,74 @@
+// Copyright 2014 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.
+
+(function TestIdentityEscapes() {
+ // \u not followed by 4 hex digits is treated as an identity escape.
+ var r0 = /\u/;
+ assertTrue(r0.test("u"));
+
+ r0 = RegExp("\\u");
+ assertTrue(r0.test("u"));
+
+ var r1 = /\usecond/;
+ assertTrue(r1.test("usecond"));
+
+ r1 = RegExp("\\usecond");
+ assertTrue(r1.test("usecond"));
+
+ var r2 = /first\u/;
+ assertTrue(r2.test("firstu"));
+ // This used to return true (which was a bug).
+ assertFalse(r2.test("first\\u"));
+
+ r2 = RegExp("first\\u");
+ assertTrue(r2.test("firstu"));
+ // This used to return true (which was a bug).
+ assertFalse(r2.test("first\\u"));
+
+ var r3 = /first\usecond/;
+ assertTrue(r3.test("firstusecond"));
+ assertFalse(r3.test("first\\usecond"));
+
+ r3 = RegExp("first\\usecond");
+ assertTrue(r3.test("firstusecond"));
+ assertFalse(r3.test("first\\usecond"));
+
+ var r4 = /first\u123second/;
+ assertTrue(r4.test("firstu123second"));
+ assertFalse(r4.test("first\\u123second"));
+
+ r4 = RegExp("first\\u123second");
+ assertTrue(r4.test("firstu123second"));
+ assertFalse(r4.test("first\\u123second"));
+
+ // \X where X is not a legal escape character is treated as identity escape
+ // too.
+ var r5 = /\a/;
+ assertTrue(r5.test("a"));
+
+ r5 = RegExp("\\a");
+ assertTrue(r5.test("a"));
+
+ var r6 = /\asecond/;
+ assertTrue(r6.test("asecond"));
+
+ r6 = RegExp("\\asecond");
+ assertTrue(r6.test("asecond"));
+
+ var r7 = /first\a/;
+ assertTrue(r7.test("firsta"));
+ assertFalse(r7.test("first\\a"));
+
+ r7 = RegExp("first\\a");
+ assertTrue(r7.test("firsta"));
+ assertFalse(r7.test("first\\a"));
+
+ var r8 = /first\asecond/;
+ assertTrue(r8.test("firstasecond"));
+ assertFalse(r8.test("first\\asecond"));
+
+ r8 = RegExp("first\\asecond");
+ assertTrue(r8.test("firstasecond"));
+ assertFalse(r8.test("first\\asecond"));
+})();
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698