Fixes async for two other language_2 tests.
Change-Id: Id805a913275468f70cfbe03e37f2534fad6aaab8 Reviewed-on: https://dart-review.googlesource.com/26221 Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
typedef Future<Null> Task();
|
||||
|
||||
@@ -65,8 +66,12 @@ Future<String> world() async {
|
||||
return 'world';
|
||||
}
|
||||
|
||||
Future main() async {
|
||||
var r2 = await world();
|
||||
Expect.equals('hello', r1);
|
||||
Expect.equals('world', r2);
|
||||
void main() {
|
||||
asyncStart();
|
||||
() async {
|
||||
var r2 = await world();
|
||||
Expect.equals('hello', r1);
|
||||
Expect.equals('world', r2);
|
||||
asyncEnd();
|
||||
}();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import "dart:async";
|
||||
import "package:expect/expect.dart";
|
||||
import "package:async_helper/async_helper.dart";
|
||||
|
||||
var result = "";
|
||||
|
||||
@@ -15,14 +16,18 @@ bar() async {
|
||||
result += "bar";
|
||||
}
|
||||
|
||||
main() async {
|
||||
var f = new Future(foo);
|
||||
var b = bar();
|
||||
Expect.equals("", result);
|
||||
scheduleMicrotask(() => result += "micro");
|
||||
await b;
|
||||
await f;
|
||||
main() {
|
||||
asyncStart();
|
||||
() async {
|
||||
var f = new Future(foo);
|
||||
var b = bar();
|
||||
Expect.equals("", result);
|
||||
scheduleMicrotask(() => result += "micro");
|
||||
await b;
|
||||
await f;
|
||||
|
||||
// Validates that bar is scheduled as a microtask, before foo.
|
||||
Expect.equals("barmicrofoo", result);
|
||||
// Validates that bar is scheduled as a microtask, before foo.
|
||||
Expect.equals("barmicrofoo", result);
|
||||
asyncEnd();
|
||||
}();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user