Skip to content

Commit 6975b6e

Browse files
committed
Address feedback, keep mirrors around.
1 parent dc8ce18 commit 6975b6e

File tree

8 files changed

+20
-32
lines changed

8 files changed

+20
-32
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## 2.0.0-dev
22

3-
* Deprecated usage of `spy` and any `dart:mirrors` based API. Users may
4-
import as `package:mockito/deprecated.dart` until the 2.0.0 final
5-
release.
3+
* Remove export of `spy` and any `dart:mirrors` based API from
4+
`mockito.dart`. Users may import as `package:mockito/mirrors.dart`
5+
going forward.
66
* Deprecated `mockito_no_mirrors.dart`; replace with `mockito.dart`.
77

88
## 1.0.1

lib/deprecated.dart

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/mirrors.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export 'mockito.dart';
2+
export 'src/spy.dart' show spy;

lib/mockito_no_mirrors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@Deprecated('Import "mockito.dart" instead.')
1+
@Deprecated('Import "package:mockito/mockito.dart" instead.')
22
library mockito.mockito_no_mirrors;
33

44
export 'mockito.dart';

lib/src/mock.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Warning: Do not import dart:mirrors in this library, as it's exported via
2-
// lib/mockito_no_mirrors.dart, which is used for Dart AOT projects such as
3-
// Flutter.
2+
// lib/mockito.dart, which is used for Dart AOT projects such as Flutter.
43

54
import 'package:meta/meta.dart';
65
import 'package:test/test.dart';

lib/src/spy.dart

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
// This file is intentionally separated from 'mock.dart' in order to avoid
2-
// bringing in the mirrors dependency into mockito_no_mirrors.dart.
2+
// bringing in the mirrors dependency into mockito.dart.
33
import 'dart:mirrors';
44

5-
import 'mock.dart' show CannedResponse, setDefaultResponse;
5+
import 'mock.dart' show CannedResponse, Mock, setDefaultResponse;
66

7-
@Deprecated(
8-
'Mockito is dropping support for spy(). Instead it is recommended to come '
9-
'up with a code-generation technique or just hand-coding a Stub object that '
10-
'forwards to a delegate. For example:\n\n'
11-
'class SpyAnimal implements Animal {\n'
12-
' final Animal _delegate;\n'
13-
' FakeAnimal(this._delegate);\n'
14-
'\n'
15-
' @override\n'
16-
' void eat() {\n'
17-
' _delegate.eat();\n'
18-
' }\n'
19-
'}'
20-
)
21-
dynamic spy(dynamic mock, dynamic spiedObject) {
22-
var mirror = reflect(spiedObject);
7+
/// Sets the default response of [mock] to be delegated to [spyOn].
8+
///
9+
/// __Example use__:
10+
/// var mockAnimal = new MockAnimal();
11+
/// var realAnimal = new RealAnimal();
12+
/// spy(mockAnimal, realAnimal);
13+
/*=E*/ spy/*<E>*/(Mock mock, Object /*=E*/ spyOn) {
14+
var mirror = reflect(spyOn);
2315
setDefaultResponse(
2416
mock,
2517
() => new CannedResponse(null,

test/invocation_matcher_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void main() {
5454
var call2 = stub.value;
5555
stub.value = true;
5656
var call3 = Stub.lastInvocation;
57-
shouldPass(call1, isInvocation(call2));
57+
shouldPass(call1, isInvocation(call2 as Invocation));
5858
shouldFail(
5959
call1,
6060
isInvocation(call3),

test/spy_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:mockito/src/mock.dart' show resetMockitoState;
2-
import 'package:mockito/deprecated.dart';
2+
import 'package:mockito/mirrors.dart';
33
import 'package:test/test.dart';
44

55
import 'mockito_test.dart' show MockedClass, RealClass;
@@ -19,7 +19,7 @@ void main() {
1919

2020
group("spy", () {
2121
setUp(() {
22-
mock = spy(new MockedClass(), new RealClass());
22+
mock = spy/*<RealClass>*/(new MockedClass(), new RealClass());
2323
});
2424

2525
test("should delegate to real object by default", () {

0 commit comments

Comments
 (0)