fix formatting
diff --git a/analysis_options.yaml b/analysis_options.yaml
index d7cb8a2..1cb9f53 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -32,6 +32,9 @@
- library_names
- library_prefixes
- non_constant_identifier_names
+ - prefer_generic_function_type_aliases
- prefer_is_not_empty
- slash_for_doc_comments
- type_init_formals
+ - unnecessary_const
+ - unnecessary_new
diff --git a/lib/mockito.dart b/lib/mockito.dart
index 14a506f..046f68c 100644
--- a/lib/mockito.dart
+++ b/lib/mockito.dart
@@ -39,9 +39,9 @@
Verification,
// -- deprecated
- typed, // ignore: deprecated_member_use
- typedArgThat, // ignore: deprecated_member_use
- typedCaptureThat, // ignore: deprecated_member_use
+ typed, // ignore: deprecated_member_use_from_same_package
+ typedArgThat, // ignore: deprecated_member_use_from_same_package
+ typedCaptureThat, // ignore: deprecated_member_use_from_same_package
// -- misc
throwOnMissingStub,
diff --git a/lib/src/call_pair.dart b/lib/src/call_pair.dart
index 26b258b..3c9610c 100644
--- a/lib/src/call_pair.dart
+++ b/lib/src/call_pair.dart
@@ -15,7 +15,7 @@
import 'package:matcher/matcher.dart';
/// Returns a value dependent on the details of an [invocation].
-typedef T Answer<T>(Invocation invocation);
+typedef Answer<T> = T Function(Invocation invocation);
/// A captured method or property accessor -> a function that returns a value.
class CallPair<T> {
diff --git a/lib/src/invocation_matcher.dart b/lib/src/invocation_matcher.dart
index 9fc9d81..0b34f46 100644
--- a/lib/src/invocation_matcher.dart
+++ b/lib/src/invocation_matcher.dart
@@ -39,15 +39,15 @@
bool isSetter = false,
}) {
if (isGetter && isSetter) {
- throw new ArgumentError('Cannot set isGetter and iSetter');
+ throw ArgumentError('Cannot set isGetter and iSetter');
}
if (positionalArguments == null) {
- throw new ArgumentError.notNull('positionalArguments');
+ throw ArgumentError.notNull('positionalArguments');
}
if (namedArguments == null) {
- throw new ArgumentError.notNull('namedArguments');
+ throw ArgumentError.notNull('namedArguments');
}
- return new _InvocationMatcher(new _InvocationSignature(
+ return _InvocationMatcher(_InvocationSignature(
memberName: memberName,
positionalArguments: positionalArguments,
namedArguments: namedArguments,
@@ -59,8 +59,7 @@
/// Returns a matcher that matches the name and arguments of an [invocation].
///
/// To expect the same _signature_ see [invokes].
-Matcher isInvocation(Invocation invocation) =>
- new _InvocationMatcher(invocation);
+Matcher isInvocation(Invocation invocation) => _InvocationMatcher(invocation);
class _InvocationSignature extends Invocation {
@override
@@ -131,7 +130,7 @@
_InvocationMatcher(this._invocation) {
if (_invocation == null) {
- throw new ArgumentError.notNull();
+ throw ArgumentError.notNull();
}
}
@@ -156,10 +155,10 @@
_invocation.memberName == item.memberName &&
_invocation.isSetter == item.isSetter &&
_invocation.isGetter == item.isGetter &&
- const ListEquality<dynamic /* Matcher | E */ >(const _MatcherEquality())
+ const ListEquality<dynamic /* Matcher | E */ >(_MatcherEquality())
.equals(_invocation.positionalArguments, item.positionalArguments) &&
const MapEquality<dynamic, dynamic /* Matcher | E */ >(
- values: const _MatcherEquality())
+ values: _MatcherEquality())
.equals(_invocation.namedArguments, item.namedArguments);
}
diff --git a/lib/src/mock.dart b/lib/src/mock.dart
index 4d094cb..9672cc6 100644
--- a/lib/src/mock.dart
+++ b/lib/src/mock.dart
@@ -29,7 +29,7 @@
_WhenCall _whenCall;
_UntilCall _untilCall;
final List<_VerifyCall> _verifyCalls = <_VerifyCall>[];
-final _TimeStampProvider _timer = new _TimeStampProvider();
+final _TimeStampProvider _timer = _TimeStampProvider();
final List _capturedArgs = [];
final List<ArgMatcher> _storedArgs = <ArgMatcher>[];
final Map<String, ArgMatcher> _storedNamedArgs = <String, ArgMatcher>{};
@@ -44,7 +44,7 @@
/// The default behavior when not using this is to always return `null`.
void throwOnMissingStub(Mock mock) {
mock._defaultResponse =
- () => new CallPair<dynamic>.allInvocations(mock._noSuchMethod);
+ () => CallPair<dynamic>.allInvocations(mock._noSuchMethod);
}
/// Extend or mixin this class to mark the implementation as a [Mock].
@@ -82,10 +82,10 @@
class Mock {
static Null _answerNull(_) => null;
- static const _nullResponse = const CallPair<Null>.allInvocations(_answerNull);
+ static const _nullResponse = CallPair<Null>.allInvocations(_answerNull);
final StreamController<Invocation> _invocationStreamController =
- new StreamController.broadcast();
+ StreamController.broadcast();
final _realCalls = <RealCall>[];
final _responses = <CallPair<dynamic>>[];
@@ -106,16 +106,16 @@
// See "Emulating Functions and Interactions" on dartlang.org: goo.gl/r3IQUH
invocation = _useMatchedInvocationIfSet(invocation);
if (_whenInProgress) {
- _whenCall = new _WhenCall(this, invocation);
+ _whenCall = _WhenCall(this, invocation);
return null;
} else if (_verificationInProgress) {
- _verifyCalls.add(new _VerifyCall(this, invocation));
+ _verifyCalls.add(_VerifyCall(this, invocation));
return null;
} else if (_untilCalledInProgress) {
- _untilCall = new _UntilCall(this, invocation);
+ _untilCall = _UntilCall(this, invocation);
return null;
} else {
- _realCalls.add(new RealCall(this, invocation));
+ _realCalls.add(RealCall(this, invocation));
_invocationStreamController.add(invocation);
var cannedResponse = _responses.lastWhere(
(cr) => cr.call.matches(invocation, {}),
@@ -152,14 +152,14 @@
}
}
-typedef CallPair<dynamic> _ReturnsCannedResponse();
+typedef _ReturnsCannedResponse = CallPair<dynamic> Function();
// When using an [ArgMatcher], we transform our invocation to have knowledge of
// which arguments are wrapped, and which ones are not. Otherwise we just use
// the existing invocation object.
Invocation _useMatchedInvocationIfSet(Invocation invocation) {
if (_storedArgs.isNotEmpty || _storedNamedArgs.isNotEmpty) {
- invocation = new _InvocationForMatchedArguments(invocation);
+ invocation = _InvocationForMatchedArguments(invocation);
}
return invocation;
}
@@ -182,7 +182,7 @@
factory _InvocationForMatchedArguments(Invocation invocation) {
if (_storedArgs.isEmpty && _storedNamedArgs.isEmpty) {
- throw new StateError(
+ throw StateError(
"_InvocationForMatchedArguments called when no ArgMatchers have been saved.");
}
@@ -196,7 +196,7 @@
_storedArgs.clear();
_storedNamedArgs.clear();
- return new _InvocationForMatchedArguments._(
+ return _InvocationForMatchedArguments._(
invocation.memberName,
positionalArguments,
namedArguments,
@@ -213,7 +213,7 @@
static Map<Symbol, dynamic> _reconstituteNamedArgs(Invocation invocation) {
var namedArguments = <Symbol, dynamic>{};
var _storedNamedArgSymbols =
- _storedNamedArgs.keys.map((name) => new Symbol(name));
+ _storedNamedArgs.keys.map((name) => Symbol(name));
// Iterate through [invocation]'s named args, validate them, and add them
// to the return map.
@@ -234,12 +234,12 @@
// Iterate through the stored named args, validate them, and add them to
// the return map.
_storedNamedArgs.forEach((name, arg) {
- Symbol nameSymbol = new Symbol(name);
+ Symbol nameSymbol = Symbol(name);
if (!invocation.namedArguments.containsKey(nameSymbol)) {
// Clear things out for the next call.
_storedArgs.clear();
_storedNamedArgs.clear();
- throw new ArgumentError(
+ throw ArgumentError(
'An ArgumentMatcher was declared as named $name, but was not '
'passed as an argument named $name.\n\n'
'BAD: when(obj.fn(anyNamed: "a")))\n'
@@ -249,7 +249,7 @@
// Clear things out for the next call.
_storedArgs.clear();
_storedNamedArgs.clear();
- throw new ArgumentError(
+ throw ArgumentError(
'An ArgumentMatcher was declared as named $name, but a different '
'value (${invocation.namedArguments[nameSymbol]}) was passed as '
'$name.\n\n'
@@ -274,7 +274,7 @@
// `when(obj.fn(a: any))`.
_storedArgs.clear();
_storedNamedArgs.clear();
- throw new ArgumentError(
+ throw ArgumentError(
'An argument matcher (like `any`) was used as a named argument, but '
'did not use a Mockito "named" API. Each argument matcher that is '
'used as a named argument needs to specify the name of the argument '
@@ -329,13 +329,11 @@
class PostExpectation<T> {
void thenReturn(T expected) {
if (expected is Future) {
- throw new ArgumentError(
- '`thenReturn` should not be used to return a Future. '
+ throw ArgumentError('`thenReturn` should not be used to return a Future. '
'Instead, use `thenAnswer((_) => future)`.');
}
if (expected is Stream) {
- throw new ArgumentError(
- '`thenReturn` should not be used to return a Stream. '
+ throw ArgumentError('`thenReturn` should not be used to return a Stream. '
'Instead, use `thenAnswer((_) => stream)`.');
}
return _completeWhen((_) => expected);
@@ -353,7 +351,7 @@
void _completeWhen(Answering<T> answer) {
if (_whenCall == null) {
- throw new StateError(
+ throw StateError(
'Mock method was not called within `when()`. Was a real method called?');
}
_whenCall._setExpected<T>(answer);
@@ -453,9 +451,9 @@
class _TimeStampProvider {
int _now = 0;
DateTime now() {
- var candidate = new DateTime.now();
+ var candidate = DateTime.now();
if (candidate.millisecondsSinceEpoch <= _now) {
- candidate = new DateTime.fromMillisecondsSinceEpoch(_now + 1);
+ candidate = DateTime.fromMillisecondsSinceEpoch(_now + 1);
}
_now = candidate.millisecondsSinceEpoch;
return candidate;
@@ -511,8 +509,7 @@
} else if (invocation.isSetter) {
method = '$method=$argString';
} else {
- throw new StateError(
- 'Invocation should be getter, setter or a method call.');
+ throw StateError('Invocation should be getter, setter or a method call.');
}
var verifiedText = verified ? '[VERIFIED] ' : '';
@@ -534,7 +531,7 @@
_WhenCall(this.mock, this.whenInvocation);
void _setExpected<T>(Answering<T> answer) {
- mock._setExpected(new CallPair<T>(isInvocation(whenInvocation), answer));
+ mock._setExpected(CallPair<T>(isInvocation(whenInvocation), answer));
}
}
@@ -543,7 +540,7 @@
final Mock _mock;
_UntilCall(this._mock, Invocation invocation)
- : _invocationMatcher = new InvocationMatcher(invocation);
+ : _invocationMatcher = InvocationMatcher(invocation);
bool _matchesInvocation(RealCall realCall) =>
_invocationMatcher.matches(realCall.invocation);
@@ -552,8 +549,7 @@
Future<Invocation> get invocationFuture {
if (_realCalls.any(_matchesInvocation)) {
- return new Future.value(
- _realCalls.firstWhere(_matchesInvocation).invocation);
+ return Future.value(_realCalls.firstWhere(_matchesInvocation).invocation);
}
return _mock._invocationStreamController.stream
@@ -567,7 +563,7 @@
List<RealCall> matchingInvocations;
_VerifyCall(this.mock, this.verifyInvocation) {
- var expectedMatcher = new InvocationMatcher(verifyInvocation);
+ var expectedMatcher = InvocationMatcher(verifyInvocation);
matchingInvocations = mock._realCalls.where((RealCall recordedInvocation) {
return !recordedInvocation.verified &&
expectedMatcher.matches(recordedInvocation.invocation);
@@ -650,7 +646,7 @@
captureThat(matcher, named: named);
Null _registerMatcher(Matcher matcher, bool capture, {String named}) {
- var argMatcher = new ArgMatcher(matcher, capture);
+ var argMatcher = ArgMatcher(matcher, capture);
if (named == null) {
_storedArgs.add(argMatcher);
} else {
@@ -667,7 +663,7 @@
bool _testApiMismatchHasBeenChecked = false;
VerificationResult(this.callCount) {
- captured = new List<dynamic>.from(_capturedArgs, growable: false);
+ captured = List<dynamic>.from(_capturedArgs, growable: false);
_capturedArgs.clear();
}
@@ -718,7 +714,7 @@
}
}
-typedef T Answering<T>(Invocation realInvocation);
+typedef Answering<T> = T Function(Invocation realInvocation);
typedef Verification = VerificationResult Function<T>(T matchingInvocations);
@@ -774,15 +770,14 @@
'$message ${_verifyCalls.length} verify calls have been stored. '
'[${_verifyCalls.first}, ..., ${_verifyCalls.last}]';
}
- throw new StateError(message);
+ throw StateError(message);
}
_verificationInProgress = true;
return <T>(T mock) {
_verificationInProgress = false;
if (_verifyCalls.length == 1) {
_VerifyCall verifyCall = _verifyCalls.removeLast();
- var result =
- new VerificationResult(verifyCall.matchingInvocations.length);
+ var result = VerificationResult(verifyCall.matchingInvocations.length);
verifyCall._checkWith(never);
return result;
} else {
@@ -793,13 +788,13 @@
_InOrderVerification get verifyInOrder {
if (_verifyCalls.isNotEmpty) {
- throw new StateError(_verifyCalls.join());
+ throw StateError(_verifyCalls.join());
}
_verificationInProgress = true;
return <T>(List<T> _) {
_verificationInProgress = false;
- DateTime dt = new DateTime.fromMillisecondsSinceEpoch(0);
- var tmpVerifyCalls = new List<_VerifyCall>.from(_verifyCalls);
+ DateTime dt = DateTime.fromMillisecondsSinceEpoch(0);
+ var tmpVerifyCalls = List<_VerifyCall>.from(_verifyCalls);
_verifyCalls.clear();
List<RealCall> matchedCalls = [];
for (_VerifyCall verifyCall in tmpVerifyCalls) {
@@ -878,12 +873,12 @@
/// See the README for more information.
Expectation get when {
if (_whenCall != null) {
- throw new StateError('Cannot call `when` within a stub response');
+ throw StateError('Cannot call `when` within a stub response');
}
_whenInProgress = true;
return <T>(T _) {
_whenInProgress = false;
- return new PostExpectation<T>();
+ return PostExpectation<T>();
};
}
diff --git a/test/capture_test.dart b/test/capture_test.dart
index b1335b8..0a3ae7b 100644
--- a/test/capture_test.dart
+++ b/test/capture_test.dart
@@ -24,7 +24,7 @@
String methodWithPositionalArgs(int x, [int y]) => 'Real';
String methodWithTwoNamedArgs(int x, {int y, int z}) => "Real";
set setter(String arg) {
- throw new StateError('I must be mocked');
+ throw StateError('I must be mocked');
}
}
@@ -36,7 +36,7 @@
var isNsmForwarding = assessNsmForwarding();
setUp(() {
- mock = new _MockedClass();
+ mock = _MockedClass();
});
tearDown(() {
diff --git a/test/deprecated_apis/capture_test.dart b/test/deprecated_apis/capture_test.dart
index 11725a9..c4b2657 100644
--- a/test/deprecated_apis/capture_test.dart
+++ b/test/deprecated_apis/capture_test.dart
@@ -28,7 +28,7 @@
String methodWithListArgs(List<int> x) => 'Real';
String methodWithPositionalArgs(int x, [int y]) => 'Real';
set setter(String arg) {
- throw new StateError('I must be mocked');
+ throw StateError('I must be mocked');
}
}
@@ -40,7 +40,7 @@
var isNsmForwarding = assessNsmForwarding();
setUp(() {
- mock = new MockedClass();
+ mock = MockedClass();
});
tearDown(() {
diff --git a/test/deprecated_apis/mockito_test.dart b/test/deprecated_apis/mockito_test.dart
index e14cfdc..f7bf7bc 100644
--- a/test/deprecated_apis/mockito_test.dart
+++ b/test/deprecated_apis/mockito_test.dart
@@ -31,11 +31,11 @@
String methodWithNamedArgs(int x, {int y}) => "Real";
String methodWithTwoNamedArgs(int x, {int y, int z}) => "Real";
String methodWithObjArgs(_RealClass x) => "Real";
- Future<String> methodReturningFuture() => new Future.value("Real");
- Stream<String> methodReturningStream() => new Stream.fromIterable(["Real"]);
+ Future<String> methodReturningFuture() => Future.value("Real");
+ Stream<String> methodReturningStream() => Stream.fromIterable(["Real"]);
String get getter => "Real";
set setter(String arg) {
- throw new StateError("I must be mocked");
+ throw StateError("I must be mocked");
}
}
@@ -63,7 +63,7 @@
rethrow;
} else {
if (expectedMessage != e.message) {
- throw new TestFailure("Failed, but with wrong message: ${e.message}");
+ throw TestFailure("Failed, but with wrong message: ${e.message}");
}
}
}
@@ -76,7 +76,7 @@
_MockedClass mock;
setUp(() {
- mock = new _MockedClass();
+ mock = _MockedClass();
});
tearDown(() {
@@ -116,8 +116,7 @@
//no need to mock setter, except if we will have spies later...
test("should mock method with thrown result", () {
- when(mock.methodWithNormalArgs(typed(any)))
- .thenThrow(new StateError('Boo'));
+ when(mock.methodWithNormalArgs(typed(any))).thenThrow(StateError('Boo'));
expect(() => mock.methodWithNormalArgs(42), throwsStateError);
});
diff --git a/test/deprecated_apis/until_called_test.dart b/test/deprecated_apis/until_called_test.dart
index 9263d6f..92ed487 100644
--- a/test/deprecated_apis/until_called_test.dart
+++ b/test/deprecated_apis/until_called_test.dart
@@ -39,7 +39,7 @@
'Real';
String get getter => 'Real';
set setter(String arg) {
- throw new StateError('I must be mocked');
+ throw StateError('I must be mocked');
}
}
@@ -62,7 +62,7 @@
..methodWithPositionalArgs(1, 2)
..methodWithNamedArgs(1, y: 2)
..methodWithTwoNamedArgs(1, y: 2, z: 3)
- ..methodWithObjArgs(new _RealClass())
+ ..methodWithObjArgs(_RealClass())
..typeParameterizedFn([1, 2], [3, 4], [5, 6], [7, 8])
..typeParameterizedNamedFn([1, 2], [3, 4], y: [5, 6], z: [7, 8])
..getter
@@ -76,7 +76,7 @@
MockedClass mock;
setUp(() {
- mock = new MockedClass();
+ mock = MockedClass();
});
tearDown(() {
@@ -87,7 +87,7 @@
group('untilCalled', () {
StreamController<CallMethodsEvent> streamController =
- new StreamController.broadcast();
+ StreamController.broadcast();
group('on methods already called', () {
test('waits for method with normal args', () async {
@@ -124,7 +124,7 @@
});
test('waits for method with obj args', () async {
- mock.methodWithObjArgs(new _RealClass());
+ mock.methodWithObjArgs(_RealClass());
await untilCalled(mock.methodWithObjArgs(typed(any)));
@@ -145,11 +145,11 @@
group('on methods not yet called', () {
setUp(() {
- new _RealClassController(mock, streamController);
+ _RealClassController(mock, streamController);
});
test('waits for method with normal args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithNormalArgs(typed(any)));
await untilCalled(mock.methodWithNormalArgs(typed(any)));
@@ -158,7 +158,7 @@
});
test('waits for method with list args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithListArgs(typed(any)));
await untilCalled(mock.methodWithListArgs(typed(any)));
@@ -167,7 +167,7 @@
});
test('waits for method with positional args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithPositionalArgs(typed(any), typed(any)));
await untilCalled(
@@ -177,7 +177,7 @@
});
test('waits for method with obj args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithObjArgs(typed(any)));
await untilCalled(mock.methodWithObjArgs(typed(any)));
@@ -186,7 +186,7 @@
});
test('waits for function with positional parameters', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.typeParameterizedFn(
typed(any), typed(any), typed(any), typed(any)));
diff --git a/test/deprecated_apis/verify_test.dart b/test/deprecated_apis/verify_test.dart
index abb5b7e..21a5fb4 100644
--- a/test/deprecated_apis/verify_test.dart
+++ b/test/deprecated_apis/verify_test.dart
@@ -32,7 +32,7 @@
String methodWithObjArgs(_RealClass x) => 'Real';
String get getter => 'Real';
set setter(String arg) {
- throw new StateError('I must be mocked');
+ throw StateError('I must be mocked');
}
String methodWithLongArgs(LongToString a, LongToString b,
@@ -66,7 +66,7 @@
rethrow;
} else {
if (expectedMessage != e.message) {
- throw new TestFailure('Failed, but with wrong message: ${e.message}');
+ throw TestFailure('Failed, but with wrong message: ${e.message}');
}
}
}
@@ -79,7 +79,7 @@
_MockedClass mock;
setUp(() {
- mock = new _MockedClass();
+ mock = _MockedClass();
});
tearDown(() {
diff --git a/test/example/iss/iss.dart b/test/example/iss/iss.dart
index 889988d..e932fd9 100644
--- a/test/example/iss/iss.dart
+++ b/test/example/iss/iss.dart
@@ -45,7 +45,7 @@
var data = jsonDecode(rs.body);
var latitude = double.parse(data['iss_position']['latitude'] as String);
var longitude = double.parse(data['iss_position']['longitude'] as String);
- _position = new Point<double>(latitude, longitude);
+ _position = Point<double>(latitude, longitude);
}
}
diff --git a/test/example/iss/iss_test.dart b/test/example/iss/iss_test.dart
index a971b7b..3aa2a62 100644
--- a/test/example/iss/iss_test.dart
+++ b/test/example/iss/iss_test.dart
@@ -27,8 +27,8 @@
// verify the calculated distance between them.
group('Spherical distance', () {
test('London - Paris', () {
- Point<double> london = new Point(51.5073, -0.1277);
- Point<double> paris = new Point(48.8566, 2.3522);
+ Point<double> london = Point(51.5073, -0.1277);
+ Point<double> paris = Point(48.8566, 2.3522);
double d = sphericalDistanceKm(london, paris);
// London should be approximately 343.5km
// (+/- 0.1km) from Paris.
@@ -36,8 +36,8 @@
});
test('San Francisco - Mountain View', () {
- Point<double> sf = new Point(37.783333, -122.416667);
- Point<double> mtv = new Point(37.389444, -122.081944);
+ Point<double> sf = Point(37.783333, -122.416667);
+ Point<double> mtv = Point(37.389444, -122.081944);
double d = sphericalDistanceKm(sf, mtv);
// San Francisco should be approximately 52.8km
// (+/- 0.1km) from Mountain View.
@@ -52,24 +52,24 @@
// second predefined location. This test runs asynchronously.
group('ISS spotter', () {
test('ISS visible', () async {
- Point<double> sf = new Point(37.783333, -122.416667);
- Point<double> mtv = new Point(37.389444, -122.081944);
- IssLocator locator = new MockIssLocator();
+ Point<double> sf = Point(37.783333, -122.416667);
+ Point<double> mtv = Point(37.389444, -122.081944);
+ IssLocator locator = MockIssLocator();
// Mountain View should be visible from San Francisco.
when(locator.currentPosition).thenReturn(sf);
- var spotter = new IssSpotter(locator, mtv);
+ var spotter = IssSpotter(locator, mtv);
expect(spotter.isVisible, true);
});
test('ISS not visible', () async {
- Point<double> london = new Point(51.5073, -0.1277);
- Point<double> mtv = new Point(37.389444, -122.081944);
- IssLocator locator = new MockIssLocator();
+ Point<double> london = Point(51.5073, -0.1277);
+ Point<double> mtv = Point(37.389444, -122.081944);
+ IssLocator locator = MockIssLocator();
// London should not be visible from Mountain View.
when(locator.currentPosition).thenReturn(london);
- var spotter = new IssSpotter(locator, mtv);
+ var spotter = IssSpotter(locator, mtv);
expect(spotter.isVisible, false);
});
});
diff --git a/test/invocation_matcher_test.dart b/test/invocation_matcher_test.dart
index ef5efa5..12eae07 100644
--- a/test/invocation_matcher_test.dart
+++ b/test/invocation_matcher_test.dart
@@ -18,7 +18,7 @@
Invocation lastInvocation;
void main() {
- const stub = const Stub();
+ const stub = Stub();
group('$isInvocation', () {
test('positional arguments', () {
@@ -33,8 +33,8 @@
call1,
isInvocation(call3),
"Expected: say('Guten Tag') "
- "Actual: <Instance of '${call3.runtimeType}'> "
- "Which: Does not match say('Hello')",
+ "Actual: <Instance of '${call3.runtimeType}'> "
+ "Which: Does not match say('Hello')",
);
});
@@ -50,8 +50,8 @@
call1,
isInvocation(call3),
"Expected: eat('Chicken', 'alsoDrink: false') "
- "Actual: <Instance of '${call3.runtimeType}'> "
- "Which: Does not match eat('Chicken', 'alsoDrink: true')",
+ "Actual: <Instance of '${call3.runtimeType}'> "
+ "Which: Does not match eat('Chicken', 'alsoDrink: true')",
);
});
@@ -67,8 +67,8 @@
call1,
isInvocation(call3),
"Expected: lie(<false>) "
- "Actual: <Instance of '${call3.runtimeType}'> "
- "Which: Does not match lie(<true>)",
+ "Actual: <Instance of '${call3.runtimeType}'> "
+ "Which: Does not match lie(<true>)",
);
});
@@ -84,7 +84,7 @@
call1,
isInvocation(call3),
// RegExp needed because of https://github.com/dart-lang/sdk/issues/33565
- new RegExp('Expected: set value=? <true> '
+ RegExp('Expected: set value=? <true> '
"Actual: <Instance of '${call3.runtimeType}'> "
'Which: Does not match get value'),
);
@@ -102,7 +102,7 @@
call1,
isInvocation(call3),
// RegExp needed because of https://github.com/dart-lang/sdk/issues/33565
- new RegExp("Expected: set value=? <false> "
+ RegExp("Expected: set value=? <false> "
"Actual: <Instance of '${call3.runtimeType}'> "
"Which: Does not match set value=? <true>"),
);
@@ -119,8 +119,8 @@
call,
invokes(#say, positionalArguments: [isNull]),
"Expected: say(null) "
- "Actual: <Instance of '${call.runtimeType}'> "
- "Which: Does not match say('Hello')",
+ "Actual: <Instance of '${call.runtimeType}'> "
+ "Which: Does not match say('Hello')",
);
});
@@ -133,8 +133,8 @@
call,
invokes(#fly, namedArguments: {#miles: 11}),
"Expected: fly('miles: 11') "
- "Actual: <Instance of '${call.runtimeType}'> "
- "Which: Does not match fly('miles: 10')",
+ "Actual: <Instance of '${call.runtimeType}'> "
+ "Which: Does not match fly('miles: 10')",
);
});
});
diff --git a/test/mockito_test.dart b/test/mockito_test.dart
index 4c2765e..a413009 100644
--- a/test/mockito_test.dart
+++ b/test/mockito_test.dart
@@ -28,8 +28,8 @@
String methodWithNamedArgs(int x, {int y}) => "Real";
String methodWithTwoNamedArgs(int x, {int y, int z}) => "Real";
String methodWithObjArgs(_RealClass x) => "Real";
- Future<String> methodReturningFuture() => new Future.value("Real");
- Stream<String> methodReturningStream() => new Stream.fromIterable(["Real"]);
+ Future<String> methodReturningFuture() => Future.value("Real");
+ Stream<String> methodReturningStream() => Stream.fromIterable(["Real"]);
String get getter => "Real";
}
@@ -59,7 +59,7 @@
rethrow;
} else {
if (expectedMessage != e.message) {
- throw new TestFailure("Failed, but with wrong message: ${e.message}");
+ throw TestFailure("Failed, but with wrong message: ${e.message}");
}
}
}
@@ -74,7 +74,7 @@
var isNsmForwarding = assessNsmForwarding();
setUp(() {
- mock = new _MockedClass();
+ mock = _MockedClass();
});
tearDown(() {
@@ -85,7 +85,7 @@
group("mixin support", () {
test("should work", () {
- var foo = new _MockFoo();
+ var foo = _MockFoo();
when(foo.baz()).thenReturn('baz');
expect(foo.bar(), 'baz');
});
@@ -104,9 +104,9 @@
});
test("should mock method with mock args", () {
- var m1 = new _MockedClass();
+ var m1 = _MockedClass();
when(mock.methodWithObjArgs(m1)).thenReturn("Ultimate Answer");
- expect(mock.methodWithObjArgs(new _MockedClass()), isNull);
+ expect(mock.methodWithObjArgs(_MockedClass()), isNull);
expect(mock.methodWithObjArgs(m1), equals("Ultimate Answer"));
});
@@ -199,19 +199,19 @@
});
test("should mock equals between mocks when givenHashCode is equals", () {
- var anotherMock = named(new _MockedClass(), hashCode: 42);
+ var anotherMock = named(_MockedClass(), hashCode: 42);
named(mock, hashCode: 42);
expect(mock == anotherMock, isTrue);
});
test("should use identical equality between it is not mocked", () {
- var anotherMock = new _MockedClass();
+ var anotherMock = _MockedClass();
expect(mock == anotherMock, isFalse);
expect(mock == mock, isTrue);
});
test("should mock method with thrown result", () {
- when(mock.methodWithNormalArgs(any)).thenThrow(new StateError('Boo'));
+ when(mock.methodWithNormalArgs(any)).thenThrow(StateError('Boo'));
expect(() => mock.methodWithNormalArgs(42), throwsStateError);
});
@@ -223,7 +223,7 @@
});
test("should return mock to make simple oneline mocks", () {
- _RealClass mockWithSetup = new _MockedClass();
+ _RealClass mockWithSetup = _MockedClass();
when(mockWithSetup.methodWithoutArgs()).thenReturn("oneline");
expect(mockWithSetup.methodWithoutArgs(), equals("oneline"));
});
@@ -244,7 +244,7 @@
test("should throw if `when` is called while stubbing", () {
expect(() {
var responseHelper = () {
- var mock2 = new _MockedClass();
+ var mock2 = _MockedClass();
when(mock2.getter).thenReturn("A");
return mock2;
};
@@ -255,27 +255,27 @@
test("thenReturn throws if provided Future", () {
expect(
() => when(mock.methodReturningFuture())
- .thenReturn(new Future.value("stub")),
+ .thenReturn(Future.value("stub")),
throwsArgumentError);
});
test("thenReturn throws if provided Stream", () {
expect(
() => when(mock.methodReturningStream())
- .thenReturn(new Stream.fromIterable(["stub"])),
+ .thenReturn(Stream.fromIterable(["stub"])),
throwsArgumentError);
});
test("thenAnswer supports stubbing method returning a Future", () async {
when(mock.methodReturningFuture())
- .thenAnswer((_) => new Future.value("stub"));
+ .thenAnswer((_) => Future.value("stub"));
expect(await mock.methodReturningFuture(), "stub");
});
test("thenAnswer supports stubbing method returning a Stream", () async {
when(mock.methodReturningStream())
- .thenAnswer((_) => new Stream.fromIterable(["stub"]));
+ .thenAnswer((_) => Stream.fromIterable(["stub"]));
expect(await mock.methodReturningStream().toList(), ["stub"]);
});
@@ -288,7 +288,7 @@
});
test("should throw if attempting to stub a real method", () {
- var foo = new _MockFoo();
+ var foo = _MockFoo();
expect(() {
when(foo.quux()).thenReturn("Stub");
}, throwsStateError);
diff --git a/test/until_called_test.dart b/test/until_called_test.dart
index 24e31a3..634c59c 100644
--- a/test/until_called_test.dart
+++ b/test/until_called_test.dart
@@ -34,7 +34,7 @@
'Real';
String get getter => 'Real';
set setter(String arg) {
- throw new StateError('I must be mocked');
+ throw StateError('I must be mocked');
}
}
@@ -57,7 +57,7 @@
..methodWithPositionalArgs(1, 2)
..methodWithNamedArgs(1, y: 2)
..methodWithTwoNamedArgs(1, y: 2, z: 3)
- ..methodWithObjArgs(new _RealClass())
+ ..methodWithObjArgs(_RealClass())
..typeParameterizedFn([1, 2], [3, 4], [5, 6], [7, 8])
..typeParameterizedNamedFn([1, 2], [3, 4], y: [5, 6], z: [7, 8])
..getter
@@ -71,7 +71,7 @@
_MockedClass mock;
setUp(() {
- mock = new _MockedClass();
+ mock = _MockedClass();
});
tearDown(() {
@@ -82,7 +82,7 @@
group('untilCalled', () {
StreamController<CallMethodsEvent> streamController =
- new StreamController.broadcast();
+ StreamController.broadcast();
group('on methods already called', () {
test('waits for method without args', () async {
@@ -137,7 +137,7 @@
});
test('waits for method with obj args', () async {
- mock.methodWithObjArgs(new _RealClass());
+ mock.methodWithObjArgs(_RealClass());
await untilCalled(mock.methodWithObjArgs(any));
@@ -182,11 +182,11 @@
group('on methods not yet called', () {
setUp(() {
- new _RealClassController(mock, streamController);
+ _RealClassController(mock, streamController);
});
test('waits for method without args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithoutArgs());
await untilCalled(mock.methodWithoutArgs());
@@ -195,7 +195,7 @@
});
test('waits for method with normal args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithNormalArgs(any));
await untilCalled(mock.methodWithNormalArgs(any));
@@ -204,7 +204,7 @@
});
test('waits for method with list args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithListArgs(any));
await untilCalled(mock.methodWithListArgs(any));
@@ -213,7 +213,7 @@
});
test('waits for method with positional args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithPositionalArgs(any, any));
await untilCalled(mock.methodWithPositionalArgs(any, any));
@@ -222,7 +222,7 @@
});
test('waits for method with named args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithNamedArgs(any, y: anyNamed('y')));
await untilCalled(mock.methodWithNamedArgs(any, y: anyNamed('y')));
@@ -231,7 +231,7 @@
});
test('waits for method with two named args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithTwoNamedArgs(any,
y: anyNamed('y'), z: anyNamed('z')));
@@ -244,7 +244,7 @@
});
test('waits for method with obj args', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.methodWithObjArgs(any));
await untilCalled(mock.methodWithObjArgs(any));
@@ -253,7 +253,7 @@
});
test('waits for function with positional parameters', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.typeParameterizedFn(any, any, any, any));
await untilCalled(mock.typeParameterizedFn(any, any, any, any));
@@ -262,7 +262,7 @@
});
test('waits for function with named parameters', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.typeParameterizedNamedFn(any, any,
y: anyNamed('y'), z: anyNamed('z')));
@@ -275,7 +275,7 @@
});
test('waits for getter', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.getter);
await untilCalled(mock.getter);
@@ -284,7 +284,7 @@
});
test('waits for setter', () async {
- streamController.add(new CallMethodsEvent());
+ streamController.add(CallMethodsEvent());
verifyNever(mock.setter = 'A');
await untilCalled(mock.setter = 'A');
diff --git a/test/utils.dart b/test/utils.dart
index 715ba3b..86cb4ec 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -7,7 +7,7 @@
class MockNsmForwardingSignal extends Mock implements NsmForwardingSignal {}
bool assessNsmForwarding() {
- var signal = new MockNsmForwardingSignal();
+ var signal = MockNsmForwardingSignal();
signal.fn();
try {
verify(signal.fn(any));
diff --git a/test/verify_test.dart b/test/verify_test.dart
index 43e6df8..2b0b176 100644
--- a/test/verify_test.dart
+++ b/test/verify_test.dart
@@ -29,7 +29,7 @@
String methodWithObjArgs(_RealClass x) => 'Real';
String get getter => 'Real';
set setter(String arg) {
- throw new StateError('I must be mocked');
+ throw StateError('I must be mocked');
}
String methodWithLongArgs(LongToString a, LongToString b,
@@ -74,7 +74,7 @@
var isNsmForwarding = assessNsmForwarding();
setUp(() {
- mock = new _MockedClass();
+ mock = _MockedClass();
});
tearDown(() {
@@ -129,12 +129,12 @@
});
test('should mock method with mock args', () {
- var m1 = named(new _MockedClass(), name: 'm1');
+ var m1 = named(_MockedClass(), name: 'm1');
mock.methodWithObjArgs(m1);
expectFail(
'No matching calls. All calls: _MockedClass.methodWithObjArgs(m1)\n'
'$noMatchingCallsFooter', () {
- verify(mock.methodWithObjArgs(new _MockedClass()));
+ verify(mock.methodWithObjArgs(_MockedClass()));
});
verify(mock.methodWithObjArgs(m1));
});
@@ -191,8 +191,7 @@
final expectedMessage = RegExp.escape('No matching calls. '
'All calls: _MockedClass.setter==A\n$noMatchingCallsFooter');
// RegExp needed because of https://github.com/dart-lang/sdk/issues/33565
- var expectedPattern =
- new RegExp(expectedMessage.replaceFirst('==', '=?='));
+ var expectedPattern = RegExp(expectedMessage.replaceFirst('==', '=?='));
expectFail(expectedPattern, () => verify(mock.setter = 'B'));
verify(mock.setter = 'A');
@@ -213,7 +212,7 @@
verify(mock.methodWithNamedArgs(42, y: 17));
fail('verify call was expected to throw!');
} catch (e) {
- expect(e, new TypeMatcher<StateError>());
+ expect(e, TypeMatcher<StateError>());
expect(
e.message,
contains('Verification appears to be in progress. '
@@ -450,8 +449,7 @@
});
test('throws if given a real object', () {
- expect(() => verifyNoMoreInteractions(new _RealClass()),
- throwsArgumentError);
+ expect(() => verifyNoMoreInteractions(_RealClass()), throwsArgumentError);
});
});
@@ -507,11 +505,11 @@
test(
'"No matching calls" message visibly separates unmatched calls, '
'if an arg\'s string representations is multiline', () {
- mock.methodWithLongArgs(new LongToString([1, 2], {1: 'a', 2: 'b'}, 'c'),
- new LongToString([4, 5], {3: 'd', 4: 'e'}, 'f'));
+ mock.methodWithLongArgs(LongToString([1, 2], {1: 'a', 2: 'b'}, 'c'),
+ LongToString([4, 5], {3: 'd', 4: 'e'}, 'f'));
mock.methodWithLongArgs(null, null,
- c: new LongToString([5, 6], {5: 'g', 6: 'h'}, 'i'),
- d: new LongToString([7, 8], {7: 'j', 8: 'k'}, 'l'));
+ c: LongToString([5, 6], {5: 'g', 6: 'h'}, 'i'),
+ d: LongToString([7, 8], {7: 'j', 8: 'k'}, 'l'));
var nsmForwardedNamedArgs =
isNsmForwarding ? '>, {c: null, d: null}),' : '>),';
expectFail(