| 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 wrapper utilities. | 5 /// Tests wrapper utilities. |
| 6 | 6 |
| 7 import "dart:collection"; | 7 import "dart:collection"; |
| 8 import "package:collection/collection.dart"; | 8 import "package:collection/collection.dart"; |
| 9 import "package:test/test.dart"; | 9 import "package:test/test.dart"; |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 noSuchMethod(Invocation i) => _action(i); | 78 noSuchMethod(Invocation i) => _action(i); |
| 79 } | 79 } |
| 80 | 80 |
| 81 const TO_STRING_INVOCATION = const SyntheticInvocation( | 81 const TO_STRING_INVOCATION = const SyntheticInvocation( |
| 82 #toString, const[], const{}, SyntheticInvocation.METHOD); | 82 #toString, const[], const{}, SyntheticInvocation.METHOD); |
| 83 | 83 |
| 84 // LikeNSM, but has types Iterable, Set and List to allow it as | 84 // LikeNSM, but has types Iterable, Set and List to allow it as |
| 85 // argument to DelegatingIterable/Set/List. | 85 // argument to DelegatingIterable/Set/List. |
| 86 class IterableNSM extends NSM implements Iterable, Set, List, Queue { | 86 class IterableNSM extends NSM implements Iterable, Set, List, Queue { |
| 87 IterableNSM(action(Invocation i)) : super(action); | 87 IterableNSM(action(Invocation i)) : super(action); |
| 88 noSuchMethod(Invocation i) => super.noSuchMethod(i); // Silence warnings | |
| 89 toString() => super.noSuchMethod(TO_STRING_INVOCATION); | 88 toString() => super.noSuchMethod(TO_STRING_INVOCATION); |
| 90 } | 89 } |
| 91 | 90 |
| 92 // Expector that wraps in DelegatingIterable. | 91 // Expector that wraps in DelegatingIterable. |
| 93 class IterableExpector extends Expector { | 92 class IterableExpector extends Expector { |
| 94 getWrappedObject(void action(Invocation i)) { | 93 getWrappedObject(void action(Invocation i)) { |
| 95 return new DelegatingIterable(new IterableNSM(action)); | 94 return new DelegatingIterable(new IterableNSM(action)); |
| 96 } | 95 } |
| 97 } | 96 } |
| 98 | 97 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 113 // Expector that wraps in DelegatingSet. | 112 // Expector that wraps in DelegatingSet. |
| 114 class QueueExpector extends Expector { | 113 class QueueExpector extends Expector { |
| 115 getWrappedObject(void action(Invocation i)) { | 114 getWrappedObject(void action(Invocation i)) { |
| 116 return new DelegatingQueue(new IterableNSM(action)); | 115 return new DelegatingQueue(new IterableNSM(action)); |
| 117 } | 116 } |
| 118 } | 117 } |
| 119 | 118 |
| 120 // Like NSM but implements Map to allow as argument for DelegatingMap. | 119 // Like NSM but implements Map to allow as argument for DelegatingMap. |
| 121 class MapNSM extends NSM implements Map { | 120 class MapNSM extends NSM implements Map { |
| 122 MapNSM(action(Invocation i)) : super(action); | 121 MapNSM(action(Invocation i)) : super(action); |
| 123 noSuchMethod(Invocation i) => super.noSuchMethod(i); | |
| 124 toString() => super.noSuchMethod(TO_STRING_INVOCATION); | 122 toString() => super.noSuchMethod(TO_STRING_INVOCATION); |
| 125 } | 123 } |
| 126 | 124 |
| 127 // Expector that wraps in DelegatingMap. | 125 // Expector that wraps in DelegatingMap. |
| 128 class MapExpector extends Expector { | 126 class MapExpector extends Expector { |
| 129 getWrappedObject(void action(Invocation i)) { | 127 getWrappedObject(void action(Invocation i)) { |
| 130 return new DelegatingMap(new MapNSM(action)); | 128 return new DelegatingMap(new MapNSM(action)); |
| 131 } | 129 } |
| 132 } | 130 } |
| 133 | 131 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 653 |
| 656 test(".retainWhere", () { | 654 test(".retainWhere", () { |
| 657 map["f"] = "foo"; | 655 map["f"] = "foo"; |
| 658 map["b"] = "bar"; | 656 map["b"] = "bar"; |
| 659 map["q"] = "qoo"; | 657 map["q"] = "qoo"; |
| 660 set.retainWhere((element) => element.endsWith("o")); | 658 set.retainWhere((element) => element.endsWith("o")); |
| 661 expect(map, equals({"f": "foo", "q": "qoo"})); | 659 expect(map, equals({"f": "foo", "q": "qoo"})); |
| 662 }); | 660 }); |
| 663 }); | 661 }); |
| 664 } | 662 } |
| OLD | NEW |