| OLD | NEW |
| 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 that isolates can spawn other isolates. | 5 // Dart test program for testing that isolates can spawn other isolates. |
| 6 | 6 |
| 7 library NestedSpawnTest; | 7 library NestedSpawnTest; |
| 8 |
| 8 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 9 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 10 import "remote_unittest_helper.dart"; | 11 import "remote_unittest_helper.dart"; |
| 11 | 12 |
| 12 void isolateA(message) { | 13 void isolateA(message) { |
| 13 message.add("isolateA"); | 14 message.add("isolateA"); |
| 14 Isolate.spawn(isolateB, message); | 15 Isolate.spawn(isolateB, message); |
| 15 } | 16 } |
| 16 | 17 |
| 17 void isolateB(message) { | 18 void isolateB(message) { |
| 18 message.add("isolateB"); | 19 message.add("isolateB"); |
| 19 message[0].send(message); | 20 message[0].send(message); |
| 20 } | 21 } |
| 21 | 22 |
| 22 void main([args, port]) { | 23 void main([args, port]) { |
| 23 if (testRemote(main, port)) return; | 24 if (testRemote(main, port)) return; |
| 24 test("spawned isolates can spawn nested isolates", () { | 25 test("spawned isolates can spawn nested isolates", () { |
| 25 ReceivePort port = new ReceivePort(); | 26 ReceivePort port = new ReceivePort(); |
| 26 Isolate.spawn(isolateA, [port.sendPort, "main"]); | 27 Isolate.spawn(isolateA, [port.sendPort, "main"]); |
| 27 return port.first.then((message) { | 28 return port.first.then((message) { |
| 28 expect("main", message[1]); | 29 expect("main", message[1]); |
| 29 expect("isolateA", message[2]); | 30 expect("isolateA", message[2]); |
| 30 expect("isolateB", message[3]); | 31 expect("isolateB", message[3]); |
| 31 }); | 32 }); |
| 32 }); | 33 }); |
| 33 } | 34 } |
| OLD | NEW |