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

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

Issue 2985233002: Migrated test block 19 to Dart 2.0. (Closed)
Patch Set: Migrated test block 19 to Dart 2.0. 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 parenthetical assertions.");
30
31 var regex1 = new RegExp(r"(x)(?=\1)x");
32 shouldBe(regex1.firstMatch('xx'), ['xx', 'x']);
33
34 var regex2 = new RegExp(r"(.*?)a(?!(a+)b\2c)\2(.*)");
35 shouldBe(regex2.firstMatch('baaabaac'), ['baaabaac', 'ba', null, 'abaac']);
36
37 var regex3 = new RegExp(r"(?=(a+?))(\1ab)");
38 shouldBe(regex3.firstMatch('aaab'), ['aab', 'a', 'aab']);
39
40 var regex4 = new RegExp(r"(?=(a+?))(\1ab)");
41 shouldBe(regex4.firstMatch('aaab'), ['aab', 'a', 'aab']);
42
43 var regex5 = new RegExp(r"^P([1-6])(?=\1)([1-6])$");
44 shouldBe(regex5.firstMatch('P11'), ['P11', '1', '1']);
45
46 var regex6 = new RegExp(r"(([a-c])b*?\2)*");
47 shouldBe(regex6.firstMatch('ababbbcbc'), ['ababb', 'bb', 'b']);
48
49 var regex7 = new RegExp(r"(x)(?=x)x");
50 shouldBe(regex7.firstMatch('xx'), ['xx', 'x']);
51
52 var regex8 = new RegExp(r"(x)(\1)");
53 shouldBe(regex8.firstMatch('xx'), ['xx', 'x', 'x']);
54
55 var regex9 = new RegExp(r"(x)(?=\1)x");
56 shouldBeNull(regex9.firstMatch('xy'));
57
58 var regex10 = new RegExp(r"(x)(?=x)x");
59 shouldBeNull(regex10.firstMatch('xy'));
60
61 var regex11 = new RegExp(r"(x)(\1)");
62 shouldBeNull(regex11.firstMatch('xy'));
63
64 var regex12 = new RegExp(r"(x)(?=\1)x");
65 shouldBeNull(regex12.firstMatch('x'));
66 shouldBe(regex12.firstMatch('xx'), ['xx', 'x']);
67 shouldBe(regex12.firstMatch('xxy'), ['xx', 'x']);
68
69 var regex13 = new RegExp(r"(x)zzz(?=\1)x");
70 shouldBe(regex13.firstMatch('xzzzx'), ['xzzzx', 'x']);
71 shouldBe(regex13.firstMatch('xzzzxy'), ['xzzzx', 'x']);
72
73 var regex14 = new RegExp(r"(a)\1(?=(b*c))bc");
74 shouldBe(regex14.firstMatch('aabc'), ['aabc', 'a', 'bc']);
75 shouldBe(regex14.firstMatch('aabcx'), ['aabc', 'a', 'bc']);
76
77 var regex15 = new RegExp(r"(a)a(?=(b*c))bc");
78 shouldBe(regex15.firstMatch('aabc'), ['aabc', 'a', 'bc']);
79 shouldBe(regex15.firstMatch('aabcx'), ['aabc', 'a', 'bc']);
80
81 var regex16 = new RegExp(r"a(?=(b*c))bc");
82 shouldBeNull(regex16.firstMatch('ab'));
83 shouldBe(regex16.firstMatch('abc'), ['abc', 'bc']);
84
85 var regex17 = new RegExp(r"(?=((?:ab)*))a");
86 shouldBe(regex17.firstMatch('ab'), ['a', 'ab']);
87 shouldBe(regex17.firstMatch('abc'), ['a', 'ab']);
88
89 var regex18 = new RegExp(r"(?=((?:xx)*))x");
90 shouldBe(regex18.firstMatch('x'), ['x', '']);
91 shouldBe(regex18.firstMatch('xx'), ['x', 'xx']);
92 shouldBe(regex18.firstMatch('xxx'), ['x', 'xx']);
93
94 var regex19 = new RegExp(r"(?=((xx)*))x");
95 shouldBe(regex19.firstMatch('x'), ['x', '', null]);
96 shouldBe(regex19.firstMatch('xx'), ['x', 'xx', 'xx']);
97 shouldBe(regex19.firstMatch('xxx'), ['x', 'xx', 'xx']);
98
99 var regex20 = new RegExp(r"(?=(xx))+x");
100 shouldBeNull(regex20.firstMatch('x'));
101 shouldBe(regex20.firstMatch('xx'), ['x', 'xx']);
102 shouldBe(regex20.firstMatch('xxx'), ['x', 'xx']);
103
104 var regex21 = new RegExp(r"(?=a+b)aab");
105 shouldBe(regex21.firstMatch('aab'), ['aab']);
106
107 var regex22 = new RegExp(
108 r"(?!(u|m{0,}g+)u{1,}|2{2,}!1%n|(?!K|(?=y)|(?=ip))+?)(?=(?=(((?:7))*?)*?)) p",
109 multiLine: true);
110 shouldBeNull(regex22.firstMatch('55up'));
111
112 var regex23 = new RegExp(r"(?=(a)b|c?)()*d");
113 shouldBeNull(regex23.firstMatch('ax'));
114
115 var regex24 = new RegExp(r"(?=a|b?)c");
116 shouldBeNull(regex24.firstMatch('x'));
117 }
OLDNEW
« no previous file with comments | « tests/corelib/regexp/ascii-regexp-subject_test.dart ('k') | tests/corelib/regexp/backreferences_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698