Skip to content

Commit c9d1bb3

Browse files
committed
Finalize nopre test group structure and rebase on main
1 parent 72adf82 commit c9d1bb3

7 files changed

Lines changed: 411 additions & 74 deletions

File tree

.github/workflows/Tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26+
group:
27+
- Core
28+
- nopre
2629
version:
2730
- '1'
2831
- 'lts'
2932
- 'nightly'
3033
arch:
3134
- x64
35+
exclude:
36+
- version: 'nightly'
37+
group: 'nopre'
3238
uses: "SciML/.github/.github/workflows/tests.yml@v1"
3339
with:
40+
group: "${{ matrix.group }}"
3441
julia-version: "${{ matrix.version }}"
3542
julia-arch: "${{ matrix.arch }}"
3643
secrets: "inherit"

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ TruncatedStacktraces = "1"
1515
julia = "1.6"
1616

1717
[extras]
18+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1819
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1920

2021
[targets]
21-
test = ["Test"]
22+
test = ["Pkg", "Test"]

test/basictests.jl

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using FunctionWrappersWrappers
2+
using Test
3+
4+
@testset "FunctionWrappersWrappers.jl" begin
5+
fwplus = FunctionWrappersWrapper(
6+
+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
7+
Float64, Int,
8+
)
9+
)
10+
@test fwplus(4.0, 8.0) === 12.0
11+
@test fwplus(4, 8) === 12
12+
13+
fwexp2 = FunctionWrappersWrapper(
14+
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64)
15+
)
16+
@test fwexp2(4.0) === 16.0
17+
@test fwexp2(4.0f0) === 16.0f0
18+
@test fwexp2(4) === 16.0
19+
end
20+
21+
@testset "Type inference" begin
22+
# Test return type inference
23+
fwplus = FunctionWrappersWrapper(
24+
+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
25+
Float64, Int,
26+
)
27+
)
28+
@test @inferred(fwplus(4.0, 8.0)) === 12.0
29+
@test @inferred(fwplus(4, 8)) === 12
30+
31+
fwexp2 = FunctionWrappersWrapper(
32+
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64)
33+
)
34+
@test @inferred(fwexp2(4.0)) === 16.0
35+
@test @inferred(fwexp2(4.0f0)) === 16.0f0
36+
@test @inferred(fwexp2(4)) === 16.0
37+
end
38+
39+
@testset "Introspection functions" begin
40+
# Test with a simple function
41+
fwsin = FunctionWrappersWrapper(sin, (Tuple{Float64},), (Float64,))
42+
43+
@testset "unwrap" begin
44+
f = unwrap(fwsin)
45+
@test f === sin
46+
@test f(0.5) == sin(0.5)
47+
end
48+
49+
@testset "wrapped_signatures" begin
50+
sigs = wrapped_signatures(fwsin)
51+
@test sigs == (Tuple{Float64},)
52+
end
53+
54+
@testset "wrapped_return_types" begin
55+
rets = wrapped_return_types(fwsin)
56+
@test rets == (Float64,)
57+
end
58+
59+
# Test with multiple signatures
60+
fwplus = FunctionWrappersWrapper(
61+
+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (
62+
Float64, Int,
63+
)
64+
)
65+
66+
@testset "unwrap with multiple signatures" begin
67+
f = unwrap(fwplus)
68+
@test f === +
69+
@test f(1, 2) == 3
70+
end
71+
72+
@testset "wrapped_signatures with multiple signatures" begin
73+
sigs = wrapped_signatures(fwplus)
74+
@test sigs == (Tuple{Float64, Float64}, Tuple{Int, Int})
75+
end
76+
77+
@testset "wrapped_return_types with multiple signatures" begin
78+
rets = wrapped_return_types(fwplus)
79+
@test rets == (Float64, Int)
80+
end
81+
82+
# Test with a custom function
83+
my_func(x) = x^2
84+
fwcustom = FunctionWrappersWrapper(
85+
my_func, (Tuple{Float64}, Tuple{Int}), (
86+
Float64, Int,
87+
)
88+
)
89+
90+
@testset "unwrap with custom function" begin
91+
f = unwrap(fwcustom)
92+
@test f === my_func
93+
@test f(3) == 9
94+
@test f(2.5) == 6.25
95+
end
96+
end

test/nopre/Manifest.toml

Lines changed: 261 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/nopre/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[deps]
2+
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
3+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
4+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

0 commit comments

Comments
 (0)