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

Unified Diff: tests/language/async_star_cancel_while_paused_test.dart

Issue 2985173002: Migrate language/async_backwards... ... language/async_star_take... (Closed)
Patch Set: Update tests to Dart 2.0. Created 3 years, 5 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
Index: tests/language/async_star_cancel_while_paused_test.dart
diff --git a/tests/language/async_star_cancel_while_paused_test.dart b/tests/language/async_star_cancel_while_paused_test.dart
deleted file mode 100644
index b23d758e88fb368af4752276b32e0850f7ea1786..0000000000000000000000000000000000000000
--- a/tests/language/async_star_cancel_while_paused_test.dart
+++ /dev/null
@@ -1,68 +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.
-
-// This is a regression test for issue 22853.
-
-import "dart:async";
-import "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-
-main() {
- var list = [];
- var sync = new Sync();
- f() async* {
- list.add("*1");
- yield 1;
- await sync.wait();
- sync.release();
- list.add("*2");
- yield 2;
- list.add("*3");
- }
-
- ;
- var stream = f();
- var sub = stream.listen(list.add);
-
- asyncStart();
- return sync.wait().whenComplete(() {
- Expect.listEquals(list, ["*1", 1]);
- sub.pause();
- return sync.wait();
- }).whenComplete(() {
- Expect.listEquals(list, ["*1", 1, "*2"]);
- sub.cancel();
- new Future.delayed(new Duration(milliseconds: 200), () {
- // Should not have yielded 2 or added *3 while paused.
- Expect.listEquals(list, ["*1", 1, "*2"]);
- asyncEnd();
- });
- });
-}
-
-/**
- * Allows two asynchronous executions to synchronize.
- *
- * Calling [wait] and waiting for the returned future to complete will
- * wait for the other executions to call [wait] again. At that point,
- * the waiting execution is allowed to continue (the returned future completes),
- * and the more recent call to [wait] is now the waiting execution.
- */
-class Sync {
- Completer _completer = null;
- // Release whoever is currently waiting and start waiting yourself.
- Future wait([v]) {
- if (_completer != null) _completer.complete(v);
- _completer = new Completer();
- return _completer.future;
- }
-
- // Release whoever is currently waiting.
- void release([v]) {
- if (_completer != null) {
- _completer.complete(v);
- _completer = null;
- }
- }
-}
« no previous file with comments | « tests/language/async_star_cancel_and_throw_in_finally_test.dart ('k') | tests/language/async_star_no_cancel2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698