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

Side by Side Diff: tests/isolate/message2_test.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month 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
« no previous file with comments | « tests/isolate/mandel_isolate_test.dart ('k') | tests/isolate/message_stream2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Dart test program for testing serialization of messages. 5 // Dart test program for testing serialization of messages.
6 // VMOptions=--enable_type_checks --enable_asserts 6 // VMOptions=--enable_type_checks --enable_asserts
7 7
8 library Message2Test; 8 library Message2Test;
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import '../../pkg/unittest/lib/unittest.dart'; 10 import '../../pkg/unittest/lib/unittest.dart';
(...skipping 23 matching lines...) Expand all
34 listEqualsDeep(expected[i], actual[i]); 34 listEqualsDeep(expected[i], actual[i]);
35 } else if (expected[i] is Map) { 35 } else if (expected[i] is Map) {
36 mapEqualsDeep(expected[i], actual[i]); 36 mapEqualsDeep(expected[i], actual[i]);
37 } else { 37 } else {
38 expect(actual[i], expected[i]); 38 expect(actual[i], expected[i]);
39 } 39 }
40 } 40 }
41 } 41 }
42 } 42 }
43 43
44 void pingPong() { 44 void pingPong(replyPort) {
45 port.receive((var message, SendPort replyTo) { 45 ReceivePort port = new ReceivePort();
46 if (message == -1) { 46 port.listen((message) {
47 if (message == null) {
47 port.close(); 48 port.close();
48 } else { 49 } else {
49 // Bounce the received object back so that the sender 50 // Bounce the received object back so that the sender
50 // can make sure that the object matches. 51 // can make sure that the object matches.
51 replyTo.send(message, null); 52 message[1].send(message[0]);
52 } 53 }
53 }); 54 });
55 replyPort.send(port.sendPort);
54 } 56 }
55 57
56 main() { 58 main() {
57 test("map is equal after it is sent back and forth", () { 59 test("map is equal after it is sent back and forth", () {
58 SendPort remote = spawnFunction(pingPong); 60 ReceivePort port = new ReceivePort();
59 Map m = new Map(); 61 Isolate.spawn(pingPong, port.sendPort);
60 m[1] = "eins"; 62 port.first.then(expectAsync1((remote) {
61 m[2] = "deux"; 63 Map m = new Map();
62 m[3] = "tre"; 64 m[1] = "eins";
63 m[4] = "four"; 65 m[2] = "deux";
64 remote.call(m).then(expectAsync1((var received) { 66 m[3] = "tre";
65 MessageTest.mapEqualsDeep(m, received); 67 m[4] = "four";
66 remote.send(-1, null); 68 ReceivePort replyPort = new ReceivePort();
69 remote.send([m, replyPort.sendPort]);
70 replyPort.first.then(expectAsync1((var received) {
71 MessageTest.mapEqualsDeep(m, received);
72 remote.send(null);
73 }));
67 })); 74 }));
68 }); 75 });
69 } 76 }
OLDNEW
« no previous file with comments | « tests/isolate/mandel_isolate_test.dart ('k') | tests/isolate/message_stream2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698