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

Unified Diff: tests/async_helper.dart

Issue 23701010: Switch to async_helper package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and adapt 3 new tests. Created 7 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 | « no previous file | tests/compiler/dart2js_extra/deferred/deferred_class_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/async_helper.dart
diff --git a/tests/async_helper.dart b/tests/async_helper.dart
deleted file mode 100644
index f1a84b369f782285c87d0250fa5ef5ece290a8b3..0000000000000000000000000000000000000000
--- a/tests/async_helper.dart
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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.
-
-/// This library is used for testing asynchronous tests.
-/// If a test is asynchronous, it needs to notify the testing driver
-/// about this (otherwise tests may get reported as passing [after main()
-/// finished] even if the asynchronous operations fail).
-/// Tests which can't use the unittest framework should use the helper functions
-/// in this library.
-/// This library provides two methods
-/// - asyncStart(): Needs to be called before an asynchronous operation is
-/// scheduled.
-/// - asyncEnd(): Needs to be called as soon as the asynchronous operation
-/// ended.
-/// After the last asyncStart() called was matched with a corresponding
-/// asyncEnd() call, the testing driver will be notified that the tests is done.
-
-library async_helper;
-
-// TODO(kustermann): This is problematic because we rely on a working
-// 'dart:isolate' (i.e. it is in particular problematic with dart2js).
-// It would be nice if we could use a different mechanism for different
-// runtimes.
-import 'dart:isolate';
-
-bool _initialized = false;
-ReceivePort _port = null;
-int _asyncLevel = 0;
-
-Exception _buildException(String msg) {
- return new Exception('Fatal: $msg. This is most likely a bug in your test.');
-}
-
-void asyncStart() {
- if (_initialized && _asyncLevel == 0) {
- throw _buildException('asyncStart() was called even though we are done '
- 'with testing.');
- }
- if (!_initialized) {
- print('unittest-suite-wait-for-done');
- _initialized = true;
- _port = new ReceivePort();
- }
- _asyncLevel++;
-}
-
-void asyncEnd() {
- if (_asyncLevel <= 0) {
- if (!_initialized) {
- throw _buildException('asyncEnd() was called before asyncStart().');
- } else {
- throw _buildException('asyncEnd() was called more often than '
- 'asyncStart().');
- }
- }
- _asyncLevel--;
- if (_asyncLevel == 0) {
- _port.close();
- _port = null;
- print('unittest-suite-success');
- }
-}
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/deferred/deferred_class_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698