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

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

Issue 834233003: Fix for issue 21398 (only send "literal like" objects across isolates spawned using spawnURI (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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) 2015, 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 import 'dart:isolate';
6 import 'dart:async';
7 import "package:expect/expect.dart";
8
9 class FromMainIsolate {
10 String toString() => 'from main isolate';
11 int get fld => 10;
12 }
13
14 funcChild(args) {
15 var reply = args[1];
16 var obj = args[0];
17 Expect.isTrue(obj is FromMainIsolate);
18 Expect.equals(10, obj.fld);
19 reply.send(new FromMainIsolate());
20 }
21
22 main() {
23 var receive1 = new ReceivePort();
24 var receive2 = new ReceivePort();
25
26 // First spawn an isolate using spawnURI and have it
27 // send back a "non-literal" like object.
28 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate.dart'),
29 [],
30 [new FromMainIsolate(), receive1.sendPort]).catchError(
31 (error) {
32 Expect.isTrue(error is ArgumentError);
33 }
34 );
35 Isolate.spawnUri(Uri.parse('issue_21398_child_isolate.dart'),
36 [],
37 receive1.sendPort).then(
38 (isolate) {
39 receive1.listen(
40 (msg) {
41 Expect.stringEquals(msg, "Invalid Argument(s).");
42 receive1.close();
43 },
44 onError: (e) => print('$e')
45 );
46 }
47 );
48
49 // Now spawn an isolate using spawnFunction and send it a "non-literal"
50 // like object and also have the child isolate send back a "non-literal"
51 // like object.
52 Isolate.spawn(funcChild,
53 [new FromMainIsolate(), receive2.sendPort]).then(
54 (isolate) {
55 receive2.listen(
56 (msg) {
57 Expect.isTrue(msg is FromMainIsolate);
58 Expect.equals(10, msg.fld);
59 receive2.close();
60 },
61 onError: (e) => print('$e')
62 );
63 }
64 );
65 }
OLDNEW
« no previous file with comments | « tests/isolate/issue_21398_parent_isolate1_test.dart ('k') | tests/lib/mirrors/invocation_fuzz_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698