Skip to content

Commit 0f363ed

Browse files
authored
test: fix code coverage (#3)
1 parent 2e84914 commit 0f363ed

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

test/runtests.jl

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,37 @@ using Aqua: Aqua
3737
@test (@inferred typed_callable(Float64, Tuple{Int, Int}, hypot)) isa CallableWithTypeSignature{Float64}
3838
@test (@inferred typed_callable(Float64, Tuple{Int, Int}, hypot)) isa CallableWithTypeSignature{Float64, Tuple{Int, Int}}
3939
@test (@inferred typed_callable(Float64, Tuple{Int, Int}, hypot)) isa CallableWithTypeSignature{Float64, Tuple{Int, Int}, typeof(hypot)}
40+
@test (@inferred typed_callable(Int, Tuple{Float32}, Int)) isa CallableWithTypeSignature
41+
@test (@inferred typed_callable(Int, Tuple{Float32}, Int)) isa CallableWithTypeSignature{Int}
42+
@test (@inferred typed_callable(Int, Tuple{Float32}, Int)) isa CallableWithTypeSignature{Int, Tuple{Float32}}
43+
@test (@inferred typed_callable(Int, Tuple{Float32}, Int)) isa CallableWithTypeSignature{Int, Tuple{Float32}, Type{Int}}
4044
@test_throws MethodError typed_callable(Int, Int, Int) # arguments type must subtype `Tuple`
4145
end
4246
@testset "arguments type enforcement" begin
43-
f = typed_callable(Any, Tuple{Int}, -)::CallableWithTypeSignature
44-
@test -3 === @inferred f(3)
45-
@test_throws TypeError f(3.0)
47+
@testset "non-`Type`" begin
48+
f = typed_callable(Any, Tuple{Int}, -)::CallableWithTypeSignature
49+
@test -3 === @inferred f(3)
50+
@test_throws TypeError f(3.0)
51+
end
52+
@testset "`Type`" begin
53+
f = typed_callable(Any, Tuple{Int}, Int8)::CallableWithTypeSignature
54+
@test Int8(3) === @inferred f(3)
55+
@test_throws TypeError f(3.0)
56+
end
4657
end
4758
@testset "return type enforcement" begin
48-
f = typed_callable(Int, Tuple, only)::CallableWithTypeSignature
4959
x_int = Any[3]
5060
x_f64 = Any[3.0]
51-
@test 3 === @inferred f(x_int)
52-
@test_throws TypeError f(x_f64)
61+
@testset "non-`Type`" begin
62+
f = typed_callable(Int, Tuple, only)::CallableWithTypeSignature
63+
@test 3 === @inferred f(x_int)
64+
@test_throws TypeError f(x_f64)
65+
end
66+
@testset "`Type`" begin
67+
f = typed_callable(Int, Tuple, Int)::CallableWithTypeSignature
68+
@test 3 === @inferred f(3)
69+
@test 3 === @inferred f(3.0)
70+
end
5371
end
5472
end
5573
end

0 commit comments

Comments
 (0)