| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library stream_transform_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import '../../../pkg/unittest/lib/unittest.dart'; |
| 9 import 'event_helper.dart'; |
| 10 |
| 11 |
| 12 main() { |
| 13 // Regression tests for http://dartbug.com/8311 |
| 14 |
| 15 test("simpleDone", () { |
| 16 StreamController c = new StreamController(); |
| 17 Stream out = c.stream.handleError((x){}).handleError((x){}); |
| 18 out.listen((v){}, onDone: expectAsync0(() {})); |
| 19 // Should not throw. |
| 20 c.close(); |
| 21 }); |
| 22 |
| 23 test("with events", () { |
| 24 StreamController c = new StreamController(); |
| 25 Events expected = new Events.fromIterable([10, 12]); |
| 26 Events input = new Events.fromIterable([1, 2, 3, 4, 5, 6, 7]); |
| 27 Events actual = new Events.capture( |
| 28 c.stream.map((x) => x * 2).where((x) => x > 5).skip(2).take(2)); |
| 29 actual.onDone(expectAsync0(() { |
| 30 Expect.listEquals(expected.events, actual.events); |
| 31 })); |
| 32 input.replay(c); |
| 33 }); |
| 34 |
| 35 test("paused events", () { |
| 36 StreamController c = new StreamController(); |
| 37 Events expected = new Events.fromIterable([10, 12]); |
| 38 Events input = new Events.fromIterable([1, 2, 3, 4, 5, 6, 7]); |
| 39 Events actual = new Events.capture( |
| 40 c.stream.map((x) => x * 2).where((x) => x > 5).skip(2).take(2)); |
| 41 actual.onDone(expectAsync0(() { |
| 42 Expect.listEquals(expected.events, actual.events); |
| 43 })); |
| 44 actual.pause(); |
| 45 input.replay(c); |
| 46 actual.resume(); |
| 47 }); |
| 48 } |
| OLD | NEW |