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

Side by Side Diff: tests/corelib/src/RegExpAllMatchesTest.dart

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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
« no previous file with comments | « tests/corelib/src/QueueTest.dart ('k') | tests/corelib/src/SetTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Dart test program for RegExp.allMatches. 5 // Dart test program for RegExp.allMatches.
6 6
7 class RegExpAllMatchesTest { 7 class RegExpAllMatchesTest {
8 static testIterator() { 8 static testIterator() {
9 var matches = new RegExp("foo").allMatches("foo foo"); 9 var matches = new RegExp("foo").allMatches("foo foo");
10 Iterator it = matches.iterator(); 10 Iterator it = matches.iterator();
(...skipping 20 matching lines...) Expand all
31 31
32 static testForEach() { 32 static testForEach() {
33 var matches = new RegExp("foo").allMatches("foo foo"); 33 var matches = new RegExp("foo").allMatches("foo foo");
34 var str = ""; 34 var str = "";
35 matches.forEach((Match m) { 35 matches.forEach((Match m) {
36 str += m.group(0); 36 str += m.group(0);
37 }); 37 });
38 Expect.equals("foofoo", str); 38 Expect.equals("foofoo", str);
39 } 39 }
40 40
41 static testMap() {
42 var matches = new RegExp("foo?").allMatches("foo fo foo fo");
43 var mapped = matches.map((Match m) => m.group(0) + "bar");
44 Expect.equals(4, mapped.length);
45 var str = "";
46 for (String s in mapped) {
47 str += s;
48 }
49 Expect.equals("foobarfobarfoobarfobar", str);
50 }
51
41 static testFilter() { 52 static testFilter() {
42 var matches = new RegExp("foo?").allMatches("foo fo foo fo"); 53 var matches = new RegExp("foo?").allMatches("foo fo foo fo");
43 var filtered = matches.filter((Match m) { 54 var filtered = matches.filter((Match m) {
44 return m.group(0) == 'foo'; 55 return m.group(0) == 'foo';
45 }); 56 });
46 Expect.equals(2, filtered.length); 57 Expect.equals(2, filtered.length);
47 var str = ""; 58 var str = "";
48 for (Match m in filtered) { 59 for (Match m in filtered) {
49 str += m.group(0); 60 str += m.group(0);
50 } 61 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 static testGetCount() { 95 static testGetCount() {
85 var matches = new RegExp("foo?").allMatches("foo fo foo fo"); 96 var matches = new RegExp("foo?").allMatches("foo fo foo fo");
86 Expect.equals(4, matches.length); 97 Expect.equals(4, matches.length);
87 matches = new RegExp("fooo").allMatches("foo fo foo fo"); 98 matches = new RegExp("fooo").allMatches("foo fo foo fo");
88 Expect.equals(0, matches.length); 99 Expect.equals(0, matches.length);
89 } 100 }
90 101
91 static testMain() { 102 static testMain() {
92 testIterator(); 103 testIterator();
93 testForEach(); 104 testForEach();
105 testMap();
94 testFilter(); 106 testFilter();
95 testEvery(); 107 testEvery();
96 testSome(); 108 testSome();
97 testIsEmpty(); 109 testIsEmpty();
98 testGetCount(); 110 testGetCount();
99 } 111 }
100 } 112 }
101 113
102 main() { 114 main() {
103 RegExpAllMatchesTest.testMain(); 115 RegExpAllMatchesTest.testMain();
104 } 116 }
OLDNEW
« no previous file with comments | « tests/corelib/src/QueueTest.dart ('k') | tests/corelib/src/SetTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698