| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test the Stream.single method. | 5 // Test the Stream.single method. |
| 6 library stream_single_test; | 6 library stream_single_test; |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:isolate'; | |
| 11 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 12 import 'event_helper.dart'; | 11 import 'event_helper.dart'; |
| 13 | 12 |
| 14 main() { | 13 main() { |
| 15 test("single", () { | 14 test("single", () { |
| 16 StreamController c = new StreamController(sync: true); | 15 StreamController c = new StreamController(sync: true); |
| 17 Future f = c.stream.single; | 16 Future f = c.stream.single; |
| 18 f.then(expectAsync((v) { Expect.equals(42, v);})); | 17 f.then(expectAsync((v) { Expect.equals(42, v);})); |
| 19 new Events.fromIterable([42]).replay(c); | 18 new Events.fromIterable([42]).replay(c); |
| 20 }); | 19 }); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 }); | 42 }); |
| 44 | 43 |
| 45 test("single error 3", () { | 44 test("single error 3", () { |
| 46 StreamController c = new StreamController(sync: true); | 45 StreamController c = new StreamController(sync: true); |
| 47 Future f = c.stream.single; | 46 Future f = c.stream.single; |
| 48 f.catchError(expectAsync((error) { Expect.equals("error", error); })); | 47 f.catchError(expectAsync((error) { Expect.equals("error", error); })); |
| 49 Events errorEvents = new Events()..add(499)..error("error")..close(); | 48 Events errorEvents = new Events()..add(499)..error("error")..close(); |
| 50 errorEvents.replay(c); | 49 errorEvents.replay(c); |
| 51 }); | 50 }); |
| 52 } | 51 } |
| OLD | NEW |