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:
Lasse R.H. Nielsen 2017-12-06 09:11:36 +00:00
parent c1f148ec42
commit 7f91a438f5
2 changed files with 23 additions and 13 deletions

View file

@ -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();
}();
}

View file

@ -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();
}();
}