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

Side by Side Diff: tests/isolate/src/APIv2_unresolvedPortsStandaloneTest.dart

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // spawns multiple isolates and sends unresolved ports between them.
6 #library('unresolved_ports');
7 #import('dart:isolate');
8
9 // This test does the following:
10 // - main spawns two isolates: 'tim' and 'beth'
11 // - 'tim' spawns an isolate: 'bob'
12 // - main starts a message chain:
13 // main -> beth -> tim -> bob -> main
14 // by giving 'beth' a send-port to 'tim'.
15
16 bethIsolate() {
17 port.receive((msg, reply) => msg[1].send(
18 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply));
19 }
20
21 timIsolate() {
22 SendPort bob = spawnFunction(bobIsolate);
23 port.receive((msg, reply) => bob.send(
24 '$msg\nTim says: Can you tell "main" that we are all coming?', reply));
25 }
26
27 bobIsolate() {
28 port.receive((msg, reply) => reply.send(
29 '$msg\nBob says: we are all coming!'));
30 }
31
32 main() {
33 ReceivePort port = new ReceivePort();
34 port.receive((msg, _) {
35 Expect.equals('main says: Beth, find out if Tim is coming.'
36 + '\nBeth says: Tim are you coming? And Bob?'
37 + '\nTim says: Can you tell "main" that we are all coming?'
38 + '\nBob says: we are all coming!', msg);
39 port.close();
40 });
41
42 SendPort tim = spawnFunction(timIsolate);
43 SendPort beth = spawnFunction(bethIsolate);
44
45 beth.send(
46 // because tim is created asynchronously, here we are sending an
47 // unresolved port:
48 ['main says: Beth, find out if Tim is coming.', tim],
49 port.toSendPort());
50 }
OLDNEW
« no previous file with comments | « tests/isolate/src/APIv2_unresolvedPortsStandaloneNegativeTest.dart ('k') | tests/isolate/src/APIv2_unresolvedPortsTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698