OLD | NEW |
(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 "package:expect/expect.dart"; |
| 6 import "dart:convert"; |
| 7 |
| 8 class MySink implements Sink<List<int>> { |
| 9 List<int> accumulated = <int>[]; |
| 10 bool isClosed = false; |
| 11 |
| 12 add(List<int> list) { |
| 13 accumulated.addAll(list); |
| 14 list.length; |
| 15 } |
| 16 |
| 17 close() { |
| 18 isClosed = true; |
| 19 } |
| 20 } |
| 21 |
| 22 main() { |
| 23 var mySink = new MySink(); |
| 24 var byteSink = new ByteConversionSink.from(mySink); |
| 25 byteSink.add([1, 2, 3]); |
| 26 byteSink.close(); |
| 27 Expect.listEquals([1, 2, 3], mySink.accumulated); |
| 28 Expect.isTrue(mySink.isClosed); |
| 29 } |
OLD | NEW |