// 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:isolate";
import "package:unittest/unittest.dart";

Uri toDartDataUri(String source) {
  return Uri.parse("data:application/dart;charset=utf-8,"
      "${Uri.encodeComponent(source)}");
}

main() {
  test('Simple response', () {
    String source = """
import "dart:isolate";
main(List args, SendPort replyPort) {
  replyPort.send(42);
}
""";

    RawReceivePort receivePort;
    receivePort = new RawReceivePort(expectAsync((message) {
      expect(message, equals(42));
      receivePort.close();
    }));
    Isolate.spawnUri(toDartDataUri(source), [], receivePort.sendPort);
  });
}

// 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:isolate";

import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";

Uri toDartDataUri(String source) {
  return Uri.parse("data:application/dart;charset=utf-8,"
      "${Uri.encodeComponent(source)}");
}

main() {
  String source = """
import "dart:isolate";
main(List args, SendPort replyPort) {
replyPort.send(42);
}
""";

  RawReceivePort receivePort;
  asyncStart();
  receivePort = new RawReceivePort((message) {
    Expect.equals(message, 42);
    receivePort.close();
    asyncEnd();
  });
  Isolate.spawnUri(toDartDataUri(source), [], receivePort.sendPort);
}

Migrate a VM test off the ancient deprecated unittest package.
Migrate a VM test off the ancient deprecated unittest package.

Change-Id: Id2d408b87bc40af75899fbe0922ba523cbde148c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136022
Auto-Submit: Bob Nystrom <afede3a9ebedb865bee78398feff6fbe97068f17@google.com>
Reviewed-by: Leaf Petersen <9bef692239b5f624cec8e2cd5249ab1939a377aa@google.com>
Commit-Queue: Bob Nystrom <afede3a9ebedb865bee78398feff6fbe97068f17@google.com>
