Files
sdk/tests/lib_2/async/intercept_schedule_microtask6_test.dart
T
Ben Konyi 0ea752b5bf Relanding test block 170 migration.
"Migrated test block 170 to Dart 2.0.""

This reverts commit 201df65b50201f023a1db5bb26bea7b8976c3b32.

Review-Url: https://codereview.chromium.org/3005813002 .
2017-08-29 16:22:07 -07:00

55 lines
1.1 KiB
Dart

// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:async_helper/async_helper.dart';
import "package:expect/expect.dart";
import 'dart:async';
import 'catch_errors.dart';
class A {
add(x) => print(x);
}
var events = [];
body() {
events.add("body entry");
scheduleMicrotask(() {
events.add("run async body");
throw "foo";
});
return 499;
}
onAsyncHandler(fun) {
events.add("async handler");
scheduleMicrotask(fun);
events.add("async handler done");
}
onErrorHandler(e) {
events.add("error: $e");
}
main() {
asyncStart();
// Test that runZonedScheduleMicrotask works when async, error and done
// are used.
var result = runZonedScheduleMicrotask(body,
onScheduleMicrotask: onAsyncHandler, onError: onErrorHandler);
events.add("after");
Timer.run(() {
Expect.listEquals([
"body entry",
"async handler",
"async handler done",
"after",
"run async body",
"error: foo"
], events);
asyncEnd();
});
}