Files
sdk/runtime/tests/vm/dart_2/isolate_send_regex_test.dart
T
Alexander Aprelev 22e9b612a1 [vm/isolate] Fix problems with sending RegExp to newly spawned isolate.
Fixes https://github.com/dart-lang/sdk/issues/41629

TEST=isolate_send_regex_test.dart

Change-Id: Ia8e00e175c9bca5c1c16cc2718f8b2d16cd37104
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193755
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-01 19:52:32 +00:00

39 lines
1.1 KiB
Dart

// Copyright (c) 2021, 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:expect/expect.dart';
f(List args) {
final sendPort = args[0] as SendPort;
final re = args[1] as RegExp;
Expect.stringEquals("RegExp: pattern=abc flags=", re.toString());
sendPort.send(true);
}
main() async {
final rpError = RawReceivePort((e) {
Expect.fail('Spawned isolated failed with $e');
});
{
// Test sending of initialized RegExp
final rp = ReceivePort();
final re = RegExp('abc');
print(re.hasMatch('kukabcdef'));
await Isolate.spawn(f, <dynamic>[rp.sendPort, re],
onError: rpError.sendPort);
Expect.isTrue(await rp.first);
}
{
// Test send of uninitialized RegExp(num_groups is null)
final rp = ReceivePort();
final re = RegExp('abc');
await Isolate.spawn(f, <dynamic>[rp.sendPort, re],
onError: rpError.sendPort);
Expect.isTrue(await rp.first);
}
rpError.close();
}