Index: packages/collection/test/wrapper_test.dart |
diff --git a/packages/collection/test/wrapper_test.dart b/packages/collection/test/wrapper_test.dart |
index e3043a2f322616094f037eb587dc4348bc24d9f9..9067426ce2fc71178c0af65932987fffd7535e7c 100644 |
--- a/packages/collection/test/wrapper_test.dart |
+++ b/packages/collection/test/wrapper_test.dart |
@@ -23,10 +23,8 @@ void testInvocations(Invocation i1, Invocation i2) { |
expect(i1.namedArguments, equals(i2.namedArguments), reason: name); |
} |
-/** |
- * Utility class to record a member access and a member access on a wrapped |
- * object, and compare them for equality. |
- */ |
+/// Utility class to record a member access and a member access on a wrapped |
+/// object, and compare them for equality. |
abstract class Expector { |
getWrappedObject(action(Invocation i)); |
// Hack to test assignment ([]=) because it doesn't return the result |
@@ -35,12 +33,14 @@ abstract class Expector { |
var equals; |
noSuchMethod(Invocation m) => new _Equals(equals = getWrappedObject((m2) { |
- testInvocations(m, m2); |
- })); |
- |
- toString() => new _Equals(equals = getWrappedObject((m2) { |
- testInvocations(TO_STRING_INVOCATION, m2); |
- })); |
+ testInvocations(m, m2); |
+ })); |
+ |
+ // dartanalyzer complains if this method is named `toString()`, since, if it |
+ // truly overrides Object's `toString()`, it should return a String. |
+ asString() => new _Equals(equals = getWrappedObject((m2) { |
+ testInvocations(TO_STRING_INVOCATION, m2); |
+ })); |
} |
// An object with a field called "equals", only introduced into the |
@@ -56,12 +56,13 @@ class SyntheticInvocation implements Invocation { |
static const int SETTER = 0x02; |
final Symbol memberName; |
final List positionalArguments; |
- final Map namedArguments; |
+ final Map<Symbol, dynamic> namedArguments; |
final int _type; |
- const SyntheticInvocation(this.memberName, |
- this.positionalArguments, |
- this.namedArguments, |
- this._type); |
+ const SyntheticInvocation(this.memberName, this.positionalArguments, |
+ this.namedArguments, this._type); |
+ |
+ List<Type> get typeArguments => const <Type>[]; |
+ |
bool get isMethod => _type == METHOD; |
bool get isGetter => _type == GETTER; |
@@ -79,13 +80,12 @@ class NSM { |
} |
const TO_STRING_INVOCATION = const SyntheticInvocation( |
- #toString, const[], const{}, SyntheticInvocation.METHOD); |
+ #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); |
} |
@@ -120,7 +120,6 @@ class QueueExpector extends Expector { |
// Like NSM but implements Map to allow as argument for DelegatingMap. |
class MapNSM extends NSM implements Map { |
MapNSM(action(Invocation i)) : super(action); |
- noSuchMethod(Invocation i) => super.noSuchMethod(i); |
toString() => super.noSuchMethod(TO_STRING_INVOCATION); |
} |
@@ -150,8 +149,10 @@ void main() { |
// expectation (which doesn't have the interface implemented or |
// its default values). |
expect.firstWhere(func1, orElse: null).equals.firstWhere(func1); |
- expect.firstWhere(func1, orElse: func0).equals. |
- firstWhere(func1, orElse: func0); |
+ expect |
+ .firstWhere(func1, orElse: func0) |
+ .equals |
+ .firstWhere(func1, orElse: func0); |
expect.fold(null, func2).equals.fold(null, func2); |
expect.forEach(func1).equals.forEach(func1); |
expect.isEmpty.equals.isEmpty; |
@@ -161,8 +162,10 @@ void main() { |
expect.join("X").equals.join("X"); |
expect.last.equals.last; |
expect.lastWhere(func1, orElse: null).equals.lastWhere(func1); |
- expect.lastWhere(func1, orElse: func0).equals. |
- lastWhere(func1, orElse: func0); |
+ expect |
+ .lastWhere(func1, orElse: func0) |
+ .equals |
+ .lastWhere(func1, orElse: func0); |
expect.length.equals.length; |
expect.map(func1).equals.map(func1); |
expect.reduce(func2).equals.reduce(func2); |
@@ -176,7 +179,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.asString().equals.toString(); |
expect.where(func1).equals.where(func1); |
} |
@@ -262,7 +265,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(); |
+ expect.asString().equals.toString(); |
} |
// Runs tests of Set behavior. |
@@ -338,17 +341,17 @@ void main() { |
test(".lastWhere", () { |
expect(set.lastWhere((element) => element is String), equals("bar")); |
- expect(set.lastWhere((element) => element.startsWith("f")), |
- equals("foo")); |
- expect(() => set.lastWhere((element) => element is int), |
- throwsStateError); |
+ expect( |
+ set.lastWhere((element) => element.startsWith("f")), equals("foo")); |
+ expect( |
+ () => set.lastWhere((element) => element is int), throwsStateError); |
expect(set.lastWhere((element) => element is int, orElse: () => "baz"), |
equals("baz")); |
}); |
test(".map", () { |
- expect(set.map((element) => element.substring(1)), |
- equals(["oo", "ar"])); |
+ expect( |
+ set.map((element) => element.substring(1)), equals(["oo", "ar"])); |
}); |
test(".reduce", () { |
@@ -359,8 +362,7 @@ void main() { |
test(".singleWhere", () { |
expect(() => set.singleWhere((element) => element == "baz"), |
throwsStateError); |
- expect(set.singleWhere((element) => element == "foo"), |
- "foo"); |
+ expect(set.singleWhere((element) => element == "foo"), "foo"); |
expect(() => set.singleWhere((element) => element is String), |
throwsStateError); |
}); |
@@ -376,8 +378,7 @@ void main() { |
equals(["bar"])); |
expect(set.skipWhile((element) => element.startsWith("z")), |
equals(["foo", "bar"])); |
- expect(set.skipWhile((element) => element is String), |
- equals([])); |
+ expect(set.skipWhile((element) => element is String), equals([])); |
}); |
test(".take", () { |
@@ -389,8 +390,7 @@ void main() { |
test(".takeWhile", () { |
expect(set.takeWhile((element) => element.startsWith("f")), |
equals(["foo"])); |
- expect(set.takeWhile((element) => element.startsWith("z")), |
- equals([])); |
+ expect(set.takeWhile((element) => element.startsWith("z")), equals([])); |
expect(set.takeWhile((element) => element is String), |
equals(["foo", "bar"])); |
}); |
@@ -407,11 +407,11 @@ void main() { |
}); |
test(".where", () { |
- expect(set.where((element) => element.startsWith("f")), |
- equals(["foo"])); |
+ expect( |
+ set.where((element) => element.startsWith("f")), equals(["foo"])); |
expect(set.where((element) => element.startsWith("z")), equals([])); |
- expect(set.where((element) => element is String), |
- equals(["foo", "bar"])); |
+ expect( |
+ set.where((element) => element is String), equals(["foo", "bar"])); |
}); |
test(".containsAll", () { |
@@ -531,8 +531,8 @@ void main() { |
setUp(() { |
map = new Map<String, String>(); |
- set = new MapValueSet<String, String>(map, |
- (string) => string.substring(0, 1)); |
+ set = new MapValueSet<String, String>( |
+ map, (string) => string.substring(0, 1)); |
}); |
testTwoElementSet(() { |
@@ -643,8 +643,8 @@ void main() { |
equals: (value1, value2) => |
value1.toLowerCase() == value2.toLowerCase(), |
hashCode: (value) => value.toLowerCase().hashCode); |
- set = new MapValueSet<String, String>(map, |
- (string) => string.substring(0, 1)); |
+ set = new MapValueSet<String, String>( |
+ map, (string) => string.substring(0, 1)); |
map["f"] = "foo"; |
map["B"] = "bar"; |