Skip to content

Commit

Permalink
test: add PromoteTypeConverter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Oct 10, 2023
1 parent 11b8b2b commit e9d869a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/distributions_setuptests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import ExponentialFamily:
promote_samplefloattype,
paramfloattype,
convert_paramfloattype,
FactorizedJoint
FactorizedJoint,
PromoteTypeConverter

function generate_random_distributions(::Type{V} = Any; seed = abs(rand(Int)), Types = (Float32, Float64)) where {V}
rng = StableRNG(seed)
Expand Down
10 changes: 10 additions & 0 deletions test/distributions_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,13 @@ end
)
end
end

@testitem "TypeConverter" begin
include("./distributions_setuptests.jl")

for original_T in (Float16, Float32, Float64), target_T in (Float16, Float32, Float64), n in (1, 2, 3)
converter = PromoteTypeConverter(target_T, convert)

@test typeof(@inferred(converter(rand(original_T)))) === target_T
end
end

0 comments on commit e9d869a

Please sign in to comment.