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

Side by Side Diff: tests/language/regex/ecma-regex-examples_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 "This page tests the regex examples from the ECMA-262 specification."
11 );
12
13 var regex01 = new RegExp(r"a|ab");
14 shouldBe(regex01.firstMatch("abc"), ["a"]);
15
16 var regex02 = new RegExp(r"((a)|(ab))((c)|(bc))");
17 shouldBe(regex02.firstMatch("abc"), ["abc", "a", "a", null, "bc", null, "bc"]) ;
18
19 var regex03 = new RegExp(r"a[a-z]{2,4}");
20 shouldBe(regex03.firstMatch("abcdefghi"), ["abcde"]);
21
22 var regex04 = new RegExp(r"a[a-z]{2,4}?");
23 shouldBe(regex04.firstMatch("abcdefghi"), ["abc"]);
24
25 var regex05 = new RegExp(r"(aa|aabaac|ba|b|c)*");
26 shouldBe(regex05.firstMatch("aabaac"), ["aaba", "ba"]);
27
28 var regex06 = new RegExp(r"^(a+)\1*,\1+$");
29 Expect.equals("aaaaaaaaaa,aaaaaaaaaaaaaaa".replaceAllMapped(regex06,(m) => m.g roup(1)), "aaaaa");
30
31 var regex07 = new RegExp(r"(z)((a+)?(b+)?(c))*");
32 shouldBe(regex07.firstMatch("zaacbbbcac"), ["zaacbbbcac", "z", "ac", "a", null , "c"]);
33
34 var regex08 = new RegExp(r"(a*)*");
35 shouldBe(regex08.firstMatch("b"), ["", null]);
36
37 var regex09 = new RegExp(r"(a*)b\1+");
38 shouldBe(regex09.firstMatch("baaaac"), ["b", ""]);
39
40 var regex10 = new RegExp(r"(?=(a+))");
41 shouldBe(regex10.firstMatch("baaabac"), ["", "aaa"]);
42
43 var regex11 = new RegExp(r"(?=(a+))a*b\1");
44 shouldBe(regex11.firstMatch("baaabac"), ["aba", "a"]);
45
46 var regex12 = new RegExp(r"(.*?)a(?!(a+)b\2c)\2(.*)");
47 shouldBe(regex12.firstMatch("baaabaac"), ["baaabaac", "ba", null, "abaac"]);
48 }
OLDNEW
« no previous file with comments | « tests/language/regex/early-acid3-86_test.dart ('k') | tests/language/regex/extended-characters-match_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698