Chromium Code Reviews| 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.catchError((x){}).catchError((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([6, 8, 10]); | |
| 26 Events input = new Events.fromIterable([1, 2, 3, 4, 5]); | |
| 27 Events actual = new Events.capture( | |
| 28 c.stream.map((x) => x * 2).where((x) => x > 5)); | |
| 29 actual.onDone(() { | |
|
floitsch
2013/02/05 15:09:51
expectAsync0
Lasse Reichstein Nielsen
2013/02/07 10:16:58
Done.
| |
| 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([6, 8, 10]); | |
| 38 Events input = new Events.fromIterable([1, 2, 3, 4, 5]); | |
| 39 Events actual = new Events.capture( | |
| 40 c.stream.map((x) => x * 2).where((x) => x > 5)); | |
| 41 actual.onDone(expectAsync0(() { | |
| 42 Expect.listEquals(expected.events, actual.events); | |
| 43 })); | |
| 44 actual.pause(); | |
| 45 input.replay(c); | |
| 46 actual.resume(); | |
| 47 }); | |
| 48 } | |
|
floitsch
2013/02/05 15:09:51
more tests! :)
some other transformations would be
Lasse Reichstein Nielsen
2013/02/07 10:16:58
That won't give any more coverage for this bug. It
| |
| OLD | NEW |