Files
sdk/tests/lib_2/isolate/native_wrapper_message_test.dart
T
Alexander Aprelev 67683c3973 [vm/isolates] Introduce 'vm:isolate-unsendable' pragma.
Decorate Zone, Future, Completer, Timer and Stream with newly-introduced pragma to make sure that message verification stops earlier, produces shorter retaining path for the user.

BUG=https://github.com/dart-lang/sdk/issues/51722
TEST=send_unsupported_objects_test,isolate_exit_unsendable_test.dart
CoreLibraryReviewExempt: vm-specific pragmas
Change-Id: I499eea542d228ac9cf0797a682664f93f360dc80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289027
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-27 20:54:11 +00:00

37 lines
860 B
Dart

// Copyright (c) 2018, 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.
// @dart = 2.9
import 'dart:isolate';
import 'dart:nativewrappers';
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
echo(msg) {
var data = msg[0];
var reply = msg[1];
reply.send('echoing ${data(1)}}');
}
class Test extends NativeFieldWrapperClass2 {
Test(this.i, this.j);
int i, j;
}
main() {
var port = new RawReceivePort();
var obj = new Test(1, 2);
var msg = [obj, port.sendPort];
var snd = Isolate.spawn(echo, msg);
asyncStart();
snd.catchError((e) {
Expect.isTrue(e is ArgumentError);
Expect.isTrue("$e".contains("Test"));
port.close();
asyncEnd();
});
}