Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Unified Diff: pkg/collection/test/wrapper_test.dart

Issue 141703009: Add toString to delegating collections in package:collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/collection/lib/wrappers.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/collection/test/wrapper_test.dart
diff --git a/pkg/collection/test/wrapper_test.dart b/pkg/collection/test/wrapper_test.dart
index 875a70aedae241df8b34ca2adc5fc588f51c36ab..86a0ddd1b349621550f2afcc2d647f340ee61b3d 100644
--- a/pkg/collection/test/wrapper_test.dart
+++ b/pkg/collection/test/wrapper_test.dart
@@ -37,6 +37,10 @@ abstract class Expector {
noSuchMethod(Invocation m) => new _Equals(equals = getWrappedObject((m2) {
testInvocations(m, m2);
}));
+
+ toString() => new _Equals(equals = getWrappedObject((m2) {
+ testInvocations(TO_STRING_INVOCATION, m2);
+ }));
}
// An object with a field called "equals", only introduced into the
@@ -46,6 +50,27 @@ class _Equals {
_Equals(this.equals);
}
+class SyntheticInvocation implements Invocation {
+ static const int METHOD = 0x00;
+ static const int GETTER = 0x01;
+ static const int SETTER = 0x02;
+ final Symbol memberName;
+ final List positionalArguments;
+ final Map namedArguments;
+ final int _type;
+ const SyntheticInvocation(this.memberName,
+ this.positionalArguments,
+ this.namedArguments,
+ this._type);
+ bool get isMethod => _type == METHOD;
+
+ bool get isGetter => _type == GETTER;
+
+ bool get isSetter => _type == SETTER;
+
+ bool get isAccessor => isGetter || isSetter;
+}
+
// Parameterization of noSuchMethod.
class NSM {
Function _action;
@@ -53,11 +78,15 @@ class NSM {
noSuchMethod(Invocation i) => _action(i);
}
+const TO_STRING_INVOCATION = const SyntheticInvocation(
+ #toString, const[], const{}, SyntheticInvocation.METHOD);
+
// LikeNSM, but has types Iterable, Set and List to allow it as
// argument to DelegatingIterable/Set/List.
class IterableNSM extends NSM implements Iterable, Set, List, Queue {
IterableNSM(action(Invocation i)) : super(action);
noSuchMethod(Invocation i) => super.noSuchMethod(i); // Silence warnings
+ toString() => super.noSuchMethod(TO_STRING_INVOCATION);
}
// Expector that wraps in DelegatingIterable.
@@ -92,6 +121,7 @@ class QueueExpector extends Expector {
class MapNSM extends NSM implements Map {
MapNSM(action(Invocation i)) : super(action);
noSuchMethod(Invocation i) => super.noSuchMethod(i);
+ toString() => super.noSuchMethod(TO_STRING_INVOCATION);
}
// Expector that wraps in DelegatingMap.
@@ -146,6 +176,7 @@ void main() {
expect.toList(growable: true).equals.toList(growable: true);
expect.toList(growable: false).equals.toList(growable: false);
expect.toSet().equals.toSet();
+ expect.toString().equals.toString();
expect.where(func1).equals.where(func1);
}
@@ -231,6 +262,7 @@ void main() {
expect.putIfAbsent(val, func0).equals.putIfAbsent(val, func0);
expect.remove(val).equals.remove(val);
expect.values.equals.values;
+ expect.toString().equals.toString();
}
test("Iterable", () {
« no previous file with comments | « pkg/collection/lib/wrappers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698