OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // This test checks that stdin is *not* closed when an Isolate leaks it. |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:io'; |
| 9 import 'dart:isolate'; |
| 10 |
| 11 import "package:async_helper/async_helper.dart"; |
| 12 import "package:expect/expect.dart"; |
| 13 |
| 14 void ConnectorIsolate(SendPort sendPort) { |
| 15 stdin; |
| 16 sendPort.send(true); |
| 17 } |
| 18 |
| 19 main() async { |
| 20 asyncStart(); |
| 21 ReceivePort receivePort = new ReceivePort(); |
| 22 Isolate isolate = await Isolate.spawn(ConnectorIsolate, receivePort.sendPort); |
| 23 Completer<Null> completer = new Completer<Null>(); |
| 24 receivePort.listen((msg) { |
| 25 Expect.isTrue(msg is bool); |
| 26 Expect.isTrue(msg); |
| 27 isolate.kill(); |
| 28 completer.complete(null); |
| 29 }); |
| 30 await completer.future; |
| 31 stdin.listen((_) {}).cancel(); |
| 32 receivePort.close(); |
| 33 asyncEnd(); |
| 34 } |
OLD | NEW |