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