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

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

Issue 18080019: Make StreamController be a StreamSink, not just an EventSink. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « tests/lib/async/stream_controller_async_test.dart ('k') | no next file » | 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_test; 6 library stream_controller_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 'event_helper.dart'; 10 import 'event_helper.dart';
11 11
12 testMultiController() { 12 void testMultiController() {
13 // Test normal flow. 13 // Test normal flow.
14 var c = new StreamController(sync: true); 14 var c = new StreamController(sync: true);
15 Events expectedEvents = new Events() 15 Events expectedEvents = new Events()
16 ..add(42) 16 ..add(42)
17 ..add("dibs") 17 ..add("dibs")
18 ..error("error!") 18 ..error("error!")
19 ..error("error too!") 19 ..error("error too!")
20 ..close(); 20 ..close();
21 Events actualEvents = new Events.capture(c.stream.asBroadcastStream()); 21 Events actualEvents = new Events.capture(c.stream.asBroadcastStream());
22 expectedEvents.replay(c); 22 expectedEvents.replay(c);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 sentEvents = new Events() 398 sentEvents = new Events()
399 ..add(5)..add(6)..add(4)..add(6)..add(8)..add(3)..add(4)..add(1)..close(); 399 ..add(5)..add(6)..add(4)..add(6)..add(8)..add(3)..add(4)..add(1)..close();
400 expectedEvents = new Events() 400 expectedEvents = new Events()
401 ..add(5)..add(4)..add(3)..add(1)..close(); 401 ..add(5)..add(4)..add(3)..add(1)..close();
402 // Use 'distinct' as a filter with access to the previously emitted event. 402 // Use 'distinct' as a filter with access to the previously emitted event.
403 actualEvents = new Events.capture(c.stream.distinct((a, b) => a < b)); 403 actualEvents = new Events.capture(c.stream.distinct((a, b) => a < b));
404 sentEvents.replay(c); 404 sentEvents.replay(c);
405 Expect.listEquals(expectedEvents.events, actualEvents.events); 405 Expect.listEquals(expectedEvents.events, actualEvents.events);
406 } 406 }
407 407
408 testClosed() { 408 void testClosed() {
409 StreamController c = new StreamController(sync: true); 409 StreamController c = new StreamController(sync: true);
410 Expect.isFalse(c.isClosed); 410 Expect.isFalse(c.isClosed);
411 c.add(42); 411 c.add(42);
412 Expect.isFalse(c.isClosed); 412 Expect.isFalse(c.isClosed);
413 c.addError("bad"); 413 c.addError("bad");
414 Expect.isFalse(c.isClosed); 414 Expect.isFalse(c.isClosed);
415 c.close(); 415 c.close();
416 Expect.isTrue(c.isClosed); 416 Expect.isTrue(c.isClosed);
417 } 417 }
418 418
419 main() { 419 main() {
420 testMultiController(); 420 testMultiController();
421 testSingleController(); 421 testSingleController();
422 testExtraMethods(); 422 testExtraMethods();
423 testClosed(); 423 testClosed();
424 } 424 }
OLDNEW
« no previous file with comments | « tests/lib/async/stream_controller_async_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698