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

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

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. 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 | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/slow_consumer_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // VMOptions=--old_gen_heap_size=64 5 // VMOptions=--old_gen_heap_size=64
6 6
7 library slow_consumer3_test; 7 library slow_consumer3_test;
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 }, 52 },
53 onDone: () { 53 onDone: () {
54 finalCount = receivedCount; 54 finalCount = receivedCount;
55 result.complete(receivedCount); 55 result.complete(receivedCount);
56 }); 56 });
57 return result.future; 57 return result.future;
58 } 58 }
59 59
60 Future close() { 60 Future close() {
61 return new Future.immediate(finalCount); 61 return new Future.value(finalCount);
62 } 62 }
63 } 63 }
64 64
65 Stream<List> dataGenerator(int bytesTotal, int chunkSize) { 65 Stream<List> dataGenerator(int bytesTotal, int chunkSize) {
66 int chunks = bytesTotal ~/ chunkSize; 66 int chunks = bytesTotal ~/ chunkSize;
67 return new Stream.fromIterable(new Iterable.generate(chunks, (_) { 67 return new Stream.fromIterable(new Iterable.generate(chunks, (_) {
68 // This assumes one byte per entry. In practice it will be more. 68 // This assumes one byte per entry. In practice it will be more.
69 return new List<int>(chunkSize); 69 return new List<int>(chunkSize);
70 })); 70 }));
71 } 71 }
(...skipping 13 matching lines...) Expand all
85 // file). If the consumer doesn't pause the data-provider it will run out of 85 // file). If the consumer doesn't pause the data-provider it will run out of
86 // heap-space. 86 // heap-space.
87 87
88 dataGenerator(100 * MB, 512 * KB) 88 dataGenerator(100 * MB, 512 * KB)
89 .pipe(new SlowConsumer(200 * MB, 3 * MB)) 89 .pipe(new SlowConsumer(200 * MB, 3 * MB))
90 .then((count) { 90 .then((count) {
91 port.close(); 91 port.close();
92 Expect.equals(100 * MB, count); 92 Expect.equals(100 * MB, count);
93 }); 93 });
94 } 94 }
OLDNEW
« no previous file with comments | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/slow_consumer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698