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

Additional strong-mode fixes (down to 0 after this PR) #13

Merged
merged 2 commits into from
Jan 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/cancelable_operation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
var completer;
setUp(() {
completer = new CancelableCompleter(
onCancel: expectAsync(() {}, count: 0));
onCancel: expectAsync0(() {}, count: 0));
});

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

// Give the future plenty of time to fire if it's going to.
Expand All @@ -119,7 +119,7 @@ void main() {
test("fires onCancel", () {
var canceled = false;
var completer;
completer = new CancelableCompleter(onCancel: expectAsync(() {
completer = new CancelableCompleter(onCancel: expectAsync0(() {
expect(completer.isCanceled, isTrue);
canceled = true;
}));
Expand All @@ -134,7 +134,7 @@ void main() {
});

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

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

test("doesn't call onCancel if the completer has completed", () {
var completer = new CancelableCompleter(
onCancel: expectAsync(() {}, count: 0));
onCancel: expectAsync0(() {}, count: 0));
completer.complete(1);
expect(completer.operation.value, completion(equals(1)));
expect(completer.operation.cancel(), completes);
});

test("does call onCancel if the completer has completed to an unfired "
"Future", () {
var completer = new CancelableCompleter(onCancel: expectAsync(() {}));
var completer = new CancelableCompleter(onCancel: expectAsync0(() {}));
completer.complete(new Completer().future);
expect(completer.operation.cancel(), completes);
});

test("doesn't call onCancel if the completer has completed to a fired "
"Future", () async {
var completer = new CancelableCompleter(
onCancel: expectAsync(() {}, count: 0));
onCancel: expectAsync0(() {}, count: 0));
completer.complete(new Future.value(1));
await completer.operation.value;
expect(completer.operation.cancel(), completes);
});

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

test("cancels the completer when the subscription is canceled", () {
var completer = new CancelableCompleter(onCancel: expectAsync(() {}));
var completer = new CancelableCompleter(onCancel: expectAsync0(() {}));
var sub = completer.operation.asStream()
.listen(expectAsync((_) {}, count: 0));
completer.operation.value.whenComplete(expectAsync(() {}, count: 0));
.listen(expectAsync1((_) {}, count: 0));
completer.operation.value.whenComplete(expectAsync0(() {}, count: 0));
sub.cancel();
expect(completer.isCanceled, isTrue);
});
Expand Down
6 changes: 3 additions & 3 deletions test/future_group_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ void main() {
var onIdleDone = false;
var futureFired = false;

futureGroup.onIdle.listen(expectAsync((_) {
futureGroup.onIdle.listen(expectAsync1((_) {
expect(futureFired, isFalse);
idle = true;
}), onDone: expectAsync(() {
}), onDone: expectAsync0(() {
expect(idle, isTrue);
expect(futureFired, isFalse);
onIdleDone = true;
}));

futureGroup.future.then(expectAsync((_) {
futureGroup.future.then(expectAsync1((_) {
expect(idle, isTrue);
expect(onIdleDone, isTrue);
futureFired = true;
Expand Down
12 changes: 6 additions & 6 deletions test/lazy_stream_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ main() {

test("calls the callback when the stream is listened", () async {
var callbackCalled = false;
var stream = new LazyStream(expectAsync(() {
var stream = new LazyStream(expectAsync0(() {
callbackCalled = true;
return new Stream.empty();
}));
Expand All @@ -30,7 +30,7 @@ main() {

test("calls the callback when the stream is listened", () async {
var callbackCalled = false;
var stream = new LazyStream(expectAsync(() {
var stream = new LazyStream(expectAsync0(() {
callbackCalled = true;
return new Stream.empty();
}));
Expand All @@ -44,7 +44,7 @@ main() {

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

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

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

var events = [];
stream.listen(events.add);
Expand All @@ -87,7 +87,7 @@ main() {
});

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

stream.listen(null);
Expand All @@ -97,7 +97,7 @@ main() {

test("a lazy stream can't be listened to from within its callback", () {
var stream;
stream = new LazyStream(expectAsync(() {
stream = new LazyStream(expectAsync0(() {
expect(() => stream.listen(null), throwsStateError);
return new Stream.empty();
}));
Expand Down
2 changes: 1 addition & 1 deletion test/restartable_timer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ main() {
new FakeAsync().run((async) {
new RestartableTimer(
new Duration(seconds: 5),
expectAsync(() {}, count: 1));
expectAsync0(() {}, count: 1));
async.elapse(new Duration(seconds: 10));
});
});
Expand Down
44 changes: 22 additions & 22 deletions test/result_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void main() {
test("complete with value", () {
Result<int> result = new ValueResult<int>(42);
var c = new Completer<int>();
c.future.then(expectAsync((int v) { expect(v, equals(42)); }),
c.future.then(expectAsync1((int v) { expect(v, equals(42)); }),
onError: (e, s) { fail("Unexpected error"); });
result.complete(c);
});
Expand All @@ -67,7 +67,7 @@ void main() {
Result<bool> result = new ErrorResult("BAD", stack);
var c = new Completer<bool>();
c.future.then((bool v) { fail("Unexpected value $v"); },
onError: expectAsync((e, s) {
onError: expectAsync2((e, s) {
expect(e, equals("BAD"));
expect(s, same(stack));
}));
Expand All @@ -77,15 +77,15 @@ void main() {
test("add sink value", () {
var result = new ValueResult<int>(42);
EventSink<int> sink = new TestSink(
onData: expectAsync((v) { expect(v, equals(42)); })
onData: expectAsync1((v) { expect(v, equals(42)); })
);
result.addTo(sink);
});

test("add sink error", () {
Result<bool> result = new ErrorResult("BAD", stack);
EventSink<bool> sink = new TestSink(
onError: expectAsync((e, s) {
onError: expectAsync2((e, s) {
expect(e, equals("BAD"));
expect(s, same(stack));
})
Expand All @@ -95,22 +95,22 @@ void main() {

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

test("error as future", () {
Result<bool> result = new ErrorResult("BAD", stack);
result.asFuture.then((bool v) { fail("Unexpected value $v"); },
onError: expectAsync((e, s) {
onError: expectAsync2((e, s) {
expect(e, equals("BAD"));
expect(s, same(stack));
}));
});

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

test("capture future error", () {
Future<bool> value = new Future<bool>.error("BAD", stack);
Result.capture(value).then(expectAsync((Result result) {
Result.capture(value).then(expectAsync1((Result result) {
expect(result.isValue, isFalse);
expect(result.isError, isTrue);
ErrorResult error = result.asError;
Expand All @@ -136,7 +136,7 @@ void main() {
test("release future value", () {
Future<Result<int>> future =
new Future<Result<int>>.value(new Result<int>.value(42));
Result.release(future).then(expectAsync((v) {
Result.release(future).then(expectAsync1((v) {
expect(v, equals(42));
}), onError: (e, s) {
fail("Unexpected error: $e");
Expand All @@ -149,7 +149,7 @@ void main() {
new Future<Result<bool>>.value(new Result<bool>.error("BAD", stack));
Result.release(future).then((v) {
fail("Unexpected value: $v");
}, onError: expectAsync((e, s) {
}, onError: expectAsync2((e, s) {
expect(e, equals("BAD"));
expect(s, same(stack));
}));
Expand All @@ -160,7 +160,7 @@ void main() {
Future<Result<bool>> future = new Future<Result<bool>>.error("BAD", stack);
Result.release(future).then((v) {
fail("Unexpected value: $v");
}, onError: expectAsync((e, s) {
}, onError: expectAsync2((e, s) {
expect(e, equals("BAD"));
expect(s, same(stack));
}));
Expand All @@ -176,9 +176,9 @@ void main() {
expect(expectedList.isEmpty, isFalse);
expectResult(actual, expectedList.removeFirst());
}
stream.listen(expectAsync(listener, count: 3),
stream.listen(expectAsync1(listener, count: 3),
onError: (e, s) { fail("Unexpected error: $e"); },
onDone: expectAsync((){}),
onDone: expectAsync0((){}),
cancelOnError: true);
c.add(42);
c.addError("BAD", stack);
Expand Down Expand Up @@ -211,9 +211,9 @@ void main() {
expect(stackTrace, same(expected.asError.stackTrace));
}

stream.listen(expectAsync(dataListener, count: 2),
onError: expectAsync(errorListener, count: 2),
onDone: expectAsync((){}));
stream.listen(expectAsync1(dataListener, count: 2),
onError: expectAsync2(errorListener, count: 2),
onDone: expectAsync0((){}));
for (Result<int> result in events) {
c.add(result); // Result value or error in data line.
}
Expand All @@ -224,8 +224,8 @@ void main() {
test("release stream cancel on error", () {
StreamController<Result<int>> c = new StreamController<Result<int>>();
Stream<int> stream = Result.releaseStream(c.stream);
stream.listen(expectAsync((v) { expect(v, equals(42)); }),
onError: expectAsync((e, s) {
stream.listen(expectAsync1((v) { expect(v, equals(42)); }),
onError: expectAsync2((e, s) {
expect(e, equals("BAD"));
expect(s, same(stack));
}),
Expand Down Expand Up @@ -259,7 +259,7 @@ void main() {
});

test("handle unary", () {
var result = new Result.error("error", stack);
ErrorResult result = new Result.error("error", stack);
bool called = false;
result.handle((error) {
called = true;
Expand All @@ -269,7 +269,7 @@ void main() {
});

test("handle binary", () {
var result = new Result.error("error", stack);
ErrorResult result = new Result.error("error", stack);
bool called = false;
result.handle((error, stackTrace) {
called = true;
Expand All @@ -280,7 +280,7 @@ void main() {
});

test("handle unary and binary", () {
var result = new Result.error("error", stack);
ErrorResult result = new Result.error("error", stack);
bool called = false;
result.handle((error, [stackTrace]) {
called = true;
Expand All @@ -291,7 +291,7 @@ void main() {
});

test("handle neither unary nor binary", () {
var result = new Result.error("error", stack);
ErrorResult result = new Result.error("error", stack);
expect(() => result.handle(() => fail("unreachable")),
throws);
expect(() => result.handle((a, b, c) => fail("unreachable")),
Expand Down
8 changes: 4 additions & 4 deletions test/stream_completer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@ main() {
var completer = new StreamCompleter();
completer.stream.listen(
unreachable("data"),
onError: expectAsync((error, stackTrace) {
onError: expectAsync2((error, stackTrace) {
expect(error, equals("oh no"));
}),
onDone: expectAsync(() {}));
onDone: expectAsync0(() {}));

completer.setError("oh no");
});
Expand All @@ -359,10 +359,10 @@ main() {

completer.stream.listen(
unreachable("data"),
onError: expectAsync((error, stackTrace) {
onError: expectAsync2((error, stackTrace) {
expect(error, equals("oh no"));
}),
onDone: expectAsync(() {}));
onDone: expectAsync0(() {}));
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/stream_group_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ main() {
var canceled = false;
var controller = new StreamController<String>(onListen: () {
listened = true;
}, onCancel: expectAsync(() {
}, onCancel: expectAsync0(() {
expect(listened, isTrue);
canceled = true;
}));
Expand Down Expand Up @@ -357,7 +357,7 @@ main() {
var subscription = streamGroup.stream.listen(null);

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

streamGroup.add(controller.stream);
await flushMicrotasks();
Expand Down
Loading