From 560784d75853200eaff99ac0dbe298eb0851ca27 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Thu, 25 Apr 2024 14:08:07 +0200 Subject: [PATCH] test: meta: ensure the inference tests are strict about the return type --- test/runtests.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 551c45b..10b21b7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -11,9 +11,15 @@ allocated(f::F, args::Tuple) where {F} = @allocated f(args...) allocated(::Type{T}, args::Tuple) where {T} = @allocated T(args...) test_noalloc(f::F, args::Tuple) where {F} = @test iszero(allocated(f, args)) test_noalloc(::Type{T}, args::Tuple) where {T} = @test iszero(allocated(T, args)) -test_inferred(f::F, ::Type{R}, args::Tuple) where {F,R} = @test (@inferred f(args...)) isa R -test_inferred(::Type{T}, ::Type{R}, args::Tuple) where {T,R} = @test (@inferred T(args...)) isa R -test_inferred(::Type{T}, args::Tuple) where {T } = test_inferred(T, T, args) +function test_inferred(f::F, ::Type{R}, args::Tuple) where {F,R} + @test isconcretetype(R) # meta: test-strictness test + @test (@inferred f(args...)) isa R +end +function test_inferred(::Type{T}, ::Type{R}, args::Tuple) where {T,R} + @test isconcretetype(R) # meta: test-strictness test + @test (@inferred T(args...)) isa R +end +test_inferred(::Type{T}, args::Tuple) where {T} = test_inferred(T, T, args) function test_inferred_noalloc(f::F, ::Type{R}, args::Tuple) where {F,R} test_noalloc(f, args) test_inferred(f, R, args)