1- using FunctionWrappersWrappers
21using Test
32
4- @testset " FunctionWrappersWrappers.jl" begin
5- fwplus = FunctionWrappersWrapper (+ , (Tuple{Float64, Float64}, Tuple{Int, Int}), (
6- Float64, Int));
7- @test fwplus (4.0 , 8.0 ) === 12.0
8- @test fwplus (4 , 8 ) === 12
9-
10- fwexp2 = FunctionWrappersWrapper (
11- exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64));
12- @test fwexp2 (4.0 ) === 16.0
13- @test fwexp2 (4.0f0 ) === 16.0f0
14- @test fwexp2 (4 ) === 16.0
15- end
16-
17- using JET: JET, @test_opt
18-
19- @testset " JET static analysis" begin
20- # Test that the main call path is type-stable (no fallback)
21- fwplus = FunctionWrappersWrapper (+ , (Tuple{Float64, Float64}, Tuple{Int, Int}), (
22- Float64, Int))
23-
24- # Core functionality should be type-stable
25- @test_opt target_modules = (FunctionWrappersWrappers,) fwplus (4.0 , 8.0 )
26- @test_opt target_modules = (FunctionWrappersWrappers,) fwplus (4 , 8 )
27-
28- # Test single-argument wrapper
29- fwexp2 = FunctionWrappersWrapper (
30- exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64))
31- @test_opt target_modules = (FunctionWrappersWrappers,) fwexp2 (4.0 )
32- @test_opt target_modules = (FunctionWrappersWrappers,) fwexp2 (4.0f0 )
33- @test_opt target_modules = (FunctionWrappersWrappers,) fwexp2 (4 )
34-
35- # Verify no errors detected by JET.report_call for core paths
36- rep = JET. report_call (fwplus, (Float64, Float64))
37- @test length (JET. get_reports (rep)) == 0
38- rep = JET. report_call (fwplus, (Int, Int))
39- @test length (JET. get_reports (rep)) == 0
40- end
41-
42- @testset " Type inference" begin
43- # Test return type inference
44- fwplus = FunctionWrappersWrapper (+ , (Tuple{Float64, Float64}, Tuple{Int, Int}), (
45- Float64, Int))
46- @test @inferred (fwplus (4.0 , 8.0 )) === 12.0
47- @test @inferred (fwplus (4 , 8 )) === 12
48-
49- fwexp2 = FunctionWrappersWrapper (
50- exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64))
51- @test @inferred (fwexp2 (4.0 )) === 16.0
52- @test @inferred (fwexp2 (4.0f0 )) === 16.0f0
53- @test @inferred (fwexp2 (4 )) === 16.0
54- end
55-
56- @testset " Introspection functions" begin
57- # Test with a simple function
58- fwsin = FunctionWrappersWrapper (sin, (Tuple{Float64},), (Float64,))
59-
60- @testset " unwrap" begin
61- f = unwrap (fwsin)
62- @test f === sin
63- @test f (0.5 ) == sin (0.5 )
64- end
3+ const GROUP = get (ENV , " GROUP" , " All" )
654
66- @testset " wrapped_signatures" begin
67- sigs = wrapped_signatures (fwsin)
68- @test sigs == (Tuple{Float64},)
69- end
70-
71- @testset " wrapped_return_types" begin
72- rets = wrapped_return_types (fwsin)
73- @test rets == (Float64,)
74- end
75-
76- # Test with multiple signatures
77- fwplus = FunctionWrappersWrapper (+ , (Tuple{Float64, Float64}, Tuple{Int, Int}), (
78- Float64, Int))
79-
80- @testset " unwrap with multiple signatures" begin
81- f = unwrap (fwplus)
82- @test f === +
83- @test f (1 , 2 ) == 3
84- end
85-
86- @testset " wrapped_signatures with multiple signatures" begin
87- sigs = wrapped_signatures (fwplus)
88- @test sigs == (Tuple{Float64, Float64}, Tuple{Int, Int})
89- end
90-
91- @testset " wrapped_return_types with multiple signatures" begin
92- rets = wrapped_return_types (fwplus)
93- @test rets == (Float64, Int)
5+ @testset " FunctionWrappersWrappers.jl" begin
6+ if GROUP == " All" || GROUP == " Core"
7+ include (" basictests.jl" )
948 end
959
96- # Test with a custom function
97- my_func (x) = x^ 2
98- fwcustom = FunctionWrappersWrapper (my_func, (Tuple{Float64}, Tuple{Int}), (
99- Float64, Int))
100-
101- @testset " unwrap with custom function" begin
102- f = unwrap (fwcustom)
103- @test f === my_func
104- @test f (3 ) == 9
105- @test f (2.5 ) == 6.25
10+ if GROUP == " All" || GROUP == " nopre"
11+ include (" jet_tests.jl" )
10612 end
107- end
13+ end
0 commit comments