Index: tests/lib/async/future_test.dart |
diff --git a/tests/lib/async/future_test.dart b/tests/lib/async/future_test.dart |
index 6feffe16ee50c41932d4283bc2b3b0d4d98ded3d..224e49606383abb8e70cced842cb933e29b8e7b5 100644 |
--- a/tests/lib/async/future_test.dart |
+++ b/tests/lib/async/future_test.dart |
@@ -10,8 +10,8 @@ import 'dart:isolate'; |
const Duration MS = const Duration(milliseconds: 1); |
-testImmediate() { |
- final future = new Future<String>.immediate("42"); |
+testValue() { |
+ final future = new Future<String>.value("42"); |
var port = new ReceivePort(); |
future.then((x) { |
Expect.equals("42", x); |
@@ -19,11 +19,11 @@ testImmediate() { |
}); |
} |
-testOf() { |
+testSync() { |
compare(func) { |
// Compare the results of the following two futures. |
- Future f1 = new Future.of(func); |
- Future f2 = new Future.immediate(null).then((_) => func()); |
+ Future f1 = new Future.sync(func); |
+ Future f2 = new Future.value().then((_) => func()); |
f2.catchError((_){}); // I'll get the error later. |
f1.then((v1) { f2.then((v2) { Expect.equals(v1, v2); }); }, |
onError: (e1) { |
@@ -33,15 +33,21 @@ testOf() { |
}); |
}); |
} |
- Future val = new Future.immediate(42); |
- Future err1 = new Future.immediateError("Error")..catchError((_){}); |
- Future err2 = new Future.immediateError(new AsyncError("AsyncError"))..catchError((_){}); |
+ Future val = new Future.value(42); |
+ Future err1 = new Future.error("Error")..catchError((_){}); |
+ Future err2 = new Future.error(new AsyncError("AsyncError"))..catchError((_){}); |
compare(() => 42); |
compare(() => val); |
compare(() { throw "Flif"; }); |
compare(() { throw new AsyncError("AsyncFlif"); }); |
compare(() => err1); |
compare(() => err2); |
+ bool hasExecuted = false; |
+ compare(() { |
+ hasExecuted = true; |
+ return 499; |
+ }); |
+ Expect.isTrue(hasExecuted); |
} |
testNeverComplete() { |
@@ -240,7 +246,7 @@ testFutureAsStreamCompleteBefore() { |
testFutureAsStreamCompleteImmediate() { |
bool gotValue = false; |
var port = new ReceivePort(); |
- new Future.immediate("value").asStream().listen( |
+ new Future.value("value").asStream().listen( |
(data) { |
Expect.isFalse(gotValue); |
gotValue = true; |
@@ -562,7 +568,7 @@ testChainedFutureValue() { |
final future = completer.future; |
var port = new ReceivePort(); |
- future.then((v) => new Future.immediate(v * 2)) |
+ future.then((v) => new Future.value(v * 2)) |
.then((v) { |
Expect.equals(42, v); |
port.close(); |
@@ -598,7 +604,7 @@ testChainedFutureError() { |
final future = completer.future; |
var port = new ReceivePort(); |
- future.then((v) => new Future.immediateError("Fehler")) |
+ future.then((v) => new Future.error("Fehler")) |
.then((v) { Expect.fail("unreachable!"); }, onError: (e) { |
Expect.equals("Fehler", e.error); |
port.close(); |
@@ -607,8 +613,8 @@ testChainedFutureError() { |
} |
main() { |
- testImmediate(); |
- testOf(); |
+ testValue(); |
+ testSync(); |
testNeverComplete(); |
testComplete(); |