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

Unified Diff: tests/corelib/src/SetTest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/corelib/src/RegExpAllMatchesTest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/src/SetTest.dart
===================================================================
--- tests/corelib/src/SetTest.dart (revision 3161)
+++ tests/corelib/src/SetTest.dart (working copy)
@@ -46,19 +46,48 @@
Expect.equals(true, set.isSubsetOf(set));
Expect.equals(true, set.containsAll(set));
+ // Test Set.map.
+ testMap(int val) {
+ return val * val;
+ }
+
+ Set mapped = set.map(testMap);
+ Expect.equals(10, mapped.length);
+
+ Expect.equals(true, mapped.contains(0));
+ Expect.equals(true, mapped.contains(1));
+ Expect.equals(true, mapped.contains(4));
+ Expect.equals(true, mapped.contains(9));
+ Expect.equals(true, mapped.contains(16));
+ Expect.equals(true, mapped.contains(25));
+ Expect.equals(true, mapped.contains(36));
+ Expect.equals(true, mapped.contains(49));
+ Expect.equals(true, mapped.contains(64));
+ Expect.equals(true, mapped.contains(81));
+
+ sum = 0;
+ set.forEach(testForEach);
+ Expect.equals(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1, sum);
+
+ sum = 0;
+
+ mapped.forEach(testForEach);
+ Expect.equals(1 + 2 + 5 + 10 + 17 + 26 + 37 + 50 + 65 + 82, sum);
+
// Test Set.filter.
testFilter(int val) {
return val.isEven();
}
Set filtered = set.filter(testFilter);
+
Expect.equals(5, filtered.length);
- Expect.equals(true, set.contains(0));
- Expect.equals(true, set.contains(2));
- Expect.equals(true, set.contains(4));
- Expect.equals(true, set.contains(6));
- Expect.equals(true, set.contains(8));
+ Expect.equals(true, filtered.contains(0));
+ Expect.equals(true, filtered.contains(2));
+ Expect.equals(true, filtered.contains(4));
+ Expect.equals(true, filtered.contains(6));
+ Expect.equals(true, filtered.contains(8));
sum = 0;
filtered.forEach(testForEach);
« no previous file with comments | « tests/corelib/src/RegExpAllMatchesTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698