OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Tests of hash set behavior, with focus in iteration and concurrent | 5 // Tests of hash set behavior, with focus in iteration and concurrent |
6 // modification errors. | 6 // modification errors. |
7 | 7 |
8 library hash_map2_test; | 8 library hash_map2_test; |
9 import "package:expect/expect.dart"; | |
10 import 'dart:collection'; | 9 import 'dart:collection'; |
11 | 10 |
12 testSet(Set newSet(), Set newSetFrom(Set from)) { | 11 testSet(Set newSet(), Set newSetFrom(Set from)) { |
13 Set gen(int from, int to) => | 12 Set gen(int from, int to) => |
14 new Set.from(new Iterable.generate(to - from, (n) => n + from)); | 13 new Set.from(new Iterable.generate(to - from, (n) => n + from)); |
15 | 14 |
16 bool odd(int n) => (n & 1) == 1; | 15 bool odd(int n) => (n & 1) == 1; |
17 bool even(int n) => (n & 1) == 0; | 16 bool even(int n) => (n & 1) == 0; |
18 | 17 |
19 { // Test growing to largish capacity. | 18 { // Test growing to largish capacity. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 197 |
199 class BadHashCode { | 198 class BadHashCode { |
200 static int idCounter = 0; | 199 static int idCounter = 0; |
201 final int id; | 200 final int id; |
202 BadHashCode() : id = idCounter++; | 201 BadHashCode() : id = idCounter++; |
203 int get hashCode => 42; | 202 int get hashCode => 42; |
204 // operator == is identity. | 203 // operator == is identity. |
205 // Can't make a bad compareTo that isn't invalid. | 204 // Can't make a bad compareTo that isn't invalid. |
206 int compareTo(BadHashCode other) => id - other.id; | 205 int compareTo(BadHashCode other) => id - other.id; |
207 } | 206 } |
OLD | NEW |