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

Side by Side Diff: test/mjsunit/harmony/unicode-escapes-in-regexps.js

Issue 1568623004: [regexp] correctly parse non-BMP unicode escapes in atoms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase correctly Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ES6 extends the \uxxxx escape and also allows \u{xxxxx}. 5 // ES6 extends the \uxxxx escape and also allows \u{xxxxx}.
6 6
7 // Flags: --harmony-unicode-regexps --harmony-regexps 7 // Flags: --harmony-unicode-regexps --harmony-regexps
8 8
9 function testRegexpHelper(r) { 9 function testRegexpHelper(r) {
10 assertTrue(r.test("foo")); 10 assertTrue(r.test("foo"));
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 204
205 (function ToString() { 205 (function ToString() {
206 // Test that the u flag is included in the string representation of regexps. 206 // Test that the u flag is included in the string representation of regexps.
207 function helper(r) { 207 function helper(r) {
208 assertEquals(r.toString(), "/foo/u"); 208 assertEquals(r.toString(), "/foo/u");
209 } 209 }
210 helper(/foo/u); 210 helper(/foo/u);
211 helper(new RegExp("foo", "u")); 211 helper(new RegExp("foo", "u"));
212 })(); 212 })();
213
214 // Non-BMP patterns.
215 // Single character atom.
216 assertTrue(new RegExp("\u{12345}", "u").test("\u{12345}"));
217 assertTrue(/\u{12345}/u.test("\u{12345}"));
218 assertTrue(new RegExp("\u{12345}", "u").test("\ud808\udf45"));
219 assertTrue(/\u{12345}/u.test("\ud808\udf45"));
220 assertFalse(new RegExp("\u{12345}", "u").test("\udf45"));
221 assertFalse(/\u{12345}/u.test("\udf45"));
222
223 // Multi-character atom.
224 assertTrue(new RegExp("\u{12345}\u{23456}", "u").test("a\u{12345}\u{23456}b"));
225 assertTrue(/\u{12345}\u{23456}/u.test("b\u{12345}\u{23456}c"));
226 assertFalse(new RegExp("\u{12345}\u{23456}", "u").test("a\udf45\u{23456}b"));
227 assertFalse(/\u{12345}\u{23456}/u.test("b\udf45\u{23456}c"));
228
229 // Disjunction.
230 assertTrue(new RegExp("\u{12345}(?:\u{23456})", "u").test(
231 "a\u{12345}\u{23456}b"));
232 assertTrue(/\u{12345}(?:\u{23456})/u.test("b\u{12345}\u{23456}c"));
233 assertFalse(new RegExp("\u{12345}(?:\u{23456})", "u").test(
234 "a\udf45\u{23456}b"));
235 assertFalse(/\u{12345}(?:\u{23456})/u.test("b\udf45\u{23456}c"));
236
237 // Alternative.
238 assertTrue(new RegExp("\u{12345}|\u{23456}", "u").test("a\u{12345}b"));
239 assertTrue(/\u{12345}|\u{23456}/u.test("b\u{23456}c"));
240 assertFalse(new RegExp("\u{12345}|\u{23456}", "u").test("a\udf45\ud84db"));
241 assertFalse(/\u{12345}|\u{23456}/u.test("b\udf45\ud808c"));
242
243 // Capture.
244 assertTrue(new RegExp("(\u{12345}|\u{23456}).\\1", "u").test(
245 "\u{12345}b\u{12345}"));
246 assertTrue(/(\u{12345}|\u{23456}).\1/u.test("\u{12345}b\u{12345}"));
247 assertFalse(new RegExp("(\u{12345}|\u{23456}).\\1", "u").test(
248 "\u{12345}b\u{23456}"));
249 assertFalse(/(\u{12345}|\u{23456}).\1/u.test("\u{12345}b\u{23456}"));
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698