Skip to content

Tests for promote_type #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ include("infinitearrays.jl")
@testset "promotion" begin
Z = Zeros{Int}(5)
Zf = Zeros(5)
@test promote_type(typeof(Z), typeof(Zf)) == typeof(Zf)
O = Ones{Int}(5)
Of = Ones{Float64}(5)
@test promote_type(typeof(O), typeof(Of)) == typeof(Of)
@test [Z,O] isa Vector{Fill{Int,1,Tuple{Base.OneTo{Int}}}}
@test [Z,Of] isa Vector{Fill{Float64,1,Tuple{Base.OneTo{Int}}}}
@test [O,O] isa Vector{Ones{Int,1,Tuple{Base.OneTo{Int}}}}
Expand All @@ -215,6 +217,10 @@ include("infinitearrays.jl")
@test convert(Ones{Int}, Of) ≡ convert(Ones{Int,1}, Of) ≡ convert(typeof(O), Of) ≡ O
@test convert(Zeros{Int}, Zf) ≡ convert(Zeros{Int,1}, Zf) ≡ convert(typeof(Z), Zf) ≡ Z

F = Fill(1, 2)
Ff = Fill(1.0, 2)
@test promote_type(typeof(F), typeof(Ff)) == typeof(Ff)

@test_throws MethodError convert(Zeros{SVector{2,Int}}, Zf)
end
end
Expand Down Expand Up @@ -1566,4 +1572,4 @@ end
@test Base.setindex(Zeros(5), 2, 2) ≡ OneElement(2.0, 2, 5)
@test Base.setindex(Zeros(5,3), 2, 2, 3) ≡ OneElement(2.0, (2,3), (5,3))
@test_throws BoundsError Base.setindex(Zeros(5), 2, 6)
end
end