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

Unified Diff: tests/isolate/count_test.dart

Issue 10837070: Remove old isolate API and update all code in the repository to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 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
« no previous file with comments | « tests/isolate/constructor_test.dart ('k') | tests/isolate/cross_isolate_message_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/count_test.dart
diff --git a/tests/isolate/count_test.dart b/tests/isolate/count_test.dart
index d4fe5ff176bfc2765a9aaecc03756e7fe220eaec..5c8638e5ee7e489edeee33fe0ab2332da182bf99 100644
--- a/tests/isolate/count_test.dart
+++ b/tests/isolate/count_test.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, 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.
@@ -6,48 +6,41 @@
#import('dart:isolate');
#import('../../lib/unittest/unittest.dart');
-class TestIsolate extends Isolate {
-
- TestIsolate() : super();
-
- void main() {
- int count = 0;
- this.port.receive((int message, SendPort replyTo) {
- if (message == -1) {
- Expect.equals(10, count);
- replyTo.send(-1, null);
- this.port.close();
- return;
- }
-
- Expect.equals(count, message);
- count++;
- replyTo.send(message * 2, null);
- });
- }
+void countMessages() {
+ int count = 0;
+ port.receive((int message, SendPort replyTo) {
+ if (message == -1) {
+ Expect.equals(10, count);
+ replyTo.send(-1, null);
+ port.close();
+ return;
+ }
+ Expect.equals(count, message);
+ count++;
+ replyTo.send(message * 2, null);
+ });
}
void main() {
test("count 10 consecutive messages", () {
int count = 0;
- new TestIsolate().spawn().then(expectAsync1((SendPort remote) {
- ReceivePort local = new ReceivePort();
- SendPort reply = local.toSendPort();
+ SendPort remote = spawnFunction(countMessages);
+ ReceivePort local = new ReceivePort();
+ SendPort reply = local.toSendPort();
- local.receive(expectAsync2((int message, SendPort replyTo) {
- if (message == -1) {
- Expect.equals(11, count);
- local.close();
- return;
- }
+ local.receive(expectAsync2((int message, SendPort replyTo) {
+ if (message == -1) {
+ Expect.equals(11, count);
+ local.close();
+ return;
+ }
- Expect.equals((count - 1) * 2, message);
- remote.send(count++, reply);
- if (count == 10) {
- remote.send(-1, reply);
- }
- }, count: 11));
+ Expect.equals((count - 1) * 2, message);
remote.send(count++, reply);
- }));
+ if (count == 10) {
+ remote.send(-1, reply);
+ }
+ }, count: 11));
+ remote.send(count++, reply);
});
}
« no previous file with comments | « tests/isolate/constructor_test.dart ('k') | tests/isolate/cross_isolate_message_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698