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

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

Issue 1681893002: [regexp] parse RegExpUnicodeEscapeSequence according to spec. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 4 years, 10 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 | « src/regexp/regexp-parser.cc ('k') | test/mjsunit/harmony/unicode-regexp-restricted-syntax.js » ('j') | 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 // Quantifier. 251 // Quantifier.
252 assertTrue(new RegExp("\u{12345}{3}", "u").test("\u{12345}\u{12345}\u{12345}")); 252 assertTrue(new RegExp("\u{12345}{3}", "u").test("\u{12345}\u{12345}\u{12345}"));
253 assertTrue(/\u{12345}{3}/u.test("\u{12345}\u{12345}\u{12345}")); 253 assertTrue(/\u{12345}{3}/u.test("\u{12345}\u{12345}\u{12345}"));
254 assertTrue(new RegExp("\u{12345}{3}").test("\u{12345}\udf45\udf45")); 254 assertTrue(new RegExp("\u{12345}{3}").test("\u{12345}\udf45\udf45"));
255 assertFalse(/\ud808\udf45{3}/u.test("\u{12345}\udf45\udf45")); 255 assertFalse(/\ud808\udf45{3}/u.test("\u{12345}\udf45\udf45"));
256 assertTrue(/\ud808\udf45{3}/u.test("\u{12345}\u{12345}\u{12345}")); 256 assertTrue(/\ud808\udf45{3}/u.test("\u{12345}\u{12345}\u{12345}"));
257 assertFalse(new RegExp("\u{12345}{3}", "u").test("\u{12345}\udf45\udf45")); 257 assertFalse(new RegExp("\u{12345}{3}", "u").test("\u{12345}\udf45\udf45"));
258 assertFalse(/\u{12345}{3}/u.test("\u{12345}\udf45\udf45")); 258 assertFalse(/\u{12345}{3}/u.test("\u{12345}\udf45\udf45"));
259 259
260 // Mixed escapes and literal surrogates. 260 // Literal surrogates.
261 assertEquals(["\u{10000}\u{10000}"], 261 assertEquals(["\u{10000}\u{10000}"],
262 new RegExp("\ud800\udc00+", "u").exec("\u{10000}\u{10000}")); 262 new RegExp("\ud800\udc00+", "u").exec("\u{10000}\u{10000}"));
263 assertEquals(["\u{10000}\u{10000}"], 263 assertEquals(["\u{10000}\u{10000}"],
264 new RegExp("\\ud800\\udc00+", "u").exec("\u{10000}\u{10000}")); 264 new RegExp("\\ud800\\udc00+", "u").exec("\u{10000}\u{10000}"));
265 assertEquals(["\u{10000}\u{10000}"],
266 new RegExp("\\ud800\udc00+", "u").exec("\u{10000}\u{10000}"));
267 assertEquals(["\u{10000}\u{10000}"],
268 new RegExp("\ud800\\udc00+", "u").exec("\u{10000}\u{10000}"));
269 265
270 assertEquals(["\u{10003}\u{50001}"], 266 assertEquals(["\u{10003}\u{50001}"],
271 new RegExp("[\\ud800\\udc03-\\ud900\\udc01\]+", "u").exec( 267 new RegExp("[\\ud800\\udc03-\\ud900\\udc01\]+", "u").exec(
272 "\u{10003}\u{50001}")); 268 "\u{10003}\u{50001}"));
273 assertEquals(["\u{10003}\u{50001}"], 269 assertEquals(["\u{10003}\u{50001}"],
274 new RegExp("[\\ud800\udc03-\ud900\\udc01\]+", "u").exec(
275 "\u{10003}\u{50001}"));
276 assertEquals(["\u{50001}"],
277 new RegExp("[\\ud800\udc03-\ud900\\udc01\]+", "u").exec(
278 "\u{10002}\u{50001}"));
279 assertEquals(["\u{10003}\u{50001}"],
280 new RegExp("[\ud800\udc03-\u{50001}\]+", "u").exec( 270 new RegExp("[\ud800\udc03-\u{50001}\]+", "u").exec(
281 "\u{10003}\u{50001}")); 271 "\u{10003}\u{50001}"));
272
273 // Unicode escape sequences to represent a non-BMP character cannot have
274 // mixed notation, and must follow the rules for RegExpUnicodeEscapeSequence.
275 assertThrows(() => new RegExp("[\\ud800\udc03-\ud900\\udc01\]+", "u"));
276 assertThrows(() => new RegExp("[\\ud800\udc03-\ud900\\udc01\]+", "u"));
277 assertNull(new RegExp("\\ud800\udc00+", "u").exec("\u{10000}\u{10000}"));
278 assertNull(new RegExp("\ud800\\udc00+", "u").exec("\u{10000}\u{10000}"));
279
280 assertNull(new RegExp("[\\ud800\udc00]", "u").exec("\u{10000}"));
281 assertNull(new RegExp("[\\{ud800}\udc00]", "u").exec("\u{10000}"));
282 assertNull(new RegExp("[\ud800\\udc00]", "u").exec("\u{10000}"));
283 assertNull(new RegExp("[\ud800\\{udc00}]", "u").exec("\u{10000}"));
284
285 assertNull(/\u{d800}\u{dc00}+/u.exec("\ud800\udc00\udc00"));
286 assertNull(/\ud800\u{dc00}+/u.exec("\ud800\udc00\udc00"));
287 assertNull(/\u{d800}\udc00+/u.exec("\ud800\udc00\udc00"));
OLDNEW
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | test/mjsunit/harmony/unicode-regexp-restricted-syntax.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698