| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Tests the StreamView class. | 5 // Tests the StreamView class. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import "dart:async"; | 8 import "dart:async"; |
| 9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
| 10 | 10 |
| 11 main() { | 11 main() { |
| 12 asyncStart(); | 12 asyncStart(); |
| 13 runTest().whenComplete(asyncEnd); | 13 runTest().whenComplete(asyncEnd); |
| 14 } | 14 } |
| 15 | 15 |
| 16 Future runTest() async { | 16 Future runTest() async { |
| 17 unreachable([a,b]) { throw "UNREACHABLE"; } | 17 unreachable([a, b]) { |
| 18 throw "UNREACHABLE"; |
| 19 } |
| 20 |
| 18 int tick = 0; | 21 int tick = 0; |
| 19 ticker() { tick++; } | 22 ticker() { |
| 23 tick++; |
| 24 } |
| 20 | 25 |
| 21 asyncStart(); | 26 asyncStart(); |
| 22 | 27 |
| 23 // Is const constructor. | 28 // Is const constructor. |
| 24 Stream<int> s = const StreamView<int>(const Stream<int>.empty()); | 29 Stream<int> s = const StreamView<int>(const Stream<int>.empty()); |
| 25 | 30 |
| 26 Expect.isFalse(s is Stream<String>); // Respects type parameter. | 31 Expect.isFalse(s is Stream<String>); // Respects type parameter. |
| 27 StreamSubscription<int> sub = | 32 StreamSubscription<int> sub = |
| 28 s.listen(unreachable, onError: unreachable, onDone: ticker); | 33 s.listen(unreachable, onError: unreachable, onDone: ticker); |
| 29 Expect.isFalse(sub is StreamSubscription<String>); // Type parameter in sub. | 34 Expect.isFalse(sub is StreamSubscription<String>); // Type parameter in sub. |
| 30 | 35 |
| 31 Stream iterableStream = new Stream.fromIterable([1, 2, 3]); | 36 Stream iterableStream = new Stream.fromIterable([1, 2, 3]); |
| 32 Expect.listEquals([1, 2, 3], await iterableStream.toList()); | 37 Expect.listEquals([1, 2, 3], await iterableStream.toList()); |
| 33 | 38 |
| 34 asyncEnd(); | 39 asyncEnd(); |
| 35 } | 40 } |
| 36 | 41 |
| 37 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); | 42 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); |
| OLD | NEW |