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

Side by Side Diff: tests/language/regex/dotstar_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("This page tests handling of parentheses subexpressions.");
10
11 var regexp1 = new RegExp(r".*blah.*");
12 shouldBeNull(regexp1.firstMatch('test'));
13 shouldBe(regexp1.firstMatch('blah'), ['blah']);
14 shouldBe(regexp1.firstMatch('1blah'), ['1blah']);
15 shouldBe(regexp1.firstMatch('blah1'), ['blah1']);
16 shouldBe(regexp1.firstMatch('blah blah blah'), ['blah blah blah']);
17 shouldBe(regexp1.firstMatch('blah\nsecond'), ['blah']);
18 shouldBe(regexp1.firstMatch('first\nblah'), ['blah']);
19 shouldBe(regexp1.firstMatch('first\nblah\nthird'), ['blah']);
20 shouldBe(regexp1.firstMatch('first\nblah2\nblah3'), ['blah2']);
21
22 var regexp2 = new RegExp(r"^.*blah.*");
23 shouldBeNull(regexp2.firstMatch('test'));
24 shouldBe(regexp2.firstMatch('blah'), ['blah']);
25 shouldBe(regexp2.firstMatch('1blah'), ['1blah']);
26 shouldBe(regexp2.firstMatch('blah1'), ['blah1']);
27 shouldBe(regexp2.firstMatch('blah blah blah'), ['blah blah blah']);
28 shouldBe(regexp2.firstMatch('blah\nsecond'), ['blah']);
29 shouldBeNull(regexp2.firstMatch('first\nblah'));
30 shouldBeNull(regexp2.firstMatch('first\nblah\nthird'));
31 shouldBeNull(regexp2.firstMatch('first\nblah2\nblah3'));
32
33 var regexp3 = new RegExp(r".*blah.*$");
34 shouldBeNull(regexp3.firstMatch('test'));
35 shouldBe(regexp3.firstMatch('blah'), ['blah']);
36 shouldBe(regexp3.firstMatch('1blah'), ['1blah']);
37 shouldBe(regexp3.firstMatch('blah1'), ['blah1']);
38 shouldBe(regexp3.firstMatch('blah blah blah'), ['blah blah blah']);
39 shouldBeNull(regexp3.firstMatch('blah\nsecond'));
40 shouldBe(regexp3.firstMatch('first\nblah'), ['blah']);
41 shouldBeNull(regexp3.firstMatch('first\nblah\nthird'));
42 shouldBe(regexp3.firstMatch('first\nblah2\nblah3'), ['blah3']);
43
44 var regexp4 = new RegExp(r"^.*blah.*$");
45 shouldBeNull(regexp4.firstMatch('test'));
46 shouldBe(regexp4.firstMatch('blah'), ['blah']);
47 shouldBe(regexp4.firstMatch('1blah'), ['1blah']);
48 shouldBe(regexp4.firstMatch('blah1'), ['blah1']);
49 shouldBe(regexp4.firstMatch('blah blah blah'), ['blah blah blah']);
50 shouldBeNull(regexp4.firstMatch('blah\nsecond'));
51 shouldBeNull(regexp4.firstMatch('first\nblah'));
52 shouldBeNull(regexp4.firstMatch('first\nblah\nthird'));
53 shouldBeNull(regexp4.firstMatch('first\nblah2\nblah3'));
54
55 var regexp5 = new RegExp(r".*?blah.*");
56 shouldBeNull(regexp5.firstMatch('test'));
57 shouldBe(regexp5.firstMatch('blah'), ['blah']);
58 shouldBe(regexp5.firstMatch('1blah'), ['1blah']);
59 shouldBe(regexp5.firstMatch('blah1'), ['blah1']);
60 shouldBe(regexp5.firstMatch('blah blah blah'), ['blah blah blah']);
61 shouldBe(regexp5.firstMatch('blah\nsecond'), ['blah']);
62 shouldBe(regexp5.firstMatch('first\nblah'), ['blah']);
63 shouldBe(regexp5.firstMatch('first\nblah\nthird'), ['blah']);
64 shouldBe(regexp5.firstMatch('first\nblah2\nblah3'), ['blah2']);
65
66 var regexp6 = new RegExp(r".*blah.*?");
67 shouldBeNull(regexp6.firstMatch('test'));
68 shouldBe(regexp6.firstMatch('blah'), ['blah']);
69 shouldBe(regexp6.firstMatch('1blah'), ['1blah']);
70 shouldBe(regexp6.firstMatch('blah1'), ['blah']);
71 shouldBe(regexp6.firstMatch('blah blah blah'), ['blah blah blah']);
72 shouldBe(regexp6.firstMatch('blah\nsecond'), ['blah']);
73 shouldBe(regexp6.firstMatch('first\nblah'), ['blah']);
74 shouldBe(regexp6.firstMatch('first\nblah\nthird'), ['blah']);
75 shouldBe(regexp6.firstMatch('first\nblah2\nblah3'), ['blah']);
76
77 var regexp7 = new RegExp(r"^.*?blah.*?$");
78 shouldBeNull(regexp7.firstMatch('test'));
79 shouldBe(regexp7.firstMatch('blah'), ['blah']);
80 shouldBe(regexp7.firstMatch('1blah'), ['1blah']);
81 shouldBe(regexp7.firstMatch('blah1'), ['blah1']);
82 shouldBe(regexp7.firstMatch('blah blah blah'), ['blah blah blah']);
83 shouldBeNull(regexp7.firstMatch('blah\nsecond'));
84 shouldBeNull(regexp7.firstMatch('first\nblah'));
85 shouldBeNull(regexp7.firstMatch('first\nblah\nthird'));
86 shouldBeNull(regexp7.firstMatch('first\nblah2\nblah3'));
87
88 var regexp8 = new RegExp(r"^(.*)blah.*$");
89 shouldBeNull(regexp8.firstMatch('test'));
90 shouldBe(regexp8.firstMatch('blah'), ['blah','']);
91 shouldBe(regexp8.firstMatch('1blah'), ['1blah','1']);
92 shouldBe(regexp8.firstMatch('blah1'), ['blah1','']);
93 shouldBe(regexp8.firstMatch('blah blah blah'), ['blah blah blah','blah blah '] );
94 shouldBeNull(regexp8.firstMatch('blah\nsecond'));
95 shouldBeNull(regexp8.firstMatch('first\nblah'));
96 shouldBeNull(regexp8.firstMatch('first\nblah\nthird'));
97 shouldBeNull(regexp8.firstMatch('first\nblah2\nblah3'));
98
99 var regexp9 = new RegExp(r".*blah.*", multiLine: true);
100 shouldBeNull(regexp9.firstMatch('test'));
101 shouldBe(regexp9.firstMatch('blah'), ['blah']);
102 shouldBe(regexp9.firstMatch('1blah'), ['1blah']);
103 shouldBe(regexp9.firstMatch('blah1'), ['blah1']);
104 shouldBe(regexp9.firstMatch('blah blah blah'), ['blah blah blah']);
105 shouldBe(regexp9.firstMatch('blah\nsecond'), ['blah']);
106 shouldBe(regexp9.firstMatch('first\nblah'), ['blah']);
107 shouldBe(regexp9.firstMatch('first\nblah\nthird'), ['blah']);
108 shouldBe(regexp9.firstMatch('first\nblah2\nblah3'), ['blah2']);
109
110 var regexp10 = new RegExp(r"^.*blah.*", multiLine: true);
111 shouldBeNull(regexp10.firstMatch('test'));
112 shouldBe(regexp10.firstMatch('blah'), ['blah']);
113 shouldBe(regexp10.firstMatch('1blah'), ['1blah']);
114 shouldBe(regexp10.firstMatch('blah1'), ['blah1']);
115 shouldBe(regexp10.firstMatch('blah blah blah'), ['blah blah blah']);
116 shouldBe(regexp10.firstMatch('blah\nsecond'), ['blah']);
117 shouldBe(regexp10.firstMatch('first\nblah'), ['blah']);
118 shouldBe(regexp10.firstMatch('first\nblah\nthird'), ['blah']);
119 shouldBe(regexp10.firstMatch('first\nblah2\nblah3'), ['blah2']);
120
121 var regexp11 = new RegExp(r".*(?:blah).*$");
122 shouldBeNull(regexp11.firstMatch('test'));
123 shouldBe(regexp11.firstMatch('blah'), ['blah']);
124 shouldBe(regexp11.firstMatch('1blah'), ['1blah']);
125 shouldBe(regexp11.firstMatch('blah1'), ['blah1']);
126 shouldBe(regexp11.firstMatch('blah blah blah'), ['blah blah blah']);
127 shouldBeNull(regexp11.firstMatch('blah\nsecond'));
128 shouldBe(regexp11.firstMatch('first\nblah'), ['blah']);
129 shouldBeNull(regexp11.firstMatch('first\nblah\nthird'));
130 shouldBe(regexp11.firstMatch('first\nblah2\nblah3'), ['blah3']);
131
132 var regexp12 = new RegExp(r".*(?:blah|buzz|bang).*$");
133 shouldBeNull(regexp12.firstMatch('test'));
134 shouldBe(regexp12.firstMatch('blah'), ['blah']);
135 shouldBe(regexp12.firstMatch('1blah'), ['1blah']);
136 shouldBe(regexp12.firstMatch('blah1'), ['blah1']);
137 shouldBe(regexp12.firstMatch('blah blah blah'), ['blah blah blah']);
138 shouldBeNull(regexp12.firstMatch('blah\nsecond'));
139 shouldBe(regexp12.firstMatch('first\nblah'), ['blah']);
140 shouldBeNull(regexp12.firstMatch('first\nblah\nthird'));
141 shouldBe(regexp12.firstMatch('first\nblah2\nblah3'), ['blah3']);
142
143 var regexp13 = new RegExp(r".*\n\d+.*");
144 shouldBe(regexp13.firstMatch('abc\n123'), ['abc\n123']);
145 }
OLDNEW
« no previous file with comments | « tests/language/regex/constructor_test.dart ('k') | tests/language/regex/early-acid3-86_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698