| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // A negative test to ensure we are covering all the assertions and running to |
| 6 // completion APIv2_unresolvedPortsStandaloneTest. |
| 7 #library('unresolved_ports'); |
| 8 |
| 9 bethIsolate(ReceivePort port) { |
| 10 port.receive((msg, reply) => msg[1].send( |
| 11 "${msg[0]}\nBeth says: Tim are you coming? And Bob?", reply)); |
| 12 } |
| 13 |
| 14 timIsolate(ReceivePort port) { |
| 15 Isolate2 bob = new Isolate2.fromCode(bobIsolate); |
| 16 port.receive((msg, reply) => bob.sendPort.send( |
| 17 "$msg\nTim says: Can you tell 'main' that we are all coming?", reply)); |
| 18 } |
| 19 |
| 20 bobIsolate(ReceivePort port) { |
| 21 port.receive((msg, reply) => reply.send( |
| 22 "$msg\nBob says: we are all coming!")); |
| 23 } |
| 24 |
| 25 main() { |
| 26 ReceivePort port = new ReceivePort(); |
| 27 port.receive((msg, _) { |
| 28 Expect.equals("main says: Beth, find out if Tim is coming." |
| 29 + "\nBeth says: Tim are you coming? And Bob?" |
| 30 + "\nTim says: Can you tell 'main' that we are all coming?" |
| 31 + "\nBob says: we are NOT coming!", msg); // should be 'all', not 'NOT' |
| 32 port.close(); |
| 33 }); |
| 34 |
| 35 Isolate2 tim = new Isolate2.fromCode(timIsolate); |
| 36 Isolate2 beth = new Isolate2.fromCode(bethIsolate); |
| 37 |
| 38 beth.sendPort.send( |
| 39 // because tim is created asynchronously, here we are sending an |
| 40 // unresolved port: |
| 41 ["main says: Beth, find out if Tim is coming.", tim.sendPort], |
| 42 port.toSendPort()); |
| 43 } |
| OLD | NEW |