Skip to content

Commit 5d8a428

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

7 files changed

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