Files
sdk/tests/lib_2/async/wait_for_cancel_test.dart
T
Ben Konyi ddf2987ed7 Migrated test block 180 to Dart 2.0.
Small changes were required for zone_debug_test to become strong mode
clean.

Bug:
Change-Id: I5ef52d7d116dd25793117511d8ee1904a172c014
Reviewed-on: https://dart-review.googlesource.com/3740
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2017-09-11 13:52:19 +00:00

26 lines
750 B
Dart

// Copyright (c) 2015, 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.
import "dart:async";
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
main() {
asyncStart();
bool waitedForCancel = false;
var controller = new StreamController(
onCancel: () => new Future(() => waitedForCancel = true));
var sub = controller.stream.take(1).listen((x) {
Expect.fail("onData should not be called");
});
var cancelFuture = sub.cancel();
Expect.isNotNull(cancelFuture);
cancelFuture.then((_) {
Expect.isTrue(waitedForCancel);
asyncEnd();
});
}