Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: tests/lib/async/async_await_zones_test.dart

Issue 1296973002: Revert "Don't zone-register async callbacks for every await call in the VM." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/async_await_zones_test.dart
diff --git a/tests/lib/async/async_await_zones_test.dart b/tests/lib/async/async_await_zones_test.dart
deleted file mode 100644
index 210b05dee778929c0d7d3f3757afd3146e927214..0000000000000000000000000000000000000000
--- a/tests/lib/async/async_await_zones_test.dart
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (c) 2015, 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.
-
-// Test that async functions don't zone-register their callbacks for each
-// await. Async functions should register their callback once in the beginning
-// and then reuse it for all awaits in their body.
-// This has two advantages: it is faster, when there are several awaits (on
-// the Future class from dart:async), and it avoids zone-nesting when tracing
-// stacktraces.
-// See http://dartbug.com/23394 for more information.
-
-import 'dart:async';
-import 'package:expect/expect.dart';
-import 'package:async_helper/async_helper.dart';
-
-gee(i) async {
- return await i;
-}
-
-bar() async* {
- var i = 0;
- while (true) yield await gee(i++);
-}
-
-
-awaitForTest() async {
- var sum = 0;
- await for (var x in bar().take(100)) {
- sum += x;
- }
- Expect.equals(4950, sum);
-}
-
-awaitTest() async {
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- await null;
- return await 499;
-}
-
-runTests() async {
- await awaitTest();
- await awaitForTest();
-}
-
-var depth = 0;
-
-var depthIncreases = 0;
-
-increaseDepth() {
- depthIncreases++;
- depth++;
- // The async/await code should not register callbacks recursively in the
- // then-calls. As such the depth should never grow too much. We don't want
- // to commit to a specific value, since implementations still have some
- // room in how async/await is implemented, but 20 should be safe.
- Expect.isTrue(depth < 20);
-}
-
-registerCallback(Zone self, ZoneDelegate parent, Zone zone, f) {
- var oldDepth = depth;
- increaseDepth();
- return parent.registerCallback(zone, () {
- depth = oldDepth;
- return f();
- });
-}
-registerUnaryCallback(Zone self, ZoneDelegate parent, Zone zone, f) {
- var oldDepth = depth;
- increaseDepth();
- return parent.registerUnaryCallback(zone, (x) {
- depth = oldDepth;
- return f(x);
- });
-}
-registerBinaryCallback(Zone self, ZoneDelegate parent, Zone zone, f) {
- var oldDepth = depth;
- increaseDepth();
- return parent.registerBinaryCallback(zone, (x, y) {
- depth = oldDepth;
- return f(x, y);
- });
-}
-
-sm(Zone self, ZoneDelegate parent, Zone zone, f) {
- var oldDepth = depth;
- increaseDepth();
- return parent.scheduleMicrotask(zone, () {
- depth = oldDepth;
- return f();
- });
-}
-
-main() {
- asyncStart();
- var desc = new ZoneSpecification(
- registerCallback: registerCallback,
- registerUnaryCallback: registerUnaryCallback,
- registerBinaryCallback: registerBinaryCallback,
- scheduleMicrotask: sm
- );
- var future = runZoned(runTests, zoneSpecification: desc);
- future.then((_) => asyncEnd());
-}
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698