Merge pull request #411 from dart-lang/0.11.x-strong
Fix all strong mode warnings in 0.11.x.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e45401..2ba4f2b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+##0.11.6+2
+
+* Fix all strong mode warnings.
+
##0.11.6+1
* Give tests more time to start running.
diff --git a/lib/src/matcher/iterable_matchers.dart b/lib/src/matcher/iterable_matchers.dart
index 6a759ec..22465f6 100644
--- a/lib/src/matcher/iterable_matchers.dart
+++ b/lib/src/matcher/iterable_matchers.dart
@@ -120,8 +120,8 @@
final List _expectedValues;
_UnorderedEquals(Iterable expected)
- : super(expected.map(equals)),
- _expectedValues = expected.toList();
+ : _expectedValues = expected.toList(),
+ super(expected.map(equals));
Description describe(Description description) => description
.add('equals ')
diff --git a/lib/src/matcher/operator_matchers.dart b/lib/src/matcher/operator_matchers.dart
index 432f905..967f3fd 100644
--- a/lib/src/matcher/operator_matchers.dart
+++ b/lib/src/matcher/operator_matchers.dart
@@ -90,24 +90,8 @@
description.addAll('(', ' or ', ')', _matchers);
}
-List<Matcher> _wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
- Iterable<Matcher> matchers;
- if (arg0 is List) {
- if (arg1 != null ||
- arg2 != null ||
- arg3 != null ||
- arg4 != null ||
- arg5 != null ||
- arg6 != null) {
- throw new ArgumentError('If arg0 is a List, all other arguments must be'
- ' null.');
- }
-
- matchers = arg0;
- } else {
- matchers =
- [arg0, arg1, arg2, arg3, arg4, arg5, arg6].where((e) => e != null);
- }
-
- return matchers.map((e) => wrapMatcher(e)).toList();
-}
+List<Matcher> _wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6) =>
+ [arg0, arg1, arg2, arg3, arg4, arg5, arg6]
+ .where((e) => e != null)
+ .map((e) => wrapMatcher(e))
+ .toList();
diff --git a/lib/src/matcher/util.dart b/lib/src/matcher/util.dart
index b98c1a8..1550974 100644
--- a/lib/src/matcher/util.dart
+++ b/lib/src/matcher/util.dart
@@ -7,6 +7,8 @@
import 'core_matchers.dart';
import 'interfaces.dart';
+typedef bool _Predicate(value);
+
/// A [Map] between whitespace characters and their escape sequences.
const _escapeMap = const {
'\n': r'\n',
@@ -38,7 +40,7 @@
Matcher wrapMatcher(x) {
if (x is Matcher) {
return x;
- } else if (x is Function) {
+ } else if (x is _Predicate) {
return predicate(x);
} else {
return equals(x);
diff --git a/lib/unittest.dart b/lib/unittest.dart
index 51ccff4..8cf8719 100644
--- a/lib/unittest.dart
+++ b/lib/unittest.dart
@@ -267,6 +267,8 @@
}
}
+typedef bool _TestFilter(InternalTestCase arg);
+
/// Remove any tests that match [testFilter].
///
/// [testFilter] can be a predicate function, a [RegExp], or a [String]. If it's
@@ -276,13 +278,13 @@
/// This is different from enabling or disabling tests in that it removes the
/// tests completely.
void filterTests(testFilter) {
- var filterFunction;
+ _TestFilter filterFunction;
if (testFilter is String) {
var re = new RegExp(testFilter);
filterFunction = (t) => re.hasMatch(t.description);
} else if (testFilter is RegExp) {
filterFunction = (t) => testFilter.hasMatch(t.description);
- } else if (testFilter is Function) {
+ } else if (testFilter is _TestFilter) {
filterFunction = testFilter;
}
environment.testCases.retainWhere(filterFunction);
diff --git a/pubspec.yaml b/pubspec.yaml
index 0f971d2..35e6b45 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: unittest
-version: 0.11.6+1
+version: 0.11.6+2
author: Dart Team <misc@dartlang.org>
description: A library for writing dart unit tests.
homepage: https://github.com/dart-lang/old_unittest