| 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 // VMOptions= | 5 // VMOptions= |
| 6 | 6 |
| 7 // Tests of hash set behavior, with focus in iteration and concurrent | 7 // Tests of hash set behavior, with focus in iteration and concurrent |
| 8 // modification errors. | 8 // modification errors. |
| 9 | 9 |
| 10 library hash_map2_test; | 10 library hash_map2_test; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 Expect.identical(1, set.lookup(1.0)); | 268 Expect.identical(1, set.lookup(1.0)); |
| 269 set.add(-0.0); | 269 set.add(-0.0); |
| 270 Expect.identical(-0.0, set.lookup(0.0)); | 270 Expect.identical(-0.0, set.lookup(0.0)); |
| 271 } | 271 } |
| 272 | 272 |
| 273 { | 273 { |
| 274 // Test special hash codes | 274 // Test special hash codes |
| 275 Set set = newSet(); | 275 Set set = newSet(); |
| 276 List keys = []; | 276 List keys = []; |
| 277 // Powers of two | 277 // Powers of two |
| 278 for (int i = 65; i >= 2; --i) { | 278 for (int i = 63; i >= 2; --i) { |
| 279 keys.add(new Mutable(math.pow(2, i))); | 279 keys.add(new Mutable(math.pow(2, i))); |
| 280 } | 280 } |
| 281 for (var key in keys) { | 281 for (var key in keys) { |
| 282 Expect.isTrue(set.add(key)); | 282 Expect.isTrue(set.add(key)); |
| 283 } | 283 } |
| 284 for (var key in keys) { | 284 for (var key in keys) { |
| 285 Expect.isTrue(set.contains(key)); | 285 Expect.isTrue(set.contains(key)); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 } | 288 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 // Can't make a bad compareTo that isn't invalid. | 354 // Can't make a bad compareTo that isn't invalid. |
| 355 int compareTo(BadHashCode other) => id - other.id; | 355 int compareTo(BadHashCode other) => id - other.id; |
| 356 } | 356 } |
| 357 | 357 |
| 358 class Mutable { | 358 class Mutable { |
| 359 int id; | 359 int id; |
| 360 Mutable(this.id); | 360 Mutable(this.id); |
| 361 int get hashCode => id; | 361 int get hashCode => id; |
| 362 bool operator ==(other) => other is Mutable && id == other.id; | 362 bool operator ==(other) => other is Mutable && id == other.id; |
| 363 } | 363 } |
| OLD | NEW |