Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit e52a3be

Browse files
authored
Additional strong-mode fixes (down to 0 after this PR) (#13)
* Additional strong-mode fixes * Revert infererred types
1 parent 302cafc commit e52a3be

17 files changed

+123
-121
lines changed

test/cancelable_operation_test.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
var completer;
1515
setUp(() {
1616
completer = new CancelableCompleter(
17-
onCancel: expectAsync(() {}, count: 0));
17+
onCancel: expectAsync0(() {}, count: 0));
1818
});
1919

2020
test("sends values to the future", () {
@@ -107,7 +107,7 @@ void main() {
107107
group("when canceled", () {
108108
test("causes the future never to fire", () async {
109109
var completer = new CancelableCompleter();
110-
completer.operation.value.whenComplete(expectAsync(() {}, count: 0));
110+
completer.operation.value.whenComplete(expectAsync0(() {}, count: 0));
111111
completer.operation.cancel();
112112

113113
// Give the future plenty of time to fire if it's going to.
@@ -119,7 +119,7 @@ void main() {
119119
test("fires onCancel", () {
120120
var canceled = false;
121121
var completer;
122-
completer = new CancelableCompleter(onCancel: expectAsync(() {
122+
completer = new CancelableCompleter(onCancel: expectAsync0(() {
123123
expect(completer.isCanceled, isTrue);
124124
canceled = true;
125125
}));
@@ -134,7 +134,7 @@ void main() {
134134
});
135135

136136
test("returns the onCancel future each time cancel is called", () {
137-
var completer = new CancelableCompleter(onCancel: expectAsync(() {
137+
var completer = new CancelableCompleter(onCancel: expectAsync0(() {
138138
return new Future.value(1);
139139
}));
140140
expect(completer.operation.cancel(), completion(equals(1)));
@@ -143,37 +143,37 @@ void main() {
143143
});
144144

145145
test("returns a future even if onCancel doesn't", () {
146-
var completer = new CancelableCompleter(onCancel: expectAsync(() {}));
146+
var completer = new CancelableCompleter(onCancel: expectAsync0(() {}));
147147
expect(completer.operation.cancel(), completes);
148148
});
149149

150150
test("doesn't call onCancel if the completer has completed", () {
151151
var completer = new CancelableCompleter(
152-
onCancel: expectAsync(() {}, count: 0));
152+
onCancel: expectAsync0(() {}, count: 0));
153153
completer.complete(1);
154154
expect(completer.operation.value, completion(equals(1)));
155155
expect(completer.operation.cancel(), completes);
156156
});
157157

158158
test("does call onCancel if the completer has completed to an unfired "
159159
"Future", () {
160-
var completer = new CancelableCompleter(onCancel: expectAsync(() {}));
160+
var completer = new CancelableCompleter(onCancel: expectAsync0(() {}));
161161
completer.complete(new Completer().future);
162162
expect(completer.operation.cancel(), completes);
163163
});
164164

165165
test("doesn't call onCancel if the completer has completed to a fired "
166166
"Future", () async {
167167
var completer = new CancelableCompleter(
168-
onCancel: expectAsync(() {}, count: 0));
168+
onCancel: expectAsync0(() {}, count: 0));
169169
completer.complete(new Future.value(1));
170170
await completer.operation.value;
171171
expect(completer.operation.cancel(), completes);
172172
});
173173

174174
test("can be completed once after being canceled", () async {
175175
var completer = new CancelableCompleter();
176-
completer.operation.value.whenComplete(expectAsync(() {}, count: 0));
176+
completer.operation.value.whenComplete(expectAsync0(() {}, count: 0));
177177
await completer.operation.cancel();
178178
completer.complete(1);
179179
expect(() => completer.complete(1), throwsStateError);
@@ -228,10 +228,10 @@ void main() {
228228
});
229229

230230
test("cancels the completer when the subscription is canceled", () {
231-
var completer = new CancelableCompleter(onCancel: expectAsync(() {}));
231+
var completer = new CancelableCompleter(onCancel: expectAsync0(() {}));
232232
var sub = completer.operation.asStream()
233-
.listen(expectAsync((_) {}, count: 0));
234-
completer.operation.value.whenComplete(expectAsync(() {}, count: 0));
233+
.listen(expectAsync1((_) {}, count: 0));
234+
completer.operation.value.whenComplete(expectAsync0(() {}, count: 0));
235235
sub.cancel();
236236
expect(completer.isCanceled, isTrue);
237237
});

test/future_group_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,16 @@ void main() {
187187
var onIdleDone = false;
188188
var futureFired = false;
189189

190-
futureGroup.onIdle.listen(expectAsync((_) {
190+
futureGroup.onIdle.listen(expectAsync1((_) {
191191
expect(futureFired, isFalse);
192192
idle = true;
193-
}), onDone: expectAsync(() {
193+
}), onDone: expectAsync0(() {
194194
expect(idle, isTrue);
195195
expect(futureFired, isFalse);
196196
onIdleDone = true;
197197
}));
198198

199-
futureGroup.future.then(expectAsync((_) {
199+
futureGroup.future.then(expectAsync1((_) {
200200
expect(idle, isTrue);
201201
expect(onIdleDone, isTrue);
202202
futureFired = true;

test/lazy_stream_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ main() {
1616

1717
test("calls the callback when the stream is listened", () async {
1818
var callbackCalled = false;
19-
var stream = new LazyStream(expectAsync(() {
19+
var stream = new LazyStream(expectAsync0(() {
2020
callbackCalled = true;
2121
return new Stream.empty();
2222
}));
@@ -30,7 +30,7 @@ main() {
3030

3131
test("calls the callback when the stream is listened", () async {
3232
var callbackCalled = false;
33-
var stream = new LazyStream(expectAsync(() {
33+
var stream = new LazyStream(expectAsync0(() {
3434
callbackCalled = true;
3535
return new Stream.empty();
3636
}));
@@ -44,7 +44,7 @@ main() {
4444

4545
test("forwards to a synchronously-provided stream", () async {
4646
var controller = new StreamController<int>();
47-
var stream = new LazyStream(expectAsync(() => controller.stream));
47+
var stream = new LazyStream(expectAsync0(() => controller.stream));
4848

4949
var events = [];
5050
stream.listen(events.add);
@@ -66,7 +66,7 @@ main() {
6666

6767
test("forwards to an asynchronously-provided stream", () async {
6868
var controller = new StreamController<int>();
69-
var stream = new LazyStream(expectAsync(() async => controller.stream));
69+
var stream = new LazyStream(expectAsync0(() async => controller.stream));
7070

7171
var events = [];
7272
stream.listen(events.add);
@@ -87,7 +87,7 @@ main() {
8787
});
8888

8989
test("a lazy stream can't be listened to multiple times", () {
90-
var stream = new LazyStream(expectAsync(() => new Stream.empty()));
90+
var stream = new LazyStream(expectAsync0(() => new Stream.empty()));
9191
expect(stream.isBroadcast, isFalse);
9292

9393
stream.listen(null);
@@ -97,7 +97,7 @@ main() {
9797

9898
test("a lazy stream can't be listened to from within its callback", () {
9999
var stream;
100-
stream = new LazyStream(expectAsync(() {
100+
stream = new LazyStream(expectAsync0(() {
101101
expect(() => stream.listen(null), throwsStateError);
102102
return new Stream.empty();
103103
}));

test/restartable_timer_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ main() {
101101
new FakeAsync().run((async) {
102102
new RestartableTimer(
103103
new Duration(seconds: 5),
104-
expectAsync(() {}, count: 1));
104+
expectAsync0(() {}, count: 1));
105105
async.elapse(new Duration(seconds: 10));
106106
});
107107
});

test/result_test.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void main() {
5858
test("complete with value", () {
5959
Result<int> result = new ValueResult<int>(42);
6060
var c = new Completer<int>();
61-
c.future.then(expectAsync((int v) { expect(v, equals(42)); }),
61+
c.future.then(expectAsync1((int v) { expect(v, equals(42)); }),
6262
onError: (e, s) { fail("Unexpected error"); });
6363
result.complete(c);
6464
});
@@ -67,7 +67,7 @@ void main() {
6767
Result<bool> result = new ErrorResult("BAD", stack);
6868
var c = new Completer<bool>();
6969
c.future.then((bool v) { fail("Unexpected value $v"); },
70-
onError: expectAsync((e, s) {
70+
onError: expectAsync2((e, s) {
7171
expect(e, equals("BAD"));
7272
expect(s, same(stack));
7373
}));
@@ -77,15 +77,15 @@ void main() {
7777
test("add sink value", () {
7878
var result = new ValueResult<int>(42);
7979
EventSink<int> sink = new TestSink(
80-
onData: expectAsync((v) { expect(v, equals(42)); })
80+
onData: expectAsync1((v) { expect(v, equals(42)); })
8181
);
8282
result.addTo(sink);
8383
});
8484

8585
test("add sink error", () {
8686
Result<bool> result = new ErrorResult("BAD", stack);
8787
EventSink<bool> sink = new TestSink(
88-
onError: expectAsync((e, s) {
88+
onError: expectAsync2((e, s) {
8989
expect(e, equals("BAD"));
9090
expect(s, same(stack));
9191
})
@@ -95,22 +95,22 @@ void main() {
9595

9696
test("value as future", () {
9797
Result<int> result = new ValueResult<int>(42);
98-
result.asFuture.then(expectAsync((int v) { expect(v, equals(42)); }),
98+
result.asFuture.then(expectAsync1((int v) { expect(v, equals(42)); }),
9999
onError: (e, s) { fail("Unexpected error"); });
100100
});
101101

102102
test("error as future", () {
103103
Result<bool> result = new ErrorResult("BAD", stack);
104104
result.asFuture.then((bool v) { fail("Unexpected value $v"); },
105-
onError: expectAsync((e, s) {
105+
onError: expectAsync2((e, s) {
106106
expect(e, equals("BAD"));
107107
expect(s, same(stack));
108108
}));
109109
});
110110

111111
test("capture future value", () {
112112
Future<int> value = new Future<int>.value(42);
113-
Result.capture(value).then(expectAsync((Result result) {
113+
Result.capture(value).then(expectAsync1((Result result) {
114114
expect(result.isValue, isTrue);
115115
expect(result.isError, isFalse);
116116
ValueResult value = result.asValue;
@@ -122,7 +122,7 @@ void main() {
122122

123123
test("capture future error", () {
124124
Future<bool> value = new Future<bool>.error("BAD", stack);
125-
Result.capture(value).then(expectAsync((Result result) {
125+
Result.capture(value).then(expectAsync1((Result result) {
126126
expect(result.isValue, isFalse);
127127
expect(result.isError, isTrue);
128128
ErrorResult error = result.asError;
@@ -136,7 +136,7 @@ void main() {
136136
test("release future value", () {
137137
Future<Result<int>> future =
138138
new Future<Result<int>>.value(new Result<int>.value(42));
139-
Result.release(future).then(expectAsync((v) {
139+
Result.release(future).then(expectAsync1((v) {
140140
expect(v, equals(42));
141141
}), onError: (e, s) {
142142
fail("Unexpected error: $e");
@@ -149,7 +149,7 @@ void main() {
149149
new Future<Result<bool>>.value(new Result<bool>.error("BAD", stack));
150150
Result.release(future).then((v) {
151151
fail("Unexpected value: $v");
152-
}, onError: expectAsync((e, s) {
152+
}, onError: expectAsync2((e, s) {
153153
expect(e, equals("BAD"));
154154
expect(s, same(stack));
155155
}));
@@ -160,7 +160,7 @@ void main() {
160160
Future<Result<bool>> future = new Future<Result<bool>>.error("BAD", stack);
161161
Result.release(future).then((v) {
162162
fail("Unexpected value: $v");
163-
}, onError: expectAsync((e, s) {
163+
}, onError: expectAsync2((e, s) {
164164
expect(e, equals("BAD"));
165165
expect(s, same(stack));
166166
}));
@@ -176,9 +176,9 @@ void main() {
176176
expect(expectedList.isEmpty, isFalse);
177177
expectResult(actual, expectedList.removeFirst());
178178
}
179-
stream.listen(expectAsync(listener, count: 3),
179+
stream.listen(expectAsync1(listener, count: 3),
180180
onError: (e, s) { fail("Unexpected error: $e"); },
181-
onDone: expectAsync((){}),
181+
onDone: expectAsync0((){}),
182182
cancelOnError: true);
183183
c.add(42);
184184
c.addError("BAD", stack);
@@ -211,9 +211,9 @@ void main() {
211211
expect(stackTrace, same(expected.asError.stackTrace));
212212
}
213213

214-
stream.listen(expectAsync(dataListener, count: 2),
215-
onError: expectAsync(errorListener, count: 2),
216-
onDone: expectAsync((){}));
214+
stream.listen(expectAsync1(dataListener, count: 2),
215+
onError: expectAsync2(errorListener, count: 2),
216+
onDone: expectAsync0((){}));
217217
for (Result<int> result in events) {
218218
c.add(result); // Result value or error in data line.
219219
}
@@ -224,8 +224,8 @@ void main() {
224224
test("release stream cancel on error", () {
225225
StreamController<Result<int>> c = new StreamController<Result<int>>();
226226
Stream<int> stream = Result.releaseStream(c.stream);
227-
stream.listen(expectAsync((v) { expect(v, equals(42)); }),
228-
onError: expectAsync((e, s) {
227+
stream.listen(expectAsync1((v) { expect(v, equals(42)); }),
228+
onError: expectAsync2((e, s) {
229229
expect(e, equals("BAD"));
230230
expect(s, same(stack));
231231
}),
@@ -259,7 +259,7 @@ void main() {
259259
});
260260

261261
test("handle unary", () {
262-
var result = new Result.error("error", stack);
262+
ErrorResult result = new Result.error("error", stack);
263263
bool called = false;
264264
result.handle((error) {
265265
called = true;
@@ -269,7 +269,7 @@ void main() {
269269
});
270270

271271
test("handle binary", () {
272-
var result = new Result.error("error", stack);
272+
ErrorResult result = new Result.error("error", stack);
273273
bool called = false;
274274
result.handle((error, stackTrace) {
275275
called = true;
@@ -280,7 +280,7 @@ void main() {
280280
});
281281

282282
test("handle unary and binary", () {
283-
var result = new Result.error("error", stack);
283+
ErrorResult result = new Result.error("error", stack);
284284
bool called = false;
285285
result.handle((error, [stackTrace]) {
286286
called = true;
@@ -291,7 +291,7 @@ void main() {
291291
});
292292

293293
test("handle neither unary nor binary", () {
294-
var result = new Result.error("error", stack);
294+
ErrorResult result = new Result.error("error", stack);
295295
expect(() => result.handle(() => fail("unreachable")),
296296
throws);
297297
expect(() => result.handle((a, b, c) => fail("unreachable")),

test/stream_completer_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ main() {
343343
var completer = new StreamCompleter();
344344
completer.stream.listen(
345345
unreachable("data"),
346-
onError: expectAsync((error, stackTrace) {
346+
onError: expectAsync2((error, stackTrace) {
347347
expect(error, equals("oh no"));
348348
}),
349-
onDone: expectAsync(() {}));
349+
onDone: expectAsync0(() {}));
350350

351351
completer.setError("oh no");
352352
});
@@ -359,10 +359,10 @@ main() {
359359

360360
completer.stream.listen(
361361
unreachable("data"),
362-
onError: expectAsync((error, stackTrace) {
362+
onError: expectAsync2((error, stackTrace) {
363363
expect(error, equals("oh no"));
364364
}),
365-
onDone: expectAsync(() {}));
365+
onDone: expectAsync0(() {}));
366366
});
367367
});
368368
}

test/stream_group_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ main() {
211211
var canceled = false;
212212
var controller = new StreamController<String>(onListen: () {
213213
listened = true;
214-
}, onCancel: expectAsync(() {
214+
}, onCancel: expectAsync0(() {
215215
expect(listened, isTrue);
216216
canceled = true;
217217
}));
@@ -357,7 +357,7 @@ main() {
357357
var subscription = streamGroup.stream.listen(null);
358358

359359
var controller = new StreamController<String>(
360-
onCancel: expectAsync(() {}, count: 0));
360+
onCancel: expectAsync0(() {}, count: 0));
361361

362362
streamGroup.add(controller.stream);
363363
await flushMicrotasks();

0 commit comments

Comments
 (0)