blob: aaa4fa53f788a29d97075edefa126cb074baba0d [file] [log] [blame]
// Copyright (c) 2016, 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 Future close()
/// Tells the consumer that no further streams will be added.
///
/// @description Checks that if consumer was closed, no streams can be added
/// after closing.
/// @author ngl@unipro.ru
library close_A01_t01;
import "dart:async";
import "../../../Utils/expect.dart";
test(StreamConsumer create()) {
StreamConsumer sc1 = create();
if (sc1 is StreamController) {
StreamController sc = sc1;
List values = [1, 2, 3];
int i = 0;
sc.stream.listen((value) {
Expect.equals(values[i++], value);
}, onError: (error) {
Expect.fail("Unexpected error: $error");
}, onDone: () {
Expect.equals(3, i);
asyncEnd();
});
asyncStart();
sc1.addStream(new Stream.fromIterable([1, 2, 3])).then((_) {
sc1.close().then((_) {
try {
sc1.addStream(new Stream.fromIterable([4, 5, 6])).then((_) {});
} catch (e) {
Expect.isTrue(e is StateError);
}
});
});
}
}