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

Side by Side Diff: tests/lib/convert/chunked_conversion1_test.dart

Issue 1827803002: Make convert library strong-mode compliant. Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix more converters. Created 4 years, 9 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 | « sdk/lib/io/data_transformer.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:convert'; 5 import 'dart:convert';
6 6
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 8
9 // This test implements a new special interface that can be used to 9 // This test implements a new special interface that can be used to
10 // send data more efficiently between two converters. 10 // send data more efficiently between two converters.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 class BoolAdapterSink extends MyChunkedBoolSink { 49 class BoolAdapterSink extends MyChunkedBoolSink {
50 final _sink; 50 final _sink;
51 BoolAdapterSink(this._sink); 51 BoolAdapterSink(this._sink);
52 add(o) => _sink.add(o); 52 add(o) => _sink.add(o);
53 close() => _sink.close(); 53 close() => _sink.close();
54 specialB(o) => add(o); 54 specialB(o) => add(o);
55 } 55 }
56 56
57 class IntBoolConverter1 extends Converter<List<int>, List<bool>> { 57 class IntBoolConverter1 extends
58 ChunkedConverter<List<int>, List<bool>, int, bool> {
58 List<bool> convert(List<int> input) => input.map((x) => x > 0).toList(); 59 List<bool> convert(List<int> input) => input.map((x) => x > 0).toList();
59 60
60 startChunkedConversion(sink) { 61 startChunkedConversion(sink) {
61 if (sink is! MyChunkedBoolSink) sink = new MyChunkedBoolSink.from(sink); 62 if (sink is! MyChunkedBoolSink) sink = new MyChunkedBoolSink.from(sink);
62 return new IntBoolConverter1Sink(sink); 63 return new IntBoolConverter1Sink(sink);
63 } 64 }
64 } 65 }
65 66
66 class BoolIntConverter1 extends Converter<List<bool>, List<int>> { 67 class BoolIntConverter1 extends
68 ChunkedConverter<List<bool>, List<int>, bool, int> {
67 List<int> convert(List<bool> input) => input.map((x) => x ? 1 : 0).toList(); 69 List<int> convert(List<bool> input) => input.map((x) => x ? 1 : 0).toList();
68 70
69 startChunkedConversion(sink) { 71 startChunkedConversion(sink) {
70 if (sink is! MyChunkedIntSink) sink = new MyChunkedIntSink.from(sink); 72 if (sink is! MyChunkedIntSink) sink = new MyChunkedIntSink.from(sink);
71 return new BoolIntConverter1Sink(sink); 73 return new BoolIntConverter1Sink(sink);
72 } 74 }
73 } 75 }
74 76
75 int specialICounter = 0; 77 int specialICounter = 0;
76 int specialBCounter = 0; 78 int specialBCounter = 0;
(...skipping 20 matching lines...) Expand all
97 outSink.specialI(b ? 1 : 0); 99 outSink.specialI(b ? 1 : 0);
98 } 100 }
99 101
100 specialB(bool b) { 102 specialB(bool b) {
101 specialBCounter++; 103 specialBCounter++;
102 add(b); 104 add(b);
103 } 105 }
104 close() => outSink.close(); 106 close() => outSink.close();
105 } 107 }
106 108
107 class IdentityConverter extends Converter { 109 class IdentityConverter extends ChunkedConverter {
108 convert(x) => x; 110 convert(x) => x;
109 111
110 startChunkedConversion(sink) { 112 startChunkedConversion(sink) {
111 return new IdentitySink(sink); 113 return new IdentitySink(sink);
112 } 114 }
113 } 115 }
114 116
115 class IdentitySink extends ChunkedConversionSink { 117 class IdentitySink extends ChunkedConversionSink {
116 final _sink; 118 final _sink;
117 IdentitySink(this._sink); 119 IdentitySink(this._sink);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 intSink.add(-3); 247 intSink.add(-3);
246 intSink.add(3); 248 intSink.add(3);
247 intSink.close(); 249 intSink.close();
248 Expect.isTrue(hasExecuted); 250 Expect.isTrue(hasExecuted);
249 Expect.equals(0, specialBCounter); 251 Expect.equals(0, specialBCounter);
250 specialBCounter = 0; 252 specialBCounter = 0;
251 Expect.equals(1, specialICounter); 253 Expect.equals(1, specialICounter);
252 specialICounter = 0; 254 specialICounter = 0;
253 hasExecuted = false; 255 hasExecuted = false;
254 } 256 }
OLDNEW
« no previous file with comments | « sdk/lib/io/data_transformer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698