blob: dd8fe5aa16960d263f8643602afe809706e653ed [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 void addError(error, [StackTrace stackTrace])
/// ...
/// This operation is non-blocking. See flush or done for how to get any errors
/// generated by this call.
/// @description Checks that this operation is non-blocking
/// @author sgrekhov@unipro.ru
import "../../../Utils/expect.dart";
import "dart:async";
import "dart:io";
int called = 1;
class MyStreamConsumer extends StreamConsumer<List<int>> {
Future<dynamic> addStream(Stream<List<int>> stream) {
stream.listen((_) {
Expect.fail("Error is expected");
}, onError: (error, StackTrace st) {
Expect.equals("ERROR ${called++}", error);
});
return new Future(() {});
}
Future close() { return new Future(() {}); }
}
test() async {
StreamConsumer consumer = new MyStreamConsumer();
IOSink sink = new IOSink(consumer);
sink.addError("ERROR 1");
sink.addError("ERROR 2");
await sink.close();
Expect.equals(3, called);
asyncEnd();
}
main() {
asyncStart();
test();
}