blob: d2323ac59e467016a7341f9261afbe6a7dc76c8d [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.
/// @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 implements 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<List<int>> 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();
}