blob: 54352fd0b9e21fb39456598b01cc71b39f7ec1e4 [file] [log] [blame]
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
/// @assertion ClosableStringSink asStringSink()
/// ...
/// If used, this method must be the first and only call to this. It invalidates
/// this. All further operations must be performed on the result.
/// @description Checks that this method invalidates this and all further
/// operations must be performed on the result.
/// @issue 29353
/// @author sgrekhov@unipro.ru
import "dart:convert";
import "../../../Utils/expect.dart";
main() {
bool called = false;
var outSink = new ByteConversionSink.withCallback((accumulated) {
called = true;
Expect.listEquals(utf8.encode("12"), accumulated);
});
StringConversionSink inSink = utf8.encoder.startChunkedConversion(outSink);
inSink.add("1");
ClosableStringSink css = inSink.asStringSink();
css.write("2");
inSink.add("3");
css.close();
Expect.isTrue(called);
inSink.add("4");
inSink.close();
}