Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/MArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,9 @@ function Base.view(
end

Base.elsize(::Type{<:MArray{S,T}}) where {S,T} = sizeof(T)

function Base.show(io::IO, S::MArray)
print(io, typeof(S), "(")
show(io, Tuple(S))
print(io, ")")
end
6 changes: 6 additions & 0 deletions src/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,9 @@ end
function promote_rule(::Type{<:SArray{S,T,N,L}}, ::Type{<:SArray{S,U,N,L}}) where {S,T,U,N,L}
SArray{S,promote_type(T,U),N,L}
end

function Base.show(io::IO, S::SArray)
print(io, typeof(S), "(")
show(io, Tuple(S))
print(io, ")")
end
14 changes: 14 additions & 0 deletions test/MArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,18 @@
v[] = 2
@test v[] == 2
end

@testset "show" begin
io = IOBuffer()

S = MVector{2,Float64}(1,2)
show(io, S)
S_str = String(take!(io))
@test S_str == "MVector{2, Float64}((1.0, 2.0))"

S = MMatrix{1, 2, Int, 2}(1, 2)
show(io, S)
S_str = String(take!(io))
@test S_str == "MMatrix{1, 2, $Int, 2}((1, 2))"
end
end
13 changes: 13 additions & 0 deletions test/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,17 @@
@test @inferred(promote_type(SVector{2,Int}, SVector{2,Float64})) === SVector{2,Float64}
@test @inferred(promote_type(SMatrix{2,3,Float32,6}, SMatrix{2,3,Complex{Float64},6})) === SMatrix{2,3,Complex{Float64},6}
end

@testset "show" begin
io = IOBuffer()
S = SVector{2, Float64}(1, 2)
show(io, S)
S_str = String(take!(io))
@test S_str == "SVector{2, Float64}((1.0, 2.0))"

S = SMatrix{1, 2, Int, 2}(1, 2)
show(io, S)
S_str = String(take!(io))
@test S_str == "SMatrix{1, 2, $Int, 2}((1, 2))"
end
end