Index: tests/lib/async/stream_controller_async_test.dart |
diff --git a/tests/lib/async/stream_controller_async_test.dart b/tests/lib/async/stream_controller_async_test.dart |
index 3fed8a88cf890633e91db5a732220c8fadc21627..801f064d9dd5e5716475a149d5d9a615c7f3a70a 100644 |
--- a/tests/lib/async/stream_controller_async_test.dart |
+++ b/tests/lib/async/stream_controller_async_test.dart |
@@ -6,8 +6,7 @@ |
library stream_controller_async_test; |
import 'dart:async'; |
-import "package:expect/expect.dart"; |
-import 'package:unittest/unittest.dart'; |
+import 'package:test/test.dart'; |
import 'event_helper.dart'; |
import 'stream_state_helper.dart'; |
@@ -20,7 +19,7 @@ testController() { |
Stream stream = c.stream.asBroadcastStream(onCancel: cancelSub); |
stream.fold(0, (a,b) => a + b) |
.then(expectAsync((int v) { |
- Expect.equals(42, v); |
+ expect(42, equals(v)); |
})); |
c.add(10); |
c.add(32); |
@@ -31,7 +30,7 @@ testController() { |
StreamController c = new StreamController(); |
Stream stream = c.stream.asBroadcastStream(onCancel: cancelSub); |
stream.fold(0, (a,b) { throw "Fnyf!"; }) |
- .catchError(expectAsync((error) { Expect.equals("Fnyf!", error); })); |
+ .catchError(expectAsync((error) { expect("Fnyf!", equals(error)); })); |
c.add(42); |
}); |
} |
@@ -41,7 +40,7 @@ testSingleController() { |
StreamController c = new StreamController(); |
Stream stream = c.stream; |
stream.fold(0, (a,b) => a + b) |
- .then(expectAsync((int v) { Expect.equals(42, v); })); |
+ .then(expectAsync((int v) { expect(42, equals(v)); })); |
c.add(10); |
c.add(32); |
c.close(); |
@@ -51,7 +50,7 @@ testSingleController() { |
StreamController c = new StreamController(); |
Stream stream = c.stream; |
stream.fold(0, (a,b) { throw "Fnyf!"; }) |
- .catchError(expectAsync((e) { Expect.equals("Fnyf!", e); })); |
+ .catchError(expectAsync((e) { expect("Fnyf!", equals(e)); })); |
c.add(42); |
}); |
@@ -70,7 +69,7 @@ testSingleController() { |
counter += data; |
}, |
onDone: expectAsync(() { |
- Expect.equals(3, counter); |
+ expect(3, equals(counter)); |
})); |
}); |
} |
@@ -84,7 +83,7 @@ testExtraMethods() { |
Future f = c.stream.forEach(actualEvents.add); |
f.then(expectAsync((_) { |
actualEvents.close(); |
- Expect.listEquals(sentEvents.events, actualEvents.events); |
+ expect(sentEvents.events, equals(actualEvents.events)); |
})); |
sentEvents.replay(c); |
}); |
@@ -95,8 +94,8 @@ testExtraMethods() { |
Events actualEvents = new Events(); |
Future f = c.stream.forEach(actualEvents.add); |
f.catchError(expectAsync((error) { |
- Expect.equals("bad", error); |
- Expect.listEquals((new Events()..add(7)).events, actualEvents.events); |
+ expect("bad", equals(error)); |
+ expect((new Events()..add(7)).events, equals(actualEvents.events)); |
})); |
sentEvents.replay(c); |
}); |
@@ -110,8 +109,8 @@ testExtraMethods() { |
actualEvents.add(x); |
}); |
f.catchError(expectAsync((error) { |
- Expect.equals("bad", error); |
- Expect.listEquals((new Events()..add(7)).events, actualEvents.events); |
+ expect("bad", equals(error)); |
+ expect((new Events()..add(7)).events, equals(actualEvents.events)); |
})); |
sentEvents.replay(c); |
}); |
@@ -119,7 +118,7 @@ testExtraMethods() { |
test("firstWhere", () { |
StreamController c = new StreamController(); |
Future f = c.stream.firstWhere((x) => (x % 3) == 0); |
- f.then(expectAsync((v) { Expect.equals(9, v); })); |
+ f.then(expectAsync((v) { expect(9, equals(v)); })); |
sentEvents.replay(c); |
}); |
@@ -133,7 +132,7 @@ testExtraMethods() { |
test("firstWhere 3", () { |
StreamController c = new StreamController(); |
Future f = c.stream.firstWhere((x) => (x % 4) == 0, defaultValue: () => 999); |
- f.then(expectAsync((v) { Expect.equals(999, v); })); |
+ f.then(expectAsync((v) { expect(999, equals(v)); })); |
sentEvents.replay(c); |
}); |
@@ -141,7 +140,7 @@ testExtraMethods() { |
test("lastWhere", () { |
StreamController c = new StreamController(); |
Future f = c.stream.lastWhere((x) => (x % 3) == 0); |
- f.then(expectAsync((v) { Expect.equals(87, v); })); |
+ f.then(expectAsync((v) { expect(87, equals(v)); })); |
sentEvents.replay(c); |
}); |
@@ -155,35 +154,35 @@ testExtraMethods() { |
test("lastWhere 3", () { |
StreamController c = new StreamController(); |
Future f = c.stream.lastWhere((x) => (x % 4) == 0, defaultValue: () => 999); |
- f.then(expectAsync((v) { Expect.equals(999, v); })); |
+ f.then(expectAsync((v) { expect(999, equals(v)); })); |
sentEvents.replay(c); |
}); |
test("singleWhere", () { |
StreamController c = new StreamController(); |
Future f = c.stream.singleWhere((x) => (x % 9) == 0); |
- f.then(expectAsync((v) { Expect.equals(9, v); })); |
+ f.then(expectAsync((v) { expect(9, equals(v)); })); |
sentEvents.replay(c); |
}); |
test("singleWhere 2", () { |
StreamController c = new StreamController(); |
Future f = c.stream.singleWhere((x) => (x % 3) == 0); // Matches 9 and 87.. |
- f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); })); |
+ f.catchError(expectAsync((error) { expect(error is StateError, isTrue); })); |
sentEvents.replay(c); |
}); |
test("first", () { |
StreamController c = new StreamController(); |
Future f = c.stream.first; |
- f.then(expectAsync((v) { Expect.equals(7, v);})); |
+ f.then(expectAsync((v) { expect(7, equals(v)); })); |
sentEvents.replay(c); |
}); |
test("first empty", () { |
StreamController c = new StreamController(); |
Future f = c.stream.first; |
- f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); })); |
+ f.catchError(expectAsync((error) { expect(error is StateError, isTrue); })); |
Events emptyEvents = new Events()..close(); |
emptyEvents.replay(c); |
}); |
@@ -191,7 +190,7 @@ testExtraMethods() { |
test("first error", () { |
StreamController c = new StreamController(); |
Future f = c.stream.first; |
- f.catchError(expectAsync((error) { Expect.equals("error", error); })); |
+ f.catchError(expectAsync((error) { expect("error", equals(error)); })); |
Events errorEvents = new Events()..error("error")..close(); |
errorEvents.replay(c); |
}); |
@@ -199,7 +198,7 @@ testExtraMethods() { |
test("first error 2", () { |
StreamController c = new StreamController(); |
Future f = c.stream.first; |
- f.catchError(expectAsync((error) { Expect.equals("error", error); })); |
+ f.catchError(expectAsync((error) { expect("error", equals(error)); })); |
Events errorEvents = new Events()..error("error")..error("error2")..close(); |
errorEvents.replay(c); |
}); |
@@ -207,14 +206,14 @@ testExtraMethods() { |
test("last", () { |
StreamController c = new StreamController(); |
Future f = c.stream.last; |
- f.then(expectAsync((v) { Expect.equals(87, v);})); |
+ f.then(expectAsync((v) { expect(87, equals(v)); })); |
sentEvents.replay(c); |
}); |
test("last empty", () { |
StreamController c = new StreamController(); |
Future f = c.stream.last; |
- f.catchError(expectAsync((error) { Expect.isTrue(error is StateError); })); |
+ f.catchError(expectAsync((error) { expect(error is StateError, isTrue); })); |
Events emptyEvents = new Events()..close(); |
emptyEvents.replay(c); |
}); |
@@ -222,7 +221,7 @@ testExtraMethods() { |
test("last error", () { |
StreamController c = new StreamController(); |
Future f = c.stream.last; |
- f.catchError(expectAsync((error) { Expect.equals("error", error); })); |
+ f.catchError(expectAsync((error) { expect("error", equals(error)); })); |
Events errorEvents = new Events()..error("error")..close(); |
errorEvents.replay(c); |
}); |
@@ -230,7 +229,7 @@ testExtraMethods() { |
test("last error 2", () { |
StreamController c = new StreamController(); |
Future f = c.stream.last; |
- f.catchError(expectAsync((error) { Expect.equals("error", error); })); |
+ f.catchError(expectAsync((error) { expect("error", equals(error)); })); |
Events errorEvents = new Events()..error("error")..error("error2")..close(); |
errorEvents.replay(c); |
}); |
@@ -238,28 +237,28 @@ testExtraMethods() { |
test("elementAt", () { |
StreamController c = new StreamController(); |
Future f = c.stream.elementAt(2); |
- f.then(expectAsync((v) { Expect.equals(13, v);})); |
+ f.then(expectAsync((v) { expect(13, equals(v)); })); |
sentEvents.replay(c); |
}); |
test("elementAt 2", () { |
StreamController c = new StreamController(); |
Future f = c.stream.elementAt(20); |
- f.catchError(expectAsync((error) { Expect.isTrue(error is RangeError); })); |
+ f.catchError(expectAsync((error) { expect(error is RangeError, isTrue); })); |
sentEvents.replay(c); |
}); |
test("drain", () { |
StreamController c = new StreamController(); |
Future f = c.stream.drain(); |
- f.then(expectAsync((v) { Expect.equals(null, v);})); |
+ f.then(expectAsync((v) { expect(null, equals(v)); })); |
sentEvents.replay(c); |
}); |
test("drain error", () { |
StreamController c = new StreamController(); |
Future f = c.stream.drain(); |
- f.catchError(expectAsync((error) { Expect.equals("error", error); })); |
+ f.catchError(expectAsync((error) { expect("error", equals(error)); })); |
Events errorEvents = new Events()..error("error")..error("error2")..close(); |
errorEvents.replay(c); |
}); |
@@ -366,8 +365,8 @@ testRethrow() { |
test("rethrow-$name-value", () { |
StreamController c = new StreamController(); |
Stream s = streamValueTransform(c.stream, (v) { throw error; }); |
- s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync( |
- (e) { Expect.identical(error, e); })); |
+ s.listen((_) { fail("unexpected value"); }, onError: expectAsync( |
+ (e) { expect(error, same(e)); })); |
c.add(null); |
c.close(); |
}); |
@@ -377,8 +376,8 @@ testRethrow() { |
test("rethrow-$name-error", () { |
StreamController c = new StreamController(); |
Stream s = streamErrorTransform(c.stream, (e) { throw error; }); |
- s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync( |
- (e) { Expect.identical(error, e); })); |
+ s.listen((_) { fail("unexpected value"); }, onError: expectAsync( |
+ (e) { expect(error, same(e)); })); |
c.addError("SOME ERROR"); |
c.close(); |
}); |
@@ -388,8 +387,8 @@ testRethrow() { |
test("rethrow-$name-value", () { |
StreamController c = new StreamController(); |
Future f = streamValueTransform(c.stream, (v) { throw error; }); |
- f.then((v) { Expect.fail("unreachable"); }, |
- onError: expectAsync((e) { Expect.identical(error, e); })); |
+ f.then((v) { fail("unreachable"); }, |
+ onError: expectAsync((e) { expect(error, same(e)); })); |
// Need two values to trigger compare for reduce. |
c.add(0); |
c.add(1); |
@@ -587,7 +586,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
return sink.close(); |
}) |
.then((_) { |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
done(); |
}); |
}); |
@@ -612,7 +611,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
sink.addError("error"); |
sink.addStream(new Stream.fromIterable([1, 2, 3, 4, 5])) |
.then((_) { |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
// Close controller as well. It has no listener. If it is a broadcast |
// stream, it will still be open, and we read the "done" future before |
// closing. A normal stream is already done when its listener cancels. |
@@ -622,7 +621,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
}) |
.then((_) { |
// No change in events. |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
done(); |
}); |
}); |
@@ -665,11 +664,11 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
// Wait for the done event to be *delivered* before testing the |
// events. |
actual.onDone(() { |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
done(); |
}); |
} else { |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
done(); |
} |
}); |
@@ -691,7 +690,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
StreamController sourceController = new StreamController(); |
c.addStream(sourceController.stream).then((_) { |
c.close().then((_) { |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
done(); |
}); |
}); |
@@ -715,7 +714,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
StreamController sourceController = new StreamController(); |
c.addStream(sourceController.stream, cancelOnError: false).then((_) { |
c.close().then((_) { |
- Expect.listEquals(source.events, actual.events); |
+ expect(source.events, equals(actual.events)); |
done(); |
}); |
}); |
@@ -746,7 +745,7 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) { |
c.addStream(s1).then((_) { |
c.addStream(s2, cancelOnError: false).then((_) { |
c.close().then((_) { |
- Expect.listEquals(expected.events, actual.events); |
+ expect(expected.events, equals(actual.events)); |
done(); |
}); |
}); |