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

Side by Side Diff: test/accumulator_sink_test.dart

Issue 1911053002: Add sinks to provide synchronous access to events. (Closed) Base URL: git@github.com:dart-lang/convert@master
Patch Set: Code review changes Created 4 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
« no previous file with comments | « pubspec.yaml ('k') | test/byte_accumulator_sink_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
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:async';
6
7 import 'package:convert/convert.dart';
8 import 'package:test/test.dart';
9
10 void main() {
11 var sink;
12 setUp(() {
13 sink = new AccumulatorSink<int>();
14 });
15
16 test("provides access to events as they're added", () {
17 expect(sink.events, isEmpty);
18
19 sink.add(1);
20 expect(sink.events, equals([1]));
21
22 sink.add(2);
23 expect(sink.events, equals([1, 2]));
24
25 sink.add(3);
26 expect(sink.events, equals([1, 2, 3]));
27 });
28
29 test("clear() clears the events", () {
30 sink..add(1)..add(2)..add(3);
31 expect(sink.events, equals([1, 2, 3]));
32
33 sink.clear();
34 expect(sink.events, isEmpty);
35
36 sink..add(4)..add(5)..add(6);
37 expect(sink.events, equals([4, 5, 6]));
38 });
39
40 test("indicates whether the sink is closed", () {
41 expect(sink.isClosed, isFalse);
42 sink.close();
43 expect(sink.isClosed, isTrue);
44 });
45
46 test("doesn't allow add() to be called after close()", () {
47 sink.close();
48 expect(() => sink.add(1), throwsStateError);
49 });
50 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/byte_accumulator_sink_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698