| OLD | NEW |
| 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 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import "dart:collection"; | 8 import "dart:collection"; |
| 9 | 9 |
| 10 void testMain(Set create()) { | 10 void testMain(Set create()) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 Expect.identical(ce3, difference.lookup(ce3)); | 346 Expect.identical(ce3, difference.lookup(ce3)); |
| 347 | 347 |
| 348 // Difference uses other.contains to check for equality. | 348 // Difference uses other.contains to check for equality. |
| 349 var set3 = create(identical, identityHashCode, null, identityCompare); | 349 var set3 = create(identical, identityHashCode, null, identityCompare); |
| 350 set3.add(ce1b); | 350 set3.add(ce1b); |
| 351 difference = set1.difference(set3); | 351 difference = set1.difference(set3); |
| 352 testLength(2, difference); // ce1a is not identical to element in set3. | 352 testLength(2, difference); // ce1a is not identical to element in set3. |
| 353 Expect.identical(ce1a, difference.lookup(ce1a)); | 353 Expect.identical(ce1a, difference.lookup(ce1a)); |
| 354 Expect.identical(ce2, difference.lookup(ce2)); | 354 Expect.identical(ce2, difference.lookup(ce2)); |
| 355 | 355 |
| 356 // Intesection always takes elements from receiver set. | 356 // Intersection always takes elements from receiver set. |
| 357 var intersection = set1.intersection(set2); | 357 var intersection = set1.intersection(set2); |
| 358 testLength(1, intersection); | 358 testLength(1, intersection); |
| 359 Expect.identical(ce1a, intersection.lookup(ce1a)); | 359 Expect.identical(ce1a, intersection.lookup(ce1a)); |
| 360 | 360 |
| 361 intersection = set1.intersection(set3); | 361 intersection = set1.intersection(set3); |
| 362 testLength(0, intersection); | 362 testLength(0, intersection); |
| 363 } | 363 } |
| 364 | 364 |
| 365 // Objects that are equal based on data. | 365 // Objects that are equal based on data. |
| 366 class CE implements Comparable<CE> { | 366 class CE implements Comparable<CE> { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 536 |
| 537 testCESetFrom( | 537 testCESetFrom( |
| 538 (x) => new SplayTreeSet<CE>.from(x, customCompare(20), validKey)); | 538 (x) => new SplayTreeSet<CE>.from(x, customCompare(20), validKey)); |
| 539 testCESetFrom((x) => new SplayTreeSet<CE>.from(x, identityCompare)); | 539 testCESetFrom((x) => new SplayTreeSet<CE>.from(x, identityCompare)); |
| 540 | 540 |
| 541 testASetFrom((x) => new Set<A>.from(x)); | 541 testASetFrom((x) => new Set<A>.from(x)); |
| 542 testASetFrom((x) => new HashSet<A>.from(x)); | 542 testASetFrom((x) => new HashSet<A>.from(x)); |
| 543 testASetFrom((x) => new LinkedHashSet<A>.from(x)); | 543 testASetFrom((x) => new LinkedHashSet<A>.from(x)); |
| 544 testASetFrom((x) => new SplayTreeSet<A>.from(x, identityCompare)); | 544 testASetFrom((x) => new SplayTreeSet<A>.from(x, identityCompare)); |
| 545 } | 545 } |
| OLD | NEW |