Chromium Code Reviews| 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 library illegal_msg_tests; | |
| 6 import 'dart:isolate'; | 5 import 'dart:isolate'; |
| 7 | 6 |
| 8 funcFoo(x) => x + 2; | 7 funcFoo(x) => x + 2; |
| 9 | 8 |
| 10 echo() { | 9 foo() { |
| 11 port.receive((msg, reply) { | 10 stream.single.then((msg) { |
| 12 reply.send("echoing ${msg(1)}}"); | 11 IsolateSink sink = msg; |
| 12 sink.add(499); | |
| 13 sink.close(); | |
| 13 }); | 14 }); |
| 14 } | 15 } |
| 15 | 16 |
| 16 main() { | 17 main() { |
| 17 var snd = spawnFunction(echo); | 18 var box = new MessageBox(); |
| 19 var snd = streamSpawnFunction(foo); | |
| 18 var caught_exception = false; | 20 var caught_exception = false; |
| 19 try { | 21 try { |
| 20 snd.send(funcFoo, port.toSendPort()); | 22 snd.add(funcFoo); |
| 21 } catch (e) { | 23 } catch (e) { |
| 22 caught_exception = true; | 24 caught_exception = true; |
| 23 } | 25 } |
| 26 snd.add(box.sink); | |
| 27 snd.close(); | |
| 24 | 28 |
| 25 if (caught_exception) { | 29 box.stream.single.then((msg) { |
|
Lasse Reichstein Nielsen
2013/03/19 12:01:55
expectAsync?
floitsch
2013/03/19 13:18:59
This test doesn't import the unit-test library.
In
| |
| 26 port.close(); | 30 Expect.equals(499, msg); |
| 27 } else { | 31 }); |
| 28 port.receive((msg, reply) { | |
| 29 print("from worker ${msg}"); | |
| 30 }); | |
| 31 } | |
| 32 Expect.isTrue(caught_exception); | |
| 33 } | 32 } |
| OLD | NEW |