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

Side by Side Diff: tests/language/regex/no-extensions_test.dart

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed Ivan's comments. Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'util.dart';
6 import 'package:expect/expect.dart';
7
8 void main() {
9 description(
10 'Tests that regular expressions do not have extensions that diverge from the J avaScript specification. '
11 + 'Because WebKit originally used a copy of PCRE, various non-JavaScript regul ar expression features were historically present. '
12 + 'Also tests various related edge cases.'
13 );
14
15 shouldBeNull(new RegExp(r"\\x{41}").firstMatch("yA1"));
16 assertEquals(new RegExp(r"[\x{41}]").firstMatch("yA1").group(0), "1");
17 assertEquals(new RegExp(r"\x1g").firstMatch("x1g").group(0), "x1g");
18 assertEquals(new RegExp(r"[\x1g]").firstMatch("x").group(0), "x");
19 assertEquals(new RegExp(r"[\x1g]").firstMatch("1").group(0), "1");
20 assertEquals(new RegExp(r"\2147483648").firstMatch(new String.fromCharCode(140 ) + "7483648").group(0), new String.fromCharCode(140) + "7483648");
21 assertEquals(new RegExp(r"\4294967296").firstMatch("\"94967296").group(0), "\" 94967296");
22 assertEquals(new RegExp(r"\8589934592").firstMatch("\8589934592").group(0), "\ 8589934592");
23 assertEquals("\nAbc\n".replaceAllMapped(new RegExp(r"(\n)[^\n]+$"), (m) => m.g roup(1)), "\nAbc\n");
24 shouldBeNull(new RegExp(r"x$").firstMatch("x\n"));
25 assertThrows(() => new RegExp(r"x++"));
26 shouldBeNull(new RegExp(r"[]]").firstMatch("]"));
27
28 assertEquals(new RegExp(r"\060").firstMatch("y01").group(0), "0");
29 assertEquals(new RegExp(r"[\060]").firstMatch("y01").group(0), "0");
30 assertEquals(new RegExp(r"\606").firstMatch("y06").group(0), "06");
31 assertEquals(new RegExp(r"[\606]").firstMatch("y06").group(0), "0");
32 assertEquals(new RegExp(r"[\606]").firstMatch("y6").group(0), "6");
33 assertEquals(new RegExp(r"\101").firstMatch("yA1").group(0), "A");
34 assertEquals(new RegExp(r"[\101]").firstMatch("yA1").group(0), "A");
35 assertEquals(new RegExp(r"\1011").firstMatch("yA1").group(0), "A1");
36 assertEquals(new RegExp(r"[\1011]").firstMatch("yA1").group(0), "A");
37 assertEquals(new RegExp(r"[\1011]").firstMatch("y1").group(0), "1");
38 assertEquals(new RegExp(r"\10q").firstMatch("y" + new String.fromCharCode(8) + "q").group(0), new String.fromCharCode(8) + "q");
39 assertEquals(new RegExp(r"[\10q]").firstMatch("y" + new String.fromCharCode(8) + "q").group(0), new String.fromCharCode(8));
40 assertEquals(new RegExp(r"\1q").firstMatch("y" + new String.fromCharCode(1) + "q").group(0), new String.fromCharCode(1) + "q");
41 assertEquals(new RegExp(r"[\1q]").firstMatch("y" + new String.fromCharCode(1) + "q").group(0), new String.fromCharCode(1));
42 assertEquals(new RegExp(r"[\1q]").firstMatch("yq").group(0), "q");
43 assertEquals(new RegExp(r"\8q").firstMatch("\8q").group(0), "\8q");
44 assertEquals(new RegExp(r"[\8q]").firstMatch("y8q").group(0), "8");
45 assertEquals(new RegExp(r"[\8q]").firstMatch("yq").group(0), "q");
46 shouldBe(new RegExp(r"(x)\1q").firstMatch("xxq"), ["xxq", "x"]);
47 shouldBe(new RegExp(r"(x)[\1q]").firstMatch("xxq"), ["xq", "x"]);
48 shouldBe(new RegExp(r"(x)[\1q]").firstMatch("xx" + new String.fromCharCode(1)) , ["x" + new String.fromCharCode(1), "x"]);
49 }
OLDNEW
« no previous file with comments | « tests/language/regex/negative-special-characters_test.dart ('k') | tests/language/regex/non-bmp_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698