| 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 // spawns multiple isolates and sends unresolved ports between them. | 5 // spawns multiple isolates and sends unresolved ports between them. |
| 6 #library('unresolved_ports'); | 6 #library('unresolved_ports'); |
| 7 #import('dart:dom'); // import added so test.dart can treat this as a webtest. | 7 #import('dart:dom'); // import added so test.dart can treat this as a webtest. |
| 8 #import('dart:isolate'); | 8 #import('dart:isolate'); |
| 9 #import('../../../client/testing/unittest/unittest.dart'); | 9 #import('../../../client/testing/unittest/unittest_dom.dart'); |
| 10 | 10 |
| 11 // This is similar to APIv2_unresolvedPortsStandaloneTest but using | 11 // This is similar to APIv2_unresolvedPortsStandaloneTest but using |
| 12 // 'unittest.dart' so it can run to completion in browsers. | 12 // 'unittest.dart' so it can run to completion in browsers. |
| 13 | 13 |
| 14 bethIsolate() { | 14 bethIsolate() { |
| 15 port.receive((msg, reply) => msg[1].send( | 15 port.receive((msg, reply) => msg[1].send( |
| 16 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply)); | 16 '${msg[0]}\nBeth says: Tim are you coming? And Bob?', reply)); |
| 17 } | 17 } |
| 18 | 18 |
| 19 timIsolate() { | 19 timIsolate() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 42 SendPort tim = spawnFunction(timIsolate); | 42 SendPort tim = spawnFunction(timIsolate); |
| 43 SendPort beth = spawnFunction(bethIsolate); | 43 SendPort beth = spawnFunction(bethIsolate); |
| 44 | 44 |
| 45 beth.send( | 45 beth.send( |
| 46 // because tim is created asynchronously, here we are sending an | 46 // because tim is created asynchronously, here we are sending an |
| 47 // unresolved port: | 47 // unresolved port: |
| 48 ['main says: Beth, find out if Tim is coming.', tim], | 48 ['main says: Beth, find out if Tim is coming.', tim], |
| 49 port.toSendPort()); | 49 port.toSendPort()); |
| 50 }); | 50 }); |
| 51 } | 51 } |
| OLD | NEW |