Skip to content

Commit

Permalink
tests: improve coverage for types DB
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses4ever committed Sep 8, 2023
1 parent 06d0b56 commit 2bc84af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ is_stable_call(@nospecialize(f :: Function), @nospecialize(ts :: Vector)) = begi
end
(_ #=code=#, res_type) = ct[1] # we ought to have just one method body, I think
res = is_concrete_type(res_type)
# @info "[ is_stable_call ]" res_type
@debug "[ is_stable_call ]" f ts res_type
#print_stable_check(f,ts,res_type,res)
res
end
Expand Down
13 changes: 9 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ end
@testset "Types Database " begin
id1(x)=x
#
# Normally, we don't bail out on Any-arg methods
# Normally, we bail out on Any-arg methods
# (there's no way to enumerate subtypes of Any),
# unless we're lucky and can infer a concrte output with Any
# as the input.
Expand All @@ -293,12 +293,17 @@ end
@test Stb(3) == is_stable_method((@which id1(1)), typesdb_cfg)
# We count fuel in a tricky way: it's
# number of calls to direct_subtypes1 + number of concrete
# tuple types (corresponding to signatures).
# tuple types (corresponding to signatures) checked.
# The example DB has 2 types.

myplus(x,y)=x+y
res = is_stable_method((@which id1(1)), typesdb_cfg)
@test Stb(3) == res
res = is_stable_method((@which myplus(1,2)), typesdb_cfg)
@test Stb(6) == res

uns(x)=if x>1; x+1; else x+1.0 end
resUns = is_stable_method((@which uns(1)), typesdb_cfg)
@info resUns
@test resUns isa Uns
end

module ImportBase; import Base.push!; push!(::Int)=1; end
Expand Down

0 comments on commit 2bc84af

Please sign in to comment.