Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: tests/lib/async/stream_take_test.dart

Issue 2475303002: Revert "Handle the case of Stream.take(0) better." This reverts commit 8cead4090cc0b1184a2ad552003a… (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/co19/co19-co19.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/stream_take_test.dart
diff --git a/tests/lib/async/stream_take_test.dart b/tests/lib/async/stream_take_test.dart
deleted file mode 100644
index e341a2259d193c521b42a4db807a5665a46960ef..0000000000000000000000000000000000000000
--- a/tests/lib/async/stream_take_test.dart
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-import "package:expect/expect.dart";
-import "package:async_helper/async_helper.dart";
-
-class A { const A(); }
-class B extends A { const B(); }
-
-/// Stream which emits an error if it's not canceled at the correct time.
-///
-/// Must be canceled after at most [maxEvents] events.
-Stream makeStream(int maxEvents) {
- var c;
- int event = 0;
- bool canceled = false;
- c = new StreamController(onListen: () {
- new Timer.periodic(const Duration(milliseconds: 10), (t) {
- if (canceled) {
- t.cancel();
- return;
- }
- if (event == maxEvents) {
- c.addError("NOT CANCELED IN TIME: $maxEvents");
- c.close();
- t.cancel();
- } else {
- c.add(event++);
- }
- });
- }, onCancel: () {
- canceled = true;
- });
- return c.stream;
-}
-
-main() {
- asyncStart();
- tests().then((_) { asyncEnd(); });
-}
-
-tests() async {
- await expectThrowsAsync(makeStream(4).take(5).toList(), "5/4");
- await expectThrowsAsync(makeStream(0).take(1).toList(), "1/0");
-
- Expect.listEquals([0, 1, 2, 3, 4], await makeStream(5).take(5).toList());
-
- Expect.listEquals([0, 1, 2, 3], await makeStream(5).take(4).toList());
-
- Expect.listEquals([0], await makeStream(5).take(1).toList());
-
- Expect.listEquals([], await makeStream(5).take(0).toList());
-
- Expect.listEquals([], await makeStream(0).take(0).toList());
-}
-
-Future expectThrowsAsync(Future computation, String name) {
- return computation.then((_) {
- Expect.fail("$name: Did not throw");
- }, onError: (e, s){});
-}
« no previous file with comments | « tests/co19/co19-co19.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698