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

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

Issue 23859008: Convert HashSet, LinkedHashSet to factory methods and custom implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 3 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 library set_test; 5 library set_test;
6 6
7 7
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 import "dart:collection"; 9 import "dart:collection";
10 10
11 void testMain(Set create()) { 11 void testMain(Set create()) {
12 Set set = create(); 12 Set set = create();
13
13 testLength(0, set); 14 testLength(0, set);
14 set.add(1); 15 set.add(1);
15 testLength(1, set); 16 testLength(1, set);
16 Expect.isTrue(set.contains(1)); 17 Expect.isTrue(set.contains(1));
17 18
18 set.add(1); 19 set.add(1);
19 testLength(1, set); 20 testLength(1, set);
20 Expect.isTrue(set.contains(1)); 21 Expect.isTrue(set.contains(1));
21 22
22 set.remove(1); 23 set.remove(1);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 testLength(1, set); 183 testLength(1, set);
183 } 184 }
184 185
185 void testLength(int length, Set set) { 186 void testLength(int length, Set set) {
186 Expect.equals(length, set.length); 187 Expect.equals(length, set.length);
187 (length == 0 ? Expect.isTrue : Expect.isFalse)(set.isEmpty); 188 (length == 0 ? Expect.isTrue : Expect.isFalse)(set.isEmpty);
188 (length != 0 ? Expect.isTrue : Expect.isFalse)(set.isNotEmpty); 189 (length != 0 ? Expect.isTrue : Expect.isFalse)(set.isNotEmpty);
189 } 190 }
190 191
191 main() { 192 main() {
192 testMain(() => new Set());
193 testMain(() => new HashSet()); 193 testMain(() => new HashSet());
194 testMain(() => new LinkedHashSet());
195 testMain(() => new HashSet(equals: identical));
196 testMain(() => new LinkedHashSet(equals: identical));
197 testMain(() => new HashSet(equals: (int a, int b) => a == b || a == -b,
198 hashCode: (int n) => n.hashCode & (-n).hashCode,
199 isValidKey: (n) => n is int));
200 testMain(() => new LinkedHashSet(
201 equals: (int a, int b) => a == b || a == -b,
202 hashCode: (int n) => n.hashCode & (-n).hashCode,
203 isValidKey: (n) => n is int));
194 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698