blob: d852b4fc215c558476dfc30542c93d4fcc3fc8f5 [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 Capability pauseCapability
/// read-only
/// Capability granting the ability to pause the isolate.
/// This capability is used by pause. If the capability is not the correct
/// pause capability of the isolate, including if the capability is null,
/// then calls to pause will have no effect.
/// If the isolate is started in a paused state, use this capability
/// as argument to resume to resume the isolate.
/// @description Check that if pauseCapability is not correct pause capability,
/// call to resume() with pauseCapability as argument will not resume
/// the isolate, which is started in paused state.
/// @author
import "dart:isolate";
import "dart:async";
import "../../../Utils/expect.dart";
import "IsolateUtil.dart";
void entryPoint(SendPort sendPort) {
Future test(Capability? pauseCapability) async {
ReceivePort receivePort = new ReceivePort();
Future receiveFuture = receivePort.first;
Isolate isolate = await Isolate.spawn(entryPoint,
Isolate clone = new Isolate(isolate.controlPort,
pauseCapability: pauseCapability,
var pc = clone.pauseCapability;
if (pc != null) {
var timeout = receiveFuture.timeout(ONE_SECOND, onTimeout:() => "timeout");
Expect.equals("timeout", await timeout);
return null;
main() {
[test(null), test(new Capability())]
(_) => asyncEnd()