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 // OtherScripts=issue_24243_child3_isolate.dart |
| 10 // VMOptions=--checked |
| 11 |
| 12 import 'dart:collection'; |
| 13 import 'dart:isolate'; |
| 14 |
| 15 import "package:expect/expect.dart"; |
| 16 |
| 17 main() { |
| 18 // First spawn an isolate using spawnURI and have it |
| 19 // send back a "literal" like list object. |
| 20 var receive1 = new ReceivePort(); |
| 21 Isolate.spawnUri(Uri.parse('issue_24243_child1_isolate.dart'), |
| 22 [], |
| 23 receive1.sendPort).then( |
| 24 (isolate) { |
| 25 receive1.listen( |
| 26 (msg) { |
| 27 var list0 = <int>[1, 2, 3]; |
| 28 var list1 = <int>[4, 5, 6]; |
| 29 var list2 = <int>[7, 8, 9]; |
| 30 Expect.isTrue(msg is List<List<int>>); |
| 31 Expect.listEquals(msg[0], list0); |
| 32 Expect.listEquals(msg[1], list1); |
| 33 Expect.listEquals(msg[2], list2); |
| 34 Expect.throws(() => msg[0] = "throw an exception"); |
| 35 receive1.close(); |
| 36 }, |
| 37 onError: (e) => print('$e') |
| 38 ); |
| 39 } |
| 40 ); |
| 41 |
| 42 // Now spawn an isolate using spawnURI and have it |
| 43 // send back a "literal" like map object. |
| 44 var receive2 = new ReceivePort(); |
| 45 Isolate.spawnUri(Uri.parse('issue_24243_child2_isolate.dart'), |
| 46 [], |
| 47 receive2.sendPort).then( |
| 48 (isolate) { |
| 49 receive2.listen( |
| 50 (msg) { |
| 51 var map0 = <int, String>{1:'one', 2:'two', 3:'three'}; |
| 52 var map1 = <int, String>{4:'four', 5:'five', 6:'six'}; |
| 53 var map2 = <int, String>{7:'seven', 8:'eight', 9:'nine'}; |
| 54 Expect.isTrue(msg is Map<int, Map<int, String>>); |
| 55 Expect.mapEquals(msg[0], map0); |
| 56 Expect.mapEquals(msg[1], map1); |
| 57 Expect.mapEquals(msg[2], map2); |
| 58 Expect.throws(() => msg[0] = "throw an exception"); |
| 59 receive2.close(); |
| 60 }, |
| 61 onError: (e) => print('$e') |
| 62 ); |
| 63 } |
| 64 ); |
| 65 |
| 66 // Now spawn an isolate using spawnURI and have it |
| 67 // send back a "literal" like LinkedHashMap object. |
| 68 var receive3 = new ReceivePort(); |
| 69 Isolate.spawnUri(Uri.parse('issue_24243_child3_isolate.dart'), |
| 70 [], |
| 71 receive3.sendPort).then( |
| 72 (isolate) { |
| 73 receive3.listen( |
| 74 (msg) { |
| 75 var map0 = new LinkedHashMap<int, String>(); |
| 76 map0[1] = 'one'; |
| 77 map0[2] = 'two'; |
| 78 map0[3] = 'three'; |
| 79 var map1 = new LinkedHashMap<int, String>(); |
| 80 map1[4] = 'four'; |
| 81 map1[5] = 'five'; |
| 82 map1[6] = 'size'; |
| 83 var map2 = new LinkedHashMap<int, String>(); |
| 84 map2[7] = 'seven'; |
| 85 map2[8] = 'eight'; |
| 86 map2[9] = 'nine'; |
| 87 Expect.isTrue(msg is Map<int, LinkedHashMap<int, String>>); |
| 88 Expect.mapEquals(msg[0], map0); |
| 89 Expect.mapEquals(msg[1], map1); |
| 90 Expect.mapEquals(msg[2], map2); |
| 91 Expect.throws(() => msg[0] = "throw an exception"); |
| 92 receive3.close(); |
| 93 }, |
| 94 onError: (e) => print('$e') |
| 95 ); |
| 96 } |
| 97 ); |
| 98 |
| 99 } |
OLD | NEW |