@@ -5,9 +5,23 @@ import Dates
5
5
using Base. GC: gc
6
6
7
7
8
- JavaCall. init ([" -Djava.class.path=$(@__DIR__ ) " ])
9
- # JavaCall.init(["-verbose:gc","-Djava.class.path=$(@__DIR__)"])
10
- # JavaCall.init()
8
+ macro testasync (x)
9
+ :( @test (@sync @async eval ($ x)). result ) |> esc
10
+ end
11
+ macro syncasync (x)
12
+ :( (@sync @async eval ($ x)). result ) |> esc
13
+ end
14
+
15
+
16
+ @testset " initialization" begin
17
+ if JavaCall. JULIA_COPY_STACKS || Sys. iswindows ()
18
+ @testasync JavaCall. init ([" -Djava.class.path=$(@__DIR__ ) " ])== nothing
19
+ else
20
+ @test JavaCall. init ([" -Djava.class.path=$(@__DIR__ ) " ])== nothing
21
+ end
22
+ # JavaCall.init(["-verbose:gc","-Djava.class.path=$(@__DIR__)"])
23
+ # JavaCall.init()
24
+ end
11
25
12
26
System = @jimport java. lang. System
13
27
@info " Java Version: " , jcall (System, " getProperty" , JString, (JString,), " java.version" )
47
61
@test 1 == jcall (jlm, " abs" , jint, (jint,), - 1 )
48
62
end
49
63
64
+ @testset " static_method_call_async_1" begin
65
+ jlm = @jimport " java.lang.Math"
66
+ if JavaCall. JULIA_COPY_STACKS || Sys. iswindows ()
67
+ @testasync 1.0 ≈ jcall (jlm, " sin" , jdouble, (jdouble,), pi / 2 )
68
+ @testasync 1.0 ≈ jcall (jlm, " min" , jdouble, (jdouble,jdouble), 1 ,2 )
69
+ @testasync 1 == jcall (jlm, " abs" , jint, (jint,), - 1 )
70
+ end
71
+ end
72
+
73
+
50
74
@testset " instance_methods_1" begin
51
75
jnu = @jimport java. net. URL
52
76
gurl = jnu ((JString,), " https://en.wikipedia.org" )
230
254
@test isa (narrow (o), JString)
231
255
end
232
256
257
+ @testset " isroottask_1" begin
258
+ @test JavaCall. isroottask ()
259
+ @testasync JavaCall. JULIA_COPY_STACKS || ! JavaCall. isroottask ()
260
+ if ! JavaCall. JULIA_COPY_STACKS && ! Sys. iswindows ()
261
+ @test_throws CompositeException @syncasync JavaCall. assertroottask ()
262
+ @warn " Ran tests for root Task only. REPL and @async are not expected to work with JavaCall. Set JULIA_COPY_STACKS=1 in the environment to test @async function."
263
+ end
264
+ end
233
265
234
266
# At the end, unload the JVM before exiting
235
267
JavaCall. destroy ()
0 commit comments