| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 int specialICounter = 0; | 75 int specialICounter = 0; |
| 76 int specialBCounter = 0; | 76 int specialBCounter = 0; |
| 77 | 77 |
| 78 class IntBoolConverter1Sink extends MyChunkedIntSink { | 78 class IntBoolConverter1Sink extends MyChunkedIntSink { |
| 79 var outSink; | 79 var outSink; |
| 80 IntBoolConverter1Sink(this.outSink); | 80 IntBoolConverter1Sink(this.outSink); |
| 81 | 81 |
| 82 add(int i) { | 82 add(int i) { |
| 83 outSink.specialB(i > 0); | 83 outSink.specialB(i > 0); |
| 84 } | 84 } |
| 85 |
| 85 specialI(int i) { | 86 specialI(int i) { |
| 86 specialICounter++; | 87 specialICounter++; |
| 87 add(i); | 88 add(i); |
| 88 } | 89 } |
| 90 |
| 89 close() => outSink.close(); | 91 close() => outSink.close(); |
| 90 } | 92 } |
| 91 | 93 |
| 92 class BoolIntConverter1Sink extends MyChunkedBoolSink { | 94 class BoolIntConverter1Sink extends MyChunkedBoolSink { |
| 93 var outSink; | 95 var outSink; |
| 94 BoolIntConverter1Sink(this.outSink); | 96 BoolIntConverter1Sink(this.outSink); |
| 95 | 97 |
| 96 add(bool b) { | 98 add(bool b) { |
| 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 } |
| 106 |
| 104 close() => outSink.close(); | 107 close() => outSink.close(); |
| 105 } | 108 } |
| 106 | 109 |
| 107 class IdentityConverter extends Converter { | 110 class IdentityConverter extends Converter { |
| 108 convert(x) => x; | 111 convert(x) => x; |
| 109 | 112 |
| 110 startChunkedConversion(sink) { | 113 startChunkedConversion(sink) { |
| 111 return new IdentitySink(sink); | 114 return new IdentitySink(sink); |
| 112 } | 115 } |
| 113 } | 116 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 intSink.add(-3); | 248 intSink.add(-3); |
| 246 intSink.add(3); | 249 intSink.add(3); |
| 247 intSink.close(); | 250 intSink.close(); |
| 248 Expect.isTrue(hasExecuted); | 251 Expect.isTrue(hasExecuted); |
| 249 Expect.equals(0, specialBCounter); | 252 Expect.equals(0, specialBCounter); |
| 250 specialBCounter = 0; | 253 specialBCounter = 0; |
| 251 Expect.equals(1, specialICounter); | 254 Expect.equals(1, specialICounter); |
| 252 specialICounter = 0; | 255 specialICounter = 0; |
| 253 hasExecuted = false; | 256 hasExecuted = false; |
| 254 } | 257 } |
| OLD | NEW |