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

Side by Side Diff: tests/lib/async/stream_controller_async_test.dart

Issue 14051005: Remove deprecated CollectionSink and Stream.pipeInto. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | tests/lib/async/stream_controller_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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 the basic StreamController and StreamController.singleSubscription. 5 // Test the basic StreamController and StreamController.singleSubscription.
6 library stream_controller_async_test; 6 library stream_controller_async_test;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 14 matching lines...) Expand all
25 c.close(); 25 c.close();
26 }); 26 });
27 27
28 test("StreamController.fold throws", () { 28 test("StreamController.fold throws", () {
29 StreamController c = new StreamController.broadcast(); 29 StreamController c = new StreamController.broadcast();
30 Stream stream = c.stream; 30 Stream stream = c.stream;
31 stream.fold(0, (a,b) { throw "Fnyf!"; }) 31 stream.fold(0, (a,b) { throw "Fnyf!"; })
32 .catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); })); 32 .catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); }));
33 c.add(42); 33 c.add(42);
34 }); 34 });
35
36 test("StreamController.pipeInto", () {
37 StreamController c = new StreamController.broadcast();
38 var list = <int>[];
39 Stream stream = c.stream;
40 stream.pipeInto(new CollectionSink<int>(list))
41 .whenComplete(expectAsync0(() {
42 Expect.listEquals(<int>[1,2,9,3,9], list);
43 }));
44 c.add(1);
45 c.add(2);
46 c.add(9);
47 c.add(3);
48 c.add(9);
49 c.close();
50 });
51 } 35 }
52 36
53 testSingleController() { 37 testSingleController() {
54 test("Single-subscription StreamController.fold", () { 38 test("Single-subscription StreamController.fold", () {
55 StreamController c = new StreamController(); 39 StreamController c = new StreamController();
56 Stream stream = c.stream; 40 Stream stream = c.stream;
57 stream.fold(0, (a,b) => a + b) 41 stream.fold(0, (a,b) => a + b)
58 .then(expectAsync1((int v) { Expect.equals(42, v); })); 42 .then(expectAsync1((int v) { Expect.equals(42, v); }));
59 c.add(10); 43 c.add(10);
60 c.add(32); 44 c.add(32);
61 c.close(); 45 c.close();
62 }); 46 });
63 47
64 test("Single-subscription StreamController.fold throws", () { 48 test("Single-subscription StreamController.fold throws", () {
65 StreamController c = new StreamController(); 49 StreamController c = new StreamController();
66 Stream stream = c.stream; 50 Stream stream = c.stream;
67 stream.fold(0, (a,b) { throw "Fnyf!"; }) 51 stream.fold(0, (a,b) { throw "Fnyf!"; })
68 .catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); })); 52 .catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); }));
69 c.add(42); 53 c.add(42);
70 }); 54 });
71 55
72 test("Single-subscription StreamController.pipeInto", () {
73 StreamController c = new StreamController();
74 var list = <int>[];
75 Stream stream = c.stream;
76 stream.pipeInto(new CollectionSink<int>(list))
77 .whenComplete(expectAsync0(() {
78 Expect.listEquals(<int>[1,2,9,3,9], list);
79 }));
80 c.add(1);
81 c.add(2);
82 c.add(9);
83 c.add(3);
84 c.add(9);
85 c.close();
86 });
87
88 test("Single-subscription StreamController subscription changes", () { 56 test("Single-subscription StreamController subscription changes", () {
89 StreamController c = new StreamController(); 57 StreamController c = new StreamController();
90 EventSink sink = c.sink; 58 EventSink sink = c.sink;
91 Stream stream = c.stream; 59 Stream stream = c.stream;
92 int counter = 0; 60 int counter = 0;
93 var subscription; 61 var subscription;
94 subscription = stream.listen((data) { 62 subscription = stream.listen((data) {
95 counter += data; 63 counter += data;
96 Expect.throws(() => stream.listen(null), (e) => e is StateError); 64 Expect.throws(() => stream.listen(null), (e) => e is StateError);
97 subscription.cancel(); 65 subscription.cancel();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b))); 419 testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b)));
452 } 420 }
453 421
454 main() { 422 main() {
455 testController(); 423 testController();
456 testSingleController(); 424 testSingleController();
457 testExtraMethods(); 425 testExtraMethods();
458 testPause(); 426 testPause();
459 testRethrow(); 427 testRethrow();
460 } 428 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | tests/lib/async/stream_controller_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698