From f8efb27d75073225ba9ebd65f56821d337f2640a Mon Sep 17 00:00:00 2001 From: Iceman Date: Tue, 17 Nov 2026 10:12:30 +0900 Subject: [PATCH] Test nonisolated actor properties --- .../JNI/JNIActorTests.swift | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Tests/JExtractSwiftTests/JNI/JNIActorTests.swift b/Tests/JExtractSwiftTests/JNI/JNIActorTests.swift index aca720352..74cda25e8 100644 --- a/Tests/JExtractSwiftTests/JNI/JNIActorTests.swift +++ b/Tests/JExtractSwiftTests/JNI/JNIActorTests.swift @@ -273,3 +273,52 @@ struct JNIActor1MethodsTests { ) } } + +@Suite +struct JNIActorPropertyIsolationTests { + static let source = """ + public actor Record { + public nonisolated let identifier: Int64 + public nonisolated var label: Int64 { 7 } + public nonisolated(unsafe) var unsafeValue: Int64 + public var isolatedValue: Int64 + } + """ + + @Test + func javaAccessors() throws { + try assertOutput( + input: Self.source, + .jni, + .java, + expectedChunks: [ + "public long getIdentifier() {", + "public long getLabel() {", + "public long getUnsafeValue() {", + "public void setUnsafeValue(long newValue) {", + "public java.util.concurrent.CompletableFuture getIsolatedValue() {", + "public java.util.concurrent.CompletableFuture setIsolatedValue(long newValue) {", + ] + ) + } + + @Test + func swiftAccessors() throws { + try assertOutput( + input: Self.source, + .jni, + .swift, + expectedChunks: [ + "return selfPointer$.pointee.identifier.getJNILocalRefValue(in: environment)", + "return selfPointer$.pointee.label.getJNILocalRefValue(in: environment)", + "selfPointer$.pointee.unsafeValue = Int64(fromJNI: newValue, in: environment)", + "let swiftResult$ = await selfPointer$.pointee.isolatedValue", + ], + notExpectedChunks: [ + "await selfPointer$.pointee.identifier", + "await selfPointer$.pointee.label", + "await selfPointer$.pointee.unsafeValue", + ] + ) + } +}