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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 Expect.identical(ce3, difference.lookup(ce3)); | 355 Expect.identical(ce3, difference.lookup(ce3)); |
356 | 356 |
357 // Difference uses other.contains to check for equality. | 357 // Difference uses other.contains to check for equality. |
358 var set3 = create(identical, identityHashCode, null, identityCompare); | 358 var set3 = create(identical, identityHashCode, null, identityCompare); |
359 set3.add(ce1b); | 359 set3.add(ce1b); |
360 difference = set1.difference(set3); | 360 difference = set1.difference(set3); |
361 testLength(2, difference); // ce1a is not identical to element in set3. | 361 testLength(2, difference); // ce1a is not identical to element in set3. |
362 Expect.identical(ce1a, difference.lookup(ce1a)); | 362 Expect.identical(ce1a, difference.lookup(ce1a)); |
363 Expect.identical(ce2, difference.lookup(ce2)); | 363 Expect.identical(ce2, difference.lookup(ce2)); |
364 | 364 |
365 // Intesection always takes elements from receiver set. | 365 // Intersection always takes elements from receiver set. |
366 var intersection = set1.intersection(set2); | 366 var intersection = set1.intersection(set2); |
367 testLength(1, intersection); | 367 testLength(1, intersection); |
368 Expect.identical(ce1a, intersection.lookup(ce1a)); | 368 Expect.identical(ce1a, intersection.lookup(ce1a)); |
369 | 369 |
370 intersection = set1.intersection(set3); | 370 intersection = set1.intersection(set3); |
371 testLength(0, intersection); | 371 testLength(0, intersection); |
372 } | 372 } |
373 | 373 |
374 // Objects that are equal based on data. | 374 // Objects that are equal based on data. |
375 class CE implements Comparable<CE> { | 375 class CE implements Comparable<CE> { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 541 |
542 testCESetFrom( | 542 testCESetFrom( |
543 (x) => new SplayTreeSet<CE>.from(x, customCompare(20), validKey)); | 543 (x) => new SplayTreeSet<CE>.from(x, customCompare(20), validKey)); |
544 testCESetFrom((x) => new SplayTreeSet<CE>.from(x, identityCompare)); | 544 testCESetFrom((x) => new SplayTreeSet<CE>.from(x, identityCompare)); |
545 | 545 |
546 testASetFrom((x) => new Set<A>.from(x)); | 546 testASetFrom((x) => new Set<A>.from(x)); |
547 testASetFrom((x) => new HashSet<A>.from(x)); | 547 testASetFrom((x) => new HashSet<A>.from(x)); |
548 testASetFrom((x) => new LinkedHashSet<A>.from(x)); | 548 testASetFrom((x) => new LinkedHashSet<A>.from(x)); |
549 testASetFrom((x) => new SplayTreeSet<A>.from(x, identityCompare)); | 549 testASetFrom((x) => new SplayTreeSet<A>.from(x, identityCompare)); |
550 } | 550 } |
OLD | NEW |