| 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 // Test empty stream. | 5 // Test empty stream. |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 | 9 |
| 10 main() async { | 10 main() { |
| 11 asyncStart(); |
| 12 runTest().whenComplete(asyncEnd); |
| 13 } |
| 14 |
| 15 Future runTest() async { |
| 11 unreachable([a,b]) { throw "UNREACHABLE"; } | 16 unreachable([a,b]) { throw "UNREACHABLE"; } |
| 12 int tick = 0; | 17 int tick = 0; |
| 13 ticker() { tick++; } | 18 ticker() { tick++; } |
| 14 | 19 |
| 15 asyncStart(); | 20 asyncStart(); |
| 16 | 21 |
| 17 Stream<int> s = const Stream<int>.empty(); // Is const constructor. | 22 Stream<int> s = const Stream<int>.empty(); // Is const constructor. |
| 18 Expect.isFalse(s is Stream<String>); // Respects type parameter. | 23 Expect.isFalse(s is Stream<String>); // Respects type parameter. |
| 19 StreamSubscription<int> sub = | 24 StreamSubscription<int> sub = |
| 20 s.listen(unreachable, onError: unreachable, onDone: ticker); | 25 s.listen(unreachable, onError: unreachable, onDone: ticker); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 Expect.equals(tick, 1); | 54 Expect.equals(tick, 1); |
| 50 sub3.resume(); | 55 sub3.resume(); |
| 51 await flushMicrotasks(); | 56 await flushMicrotasks(); |
| 52 // Now completed. | 57 // Now completed. |
| 53 Expect.equals(tick, 2); | 58 Expect.equals(tick, 2); |
| 54 | 59 |
| 55 asyncEnd(); | 60 asyncEnd(); |
| 56 } | 61 } |
| 57 | 62 |
| 58 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); | 63 Future flushMicrotasks() => new Future.delayed(Duration.ZERO); |
| OLD | NEW |