Skip to content

Commit

Permalink
Fix strong mode warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Mar 24, 2016
1 parent 298ab0e commit 7beae72
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
##0.11.6+2

* Fix all strong mode warnings.

##0.11.6+1

* Give tests more time to start running.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/matcher/iterable_matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class _UnorderedEquals extends _UnorderedMatches {
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 ')
Expand Down
26 changes: 5 additions & 21 deletions lib/src/matcher/operator_matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,8 @@ class _AnyOf extends Matcher {
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();
4 changes: 3 additions & 1 deletion lib/src/matcher/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ library unittest.matcher.util;
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',
Expand Down Expand Up @@ -38,7 +40,7 @@ void addStateInfo(Map matchState, Map values) {
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);
Expand Down
6 changes: 4 additions & 2 deletions lib/unittest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ void handleExternalError(e, String message, [stackTrace]) {
}
}

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
Expand All @@ -276,13 +278,13 @@ void handleExternalError(e, String message, [stackTrace]) {
/// 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);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 7beae72

Please sign in to comment.