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

Side by Side Diff: tests/corelib/regexp/dotstar_test.dart

Issue 2989863002: Migrated test block 19 to Dart 2.0. (Closed)
Patch Set: Created 3 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. All rights reserved.
2 // Copyright 2013 the V8 project authors. All rights reserved.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions
7 // are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
18 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
21 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25 import 'v8_regexp_utils.dart';
26 import 'package:expect/expect.dart';
27
28 void main() {
29 description("This page tests handling of parentheses subexpressions.");
30
31 var regexp1 = new RegExp(r".*blah.*");
32 shouldBeNull(regexp1.firstMatch('test'));
33 shouldBe(regexp1.firstMatch('blah'), ['blah']);
34 shouldBe(regexp1.firstMatch('1blah'), ['1blah']);
35 shouldBe(regexp1.firstMatch('blah1'), ['blah1']);
36 shouldBe(regexp1.firstMatch('blah blah blah'), ['blah blah blah']);
37 shouldBe(regexp1.firstMatch('blah\nsecond'), ['blah']);
38 shouldBe(regexp1.firstMatch('first\nblah'), ['blah']);
39 shouldBe(regexp1.firstMatch('first\nblah\nthird'), ['blah']);
40 shouldBe(regexp1.firstMatch('first\nblah2\nblah3'), ['blah2']);
41
42 var regexp2 = new RegExp(r"^.*blah.*");
43 shouldBeNull(regexp2.firstMatch('test'));
44 shouldBe(regexp2.firstMatch('blah'), ['blah']);
45 shouldBe(regexp2.firstMatch('1blah'), ['1blah']);
46 shouldBe(regexp2.firstMatch('blah1'), ['blah1']);
47 shouldBe(regexp2.firstMatch('blah blah blah'), ['blah blah blah']);
48 shouldBe(regexp2.firstMatch('blah\nsecond'), ['blah']);
49 shouldBeNull(regexp2.firstMatch('first\nblah'));
50 shouldBeNull(regexp2.firstMatch('first\nblah\nthird'));
51 shouldBeNull(regexp2.firstMatch('first\nblah2\nblah3'));
52
53 var regexp3 = new RegExp(r".*blah.*$");
54 shouldBeNull(regexp3.firstMatch('test'));
55 shouldBe(regexp3.firstMatch('blah'), ['blah']);
56 shouldBe(regexp3.firstMatch('1blah'), ['1blah']);
57 shouldBe(regexp3.firstMatch('blah1'), ['blah1']);
58 shouldBe(regexp3.firstMatch('blah blah blah'), ['blah blah blah']);
59 shouldBeNull(regexp3.firstMatch('blah\nsecond'));
60 shouldBe(regexp3.firstMatch('first\nblah'), ['blah']);
61 shouldBeNull(regexp3.firstMatch('first\nblah\nthird'));
62 shouldBe(regexp3.firstMatch('first\nblah2\nblah3'), ['blah3']);
63
64 var regexp4 = new RegExp(r"^.*blah.*$");
65 shouldBeNull(regexp4.firstMatch('test'));
66 shouldBe(regexp4.firstMatch('blah'), ['blah']);
67 shouldBe(regexp4.firstMatch('1blah'), ['1blah']);
68 shouldBe(regexp4.firstMatch('blah1'), ['blah1']);
69 shouldBe(regexp4.firstMatch('blah blah blah'), ['blah blah blah']);
70 shouldBeNull(regexp4.firstMatch('blah\nsecond'));
71 shouldBeNull(regexp4.firstMatch('first\nblah'));
72 shouldBeNull(regexp4.firstMatch('first\nblah\nthird'));
73 shouldBeNull(regexp4.firstMatch('first\nblah2\nblah3'));
74
75 var regexp5 = new RegExp(r".*?blah.*");
76 shouldBeNull(regexp5.firstMatch('test'));
77 shouldBe(regexp5.firstMatch('blah'), ['blah']);
78 shouldBe(regexp5.firstMatch('1blah'), ['1blah']);
79 shouldBe(regexp5.firstMatch('blah1'), ['blah1']);
80 shouldBe(regexp5.firstMatch('blah blah blah'), ['blah blah blah']);
81 shouldBe(regexp5.firstMatch('blah\nsecond'), ['blah']);
82 shouldBe(regexp5.firstMatch('first\nblah'), ['blah']);
83 shouldBe(regexp5.firstMatch('first\nblah\nthird'), ['blah']);
84 shouldBe(regexp5.firstMatch('first\nblah2\nblah3'), ['blah2']);
85
86 var regexp6 = new RegExp(r".*blah.*?");
87 shouldBeNull(regexp6.firstMatch('test'));
88 shouldBe(regexp6.firstMatch('blah'), ['blah']);
89 shouldBe(regexp6.firstMatch('1blah'), ['1blah']);
90 shouldBe(regexp6.firstMatch('blah1'), ['blah']);
91 shouldBe(regexp6.firstMatch('blah blah blah'), ['blah blah blah']);
92 shouldBe(regexp6.firstMatch('blah\nsecond'), ['blah']);
93 shouldBe(regexp6.firstMatch('first\nblah'), ['blah']);
94 shouldBe(regexp6.firstMatch('first\nblah\nthird'), ['blah']);
95 shouldBe(regexp6.firstMatch('first\nblah2\nblah3'), ['blah']);
96
97 var regexp7 = new RegExp(r"^.*?blah.*?$");
98 shouldBeNull(regexp7.firstMatch('test'));
99 shouldBe(regexp7.firstMatch('blah'), ['blah']);
100 shouldBe(regexp7.firstMatch('1blah'), ['1blah']);
101 shouldBe(regexp7.firstMatch('blah1'), ['blah1']);
102 shouldBe(regexp7.firstMatch('blah blah blah'), ['blah blah blah']);
103 shouldBeNull(regexp7.firstMatch('blah\nsecond'));
104 shouldBeNull(regexp7.firstMatch('first\nblah'));
105 shouldBeNull(regexp7.firstMatch('first\nblah\nthird'));
106 shouldBeNull(regexp7.firstMatch('first\nblah2\nblah3'));
107
108 var regexp8 = new RegExp(r"^(.*)blah.*$");
109 shouldBeNull(regexp8.firstMatch('test'));
110 shouldBe(regexp8.firstMatch('blah'), ['blah', '']);
111 shouldBe(regexp8.firstMatch('1blah'), ['1blah', '1']);
112 shouldBe(regexp8.firstMatch('blah1'), ['blah1', '']);
113 shouldBe(
114 regexp8.firstMatch('blah blah blah'), ['blah blah blah', 'blah blah ']);
115 shouldBeNull(regexp8.firstMatch('blah\nsecond'));
116 shouldBeNull(regexp8.firstMatch('first\nblah'));
117 shouldBeNull(regexp8.firstMatch('first\nblah\nthird'));
118 shouldBeNull(regexp8.firstMatch('first\nblah2\nblah3'));
119
120 var regexp9 = new RegExp(r".*blah.*", multiLine: true);
121 shouldBeNull(regexp9.firstMatch('test'));
122 shouldBe(regexp9.firstMatch('blah'), ['blah']);
123 shouldBe(regexp9.firstMatch('1blah'), ['1blah']);
124 shouldBe(regexp9.firstMatch('blah1'), ['blah1']);
125 shouldBe(regexp9.firstMatch('blah blah blah'), ['blah blah blah']);
126 shouldBe(regexp9.firstMatch('blah\nsecond'), ['blah']);
127 shouldBe(regexp9.firstMatch('first\nblah'), ['blah']);
128 shouldBe(regexp9.firstMatch('first\nblah\nthird'), ['blah']);
129 shouldBe(regexp9.firstMatch('first\nblah2\nblah3'), ['blah2']);
130
131 var regexp10 = new RegExp(r"^.*blah.*", multiLine: true);
132 shouldBeNull(regexp10.firstMatch('test'));
133 shouldBe(regexp10.firstMatch('blah'), ['blah']);
134 shouldBe(regexp10.firstMatch('1blah'), ['1blah']);
135 shouldBe(regexp10.firstMatch('blah1'), ['blah1']);
136 shouldBe(regexp10.firstMatch('blah blah blah'), ['blah blah blah']);
137 shouldBe(regexp10.firstMatch('blah\nsecond'), ['blah']);
138 shouldBe(regexp10.firstMatch('first\nblah'), ['blah']);
139 shouldBe(regexp10.firstMatch('first\nblah\nthird'), ['blah']);
140 shouldBe(regexp10.firstMatch('first\nblah2\nblah3'), ['blah2']);
141
142 var regexp11 = new RegExp(r".*(?:blah).*$");
143 shouldBeNull(regexp11.firstMatch('test'));
144 shouldBe(regexp11.firstMatch('blah'), ['blah']);
145 shouldBe(regexp11.firstMatch('1blah'), ['1blah']);
146 shouldBe(regexp11.firstMatch('blah1'), ['blah1']);
147 shouldBe(regexp11.firstMatch('blah blah blah'), ['blah blah blah']);
148 shouldBeNull(regexp11.firstMatch('blah\nsecond'));
149 shouldBe(regexp11.firstMatch('first\nblah'), ['blah']);
150 shouldBeNull(regexp11.firstMatch('first\nblah\nthird'));
151 shouldBe(regexp11.firstMatch('first\nblah2\nblah3'), ['blah3']);
152
153 var regexp12 = new RegExp(r".*(?:blah|buzz|bang).*$");
154 shouldBeNull(regexp12.firstMatch('test'));
155 shouldBe(regexp12.firstMatch('blah'), ['blah']);
156 shouldBe(regexp12.firstMatch('1blah'), ['1blah']);
157 shouldBe(regexp12.firstMatch('blah1'), ['blah1']);
158 shouldBe(regexp12.firstMatch('blah blah blah'), ['blah blah blah']);
159 shouldBeNull(regexp12.firstMatch('blah\nsecond'));
160 shouldBe(regexp12.firstMatch('first\nblah'), ['blah']);
161 shouldBeNull(regexp12.firstMatch('first\nblah\nthird'));
162 shouldBe(regexp12.firstMatch('first\nblah2\nblah3'), ['blah3']);
163
164 var regexp13 = new RegExp(r".*\n\d+.*");
165 shouldBe(regexp13.firstMatch('abc\n123'), ['abc\n123']);
166 }
OLDNEW
« no previous file with comments | « tests/corelib/regexp/default_arguments_test.dart ('k') | tests/corelib/regexp/early-acid3-86_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698