Skip to content

Commit 7bccccc

Browse files
authored
test: meta: ensure the inference tests are strict about the return type (#42)
1 parent cb67ac4 commit 7bccccc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/runtests.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ allocated(f::F, args::Tuple) where {F} = @allocated f(args...)
1111
allocated(::Type{T}, args::Tuple) where {T} = @allocated T(args...)
1212
test_noalloc(f::F, args::Tuple) where {F} = @test iszero(allocated(f, args))
1313
test_noalloc(::Type{T}, args::Tuple) where {T} = @test iszero(allocated(T, args))
14-
test_inferred(f::F, ::Type{R}, args::Tuple) where {F,R} = @test (@inferred f(args...)) isa R
15-
test_inferred(::Type{T}, ::Type{R}, args::Tuple) where {T,R} = @test (@inferred T(args...)) isa R
16-
test_inferred(::Type{T}, args::Tuple) where {T } = test_inferred(T, T, args)
14+
function test_inferred(f::F, ::Type{R}, args::Tuple) where {F,R}
15+
@test isconcretetype(R) # meta: test-strictness test
16+
@test (@inferred f(args...)) isa R
17+
end
18+
function test_inferred(::Type{T}, ::Type{R}, args::Tuple) where {T,R}
19+
@test isconcretetype(R) # meta: test-strictness test
20+
@test (@inferred T(args...)) isa R
21+
end
22+
test_inferred(::Type{T}, args::Tuple) where {T} = test_inferred(T, T, args)
1723
function test_inferred_noalloc(f::F, ::Type{R}, args::Tuple) where {F,R}
1824
test_noalloc(f, args)
1925
test_inferred(f, R, args)

0 commit comments

Comments
 (0)