Skip to content

Commit 9af73e4

Browse files
committed
add test
1 parent 0f6140f commit 9af73e4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Tests/SwiftJavaTests/BasicRuntimeTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ class BasicRuntimeTests: XCTestCase {
8282
let nullString = String(fromJNI: nil, in: environment)
8383
XCTAssertEqual(nullString, "")
8484
}
85+
86+
func testCrossThreadAccess() async throws {
87+
let environment = try jvm.environment()
88+
let url = try URL("https://swift.org", environment: environment)
89+
let string = await Task.detached {
90+
// This should be called on a different thread
91+
url.toString()
92+
}.value
93+
94+
XCTAssertEqual(string, "https://swift.org")
95+
}
8596
}
8697

8798
@JavaClass("org.swift.javakit.Nonexistent")

0 commit comments

Comments
 (0)