| 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 test; | 5 library test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 import '../async_helper.dart'; |
| 9 | 10 |
| 10 funcFoo(x) => x + 2; | 11 funcFoo(x) => x + 2; |
| 11 | 12 |
| 12 foo() { | 13 foo() { |
| 13 stream.single.then((msg) { | 14 stream.single.then((msg) { |
| 14 IsolateSink sink = msg; | 15 IsolateSink sink = msg; |
| 15 sink.add(499); | 16 sink.add(499); |
| 16 sink.close(); | 17 sink.close(); |
| 17 }); | 18 }); |
| 18 } | 19 } |
| 19 | 20 |
| 20 main() { | 21 main() { |
| 21 var box = new MessageBox(); | 22 var box = new MessageBox(); |
| 22 var snd = streamSpawnFunction(foo); | 23 var snd = streamSpawnFunction(foo); |
| 23 var caught_exception = false; | 24 var caught_exception = false; |
| 24 try { | 25 try { |
| 25 snd.add(funcFoo); | 26 snd.add(funcFoo); |
| 26 } catch (e) { | 27 } catch (e) { |
| 27 caught_exception = true; | 28 caught_exception = true; |
| 28 } | 29 } |
| 29 snd.add(box.sink); | 30 snd.add(box.sink); |
| 30 snd.close(); | 31 snd.close(); |
| 31 | 32 |
| 33 asyncStart(); |
| 32 box.stream.single.then((msg) { | 34 box.stream.single.then((msg) { |
| 33 Expect.equals(499, msg); | 35 Expect.equals(499, msg); |
| 36 asyncEnd(); |
| 34 }); | 37 }); |
| 35 } | 38 } |
| OLD | NEW |