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

Side by Side Diff: packages/quiver/test/async/stream_buffer_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
OLDNEW
1 // Copyright 2014 Google Inc. All Rights Reserved. 1 // Copyright 2014 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 library quiver.streams.streambuffer_test; 15 library quiver.async.stream_buffer_test;
16 16
17 import 'dart:async'; 17 import 'dart:async';
18 import 'package:test/test.dart'; 18 import 'package:test/test.dart';
19 import 'package:quiver/streams.dart'; 19 import 'package:quiver/async.dart';
20 20
21 void main() { 21 void main() {
22 group("StreamBuffer", () { 22 group("StreamBuffer", () {
23 test("returns orderly overlaps", () { 23 test("returns orderly overlaps", () {
24 StreamBuffer<int> buf = new StreamBuffer(); 24 StreamBuffer<List<int>> buf = new StreamBuffer();
25 new Stream.fromIterable([[1], [2, 3, 4], [5, 6, 7, 8]]).pipe(buf); 25 new Stream.fromIterable([
26 [1],
27 [2, 3, 4],
28 [5, 6, 7, 8]
29 ]).pipe(buf);
26 return Future.wait([buf.read(2), buf.read(4), buf.read(2)]).then((vals) { 30 return Future.wait([buf.read(2), buf.read(4), buf.read(2)]).then((vals) {
27 expect(vals[0], equals([1, 2])); 31 expect(vals[0], equals([1, 2]));
28 expect(vals[1], equals([3, 4, 5, 6])); 32 expect(vals[1], equals([3, 4, 5, 6]));
29 expect(vals[2], equals([7, 8])); 33 expect(vals[2], equals([7, 8]));
30 }).then((_) { 34 }).then((_) {
31 buf.close(); 35 buf.close();
32 }); 36 });
33 }); 37 });
34 38
35 test("respects pausing of stream", () { 39 test("respects pausing of stream", () {
36 StreamBuffer<int> buf = new StreamBuffer()..limit = 2; 40 StreamBuffer<List<int>> buf = new StreamBuffer()..limit = 2;
37 new Stream.fromIterable([[1], [2], [3], [4]]).pipe(buf); 41 new Stream.fromIterable([
42 [1],
43 [2],
44 [3],
45 [4]
46 ]).pipe(buf);
38 return buf.read(2).then((val) { 47 return buf.read(2).then((val) {
39 expect(val, [1, 2]); 48 expect(val, [1, 2]);
40 }).then((_) { 49 }).then((_) {
41 return buf.read(2); 50 return buf.read(2);
42 }).then((val) { 51 }).then((val) {
43 expect(val, [3, 4]); 52 expect(val, [3, 4]);
44 }); 53 });
45 }); 54 });
46 55
47 test("throws when reading too much", () { 56 test("throws when reading too much", () {
48 StreamBuffer<int> buf = new StreamBuffer()..limit = 1; 57 StreamBuffer<List<int>> buf = new StreamBuffer()..limit = 1;
49 new Stream.fromIterable([[1], [2]]).pipe(buf); 58 new Stream.fromIterable([
59 [1],
60 [2]
61 ]).pipe(buf);
50 try { 62 try {
51 buf.read(2); 63 buf.read(2);
52 } catch (e) { 64 } catch (e) {
53 expect(e, isArgumentError); 65 expect(e, isArgumentError);
54 return; 66 return;
55 } 67 }
56 fail("error not thrown when reading more data than buffer limit"); 68 fail("error not thrown when reading more data than buffer limit");
57 }); 69 });
58 70
59 test("allows patching of streams", () { 71 test("allows patching of streams", () {
(...skipping 17 matching lines...) Expand all
77 error = e; 89 error = e;
78 }).then((_) { 90 }).then((_) {
79 expect(error is UnderflowError, isTrue, 91 expect(error is UnderflowError, isTrue,
80 reason: "!UnderflowError: $error"); 92 reason: "!UnderflowError: $error");
81 }); 93 });
82 new Stream.fromIterable([1, 2, 3]).pipe(buf); 94 new Stream.fromIterable([1, 2, 3]).pipe(buf);
83 return future; 95 return future;
84 }); 96 });
85 }); 97 });
86 } 98 }
OLDNEW
« no previous file with comments | « packages/quiver/test/async/enumerate_test.dart ('k') | packages/quiver/test/async/stream_router_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698