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