OLD | NEW |
---|---|
(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 // Note: the following comment is used by test.dart to additionally compile the | |
6 // other isolate's code. | |
7 // OtherScripts=issue_24243_child1_isolate.dart | |
8 // OtherScripts=issue_24243_child2_isolate.dart | |
9 // VMOptions=--checked | |
10 | |
11 import 'dart:isolate'; | |
12 import 'dart:async'; | |
koda
2015/09/16 17:41:26
Sort imports.
siva
2015/09/16 18:24:45
Removed dart:async as it is not needed.
| |
13 import "package:expect/expect.dart"; | |
14 | |
15 main() { | |
16 var receive1 = new ReceivePort(); | |
17 | |
18 // First spawn an isolate using spawnURI and have it | |
19 // send back a "literal" like list object. | |
20 Isolate.spawnUri(Uri.parse('issue_24243_child1_isolate.dart'), | |
21 [], | |
22 receive1.sendPort).then( | |
23 (isolate) { | |
24 receive1.listen( | |
25 (msg) { | |
26 var l0 = <int>[1, 2, 3]; | |
27 var l1 = <int>[4, 5, 6]; | |
28 var l2 = <int>[7, 8, 9]; | |
29 Expect.isTrue(msg is List<List<int>>); | |
30 Expect.listEquals(msg[0], l0); | |
31 Expect.listEquals(msg[1], l1); | |
32 Expect.listEquals(msg[2], l2); | |
33 Expect.throws(() => msg[0] = "throw an exception"); | |
34 receive1.close(); | |
35 }, | |
36 onError: (e) => print('$e') | |
37 ); | |
38 } | |
39 ); | |
40 | |
41 var receive2 = new ReceivePort(); | |
42 | |
43 // Now spawn an isolate using spawnURI and have it | |
44 // send back a "literal" like map object. | |
45 Isolate.spawnUri(Uri.parse('issue_24243_child2_isolate.dart'), | |
46 [], | |
47 receive2.sendPort).then( | |
48 (isolate) { | |
49 receive2.listen( | |
50 (msg) { | |
51 var m0 = <int, String>{1:'one', 2:'two', 3:'three'}; | |
52 var m1 = <int, String>{4:'four', 5:'five', 6:'six'}; | |
53 var m2 = <int, String>{7:'seven', 8:'eight', 9:'nine'}; | |
54 Expect.isTrue(msg is Map<int, Map<int, String>>); | |
55 Expect.mapEquals(msg[0], m0); | |
56 Expect.mapEquals(msg[1], m1); | |
57 Expect.mapEquals(msg[2], m2); | |
58 Expect.throws(() => msg[0] = "throw an exception"); | |
59 receive2.close(); | |
60 }, | |
61 onError: (e) => print('$e') | |
62 ); | |
63 } | |
64 ); | |
65 } | |
OLD | NEW |