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

Side by Side Diff: tests/corelib/collection_removes_test.dart

Issue 12537009: Rename XMatching to XWhere. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge and rebuild dom libraries. Created 7 years, 9 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
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 testRemove(Collection base) { 5 testRemove(Collection base) {
6 int length = base.length; 6 int length = base.length;
7 for (int i = 0; i < length; i++) { 7 for (int i = 0; i < length; i++) {
8 Expect.isFalse(base.isEmpty); 8 Expect.isFalse(base.isEmpty);
9 base.remove(base.first); 9 base.remove(base.first);
10 } 10 }
(...skipping 27 matching lines...) Expand all
38 String name = "$base.retainAll($retains) -> $retained"; 38 String name = "$base.retainAll($retains) -> $retained";
39 base.retainAll(retains); 39 base.retainAll(retains);
40 for (var value in base) { 40 for (var value in base) {
41 Expect.isTrue(retains.contains(value), "$name: Found $value"); 41 Expect.isTrue(retains.contains(value), "$name: Found $value");
42 } 42 }
43 for (var value in retained) { 43 for (var value in retained) {
44 Expect.isTrue(base.contains(value), "$name: Found $value"); 44 Expect.isTrue(base.contains(value), "$name: Found $value");
45 } 45 }
46 } 46 }
47 47
48 testRemoveMatching(Collection base, bool test(value)) { 48 testRemoveWhere(Collection base, bool test(value)) {
49 Set retained = new Set(); 49 Set retained = new Set();
50 for (var element in base) { 50 for (var element in base) {
51 if (!test(element)) { 51 if (!test(element)) {
52 retained.add(element); 52 retained.add(element);
53 } 53 }
54 } 54 }
55 String name = "$base.removeMatching(...) -> $retained"; 55 String name = "$base.removeWhere(...) -> $retained";
56 base.removeMatching(test); 56 base.removeWhere(test);
57 for (var value in base) { 57 for (var value in base) {
58 Expect.isFalse(test(value), "$name: Found $value"); 58 Expect.isFalse(test(value), "$name: Found $value");
59 } 59 }
60 for (var value in retained) { 60 for (var value in retained) {
61 Expect.isTrue(base.contains(value), "$name: Found $value"); 61 Expect.isTrue(base.contains(value), "$name: Found $value");
62 } 62 }
63 } 63 }
64 64
65 testRetainMatching(Collection base, bool test(value)) { 65 testRetainWhere(Collection base, bool test(value)) {
66 Set retained = new Set(); 66 Set retained = new Set();
67 for (var element in base) { 67 for (var element in base) {
68 if (test(element)) { 68 if (test(element)) {
69 retained.add(element); 69 retained.add(element);
70 } 70 }
71 } 71 }
72 String name = "$base.retainMatching(...) -> $retained"; 72 String name = "$base.retainWhere(...) -> $retained";
73 base.retainMatching(test); 73 base.retainWhere(test);
74 for (var value in base) { 74 for (var value in base) {
75 Expect.isTrue(test(value), "$name: Found $value"); 75 Expect.isTrue(test(value), "$name: Found $value");
76 } 76 }
77 for (var value in retained) { 77 for (var value in retained) {
78 Expect.isTrue(base.contains(value), "$name: Found $value"); 78 Expect.isTrue(base.contains(value), "$name: Found $value");
79 } 79 }
80 } 80 }
81 81
82 void main() { 82 void main() {
83 var collections = [ 83 var collections = [
84 [], [1], [2], [1, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 84 [], [1], [2], [1, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
85 [1, 3, 5, 7, 9], [2, 4, 6, 8, 10] 85 [1, 3, 5, 7, 9], [2, 4, 6, 8, 10]
86 ]; 86 ];
87 for (var base in collections) { 87 for (var base in collections) {
88 for (var delta in collections) { 88 for (var delta in collections) {
89 testRemove(base.toList()); 89 testRemove(base.toList());
90 testRemove(base.toSet()); 90 testRemove(base.toSet());
91 91
92 var deltaSet = delta.toSet(); 92 var deltaSet = delta.toSet();
93 testRemoveAll(base.toList(), delta); 93 testRemoveAll(base.toList(), delta);
94 testRemoveAll(base.toList(), deltaSet); 94 testRemoveAll(base.toList(), deltaSet);
95 testRetainAll(base.toList(), delta); 95 testRetainAll(base.toList(), delta);
96 testRetainAll(base.toList(), deltaSet); 96 testRetainAll(base.toList(), deltaSet);
97 testRemoveMatching(base.toList(), deltaSet.contains); 97 testRemoveWhere(base.toList(), deltaSet.contains);
98 testRetainMatching(base.toList(), 98 testRetainWhere(base.toList(),
99 (e) => !deltaSet.contains(e)); 99 (e) => !deltaSet.contains(e));
100 100
101 testRemoveAll(base.toSet(), delta); 101 testRemoveAll(base.toSet(), delta);
102 testRemoveAll(base.toSet(), deltaSet); 102 testRemoveAll(base.toSet(), deltaSet);
103 testRetainAll(base.toSet(), delta); 103 testRetainAll(base.toSet(), delta);
104 testRetainAll(base.toSet(), deltaSet); 104 testRetainAll(base.toSet(), deltaSet);
105 testRemoveMatching(base.toSet(), deltaSet.contains); 105 testRemoveWhere(base.toSet(), deltaSet.contains);
106 testRetainMatching(base.toSet(), (e) => !deltaSet.contains(e)); 106 testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e));
107 } 107 }
108 } 108 }
109 } 109 }
110 110
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tests/corelib/iterable_first_matching_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698