Skip to content

Commit

Permalink
Add 0-dim reshape tests for MyBigFill
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Dec 18, 2024
1 parent b704533 commit d1cb8a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ struct MyBigFill{T,N} <: AbstractArray{T,N}
val :: T
axes :: NTuple{N,Base.OneTo{BigInt}}
end
MyBigFill(val, sz::Tuple{}) = MyBigFill{typeof(val),0}(val, sz)
MyBigFill(val, sz::NTuple{N,BigInt}) where {N} = MyBigFill(val, map(Base.OneTo, sz))
MyBigFill(val, sz::Tuple{Vararg{Integer}}) = MyBigFill(val, map(BigInt, sz))
Base.size(M::MyBigFill) = map(length, M.axes)
Expand All @@ -1770,6 +1771,7 @@ function Base.reshape(M::MyBigFill, ind::NTuple{N,BigInt}) where {N}
length(M) == prod(ind) || throw(ArgumentError("length mismatch in reshape"))
MyBigFill(M.val, ind)
end
Base.reshape(M::MyBigFill, ind::Tuple{}) = MyBigFill(M.val, ind)

@testset "reshape" begin
A0 = [1 3; 2 4]
Expand Down Expand Up @@ -1928,6 +1930,10 @@ end
M = MyBigFill(4, (2, 3))
O = OffsetArray(M)
@test vec(O) isa MyBigFill

M = MyBigFill(4, (1,1))
O = OffsetArray(M)
@test reshape(O) == reshape(M)
end
end

Expand Down

0 comments on commit d1cb8a2

Please sign in to comment.