Skip to content

Commit a0d6e06

Browse files
committed
Add tests
1 parent a92241b commit a0d6e06

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/test_basics.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,24 @@ arrayts = (Array, JLArray)
337337
@test blockstoredlength(a) == 1
338338
@test storedlength(a) == 2 * 4
339339

340+
# Test similar on broadcasted expressions.
341+
a = dev(BlockSparseArray{elt}(undef, ([2, 3], [3, 4])))
342+
bc = Broadcast.broadcasted(+, a, a)
343+
a′ = similar(bc, Float32)
344+
@test a′ isa BlockSparseArray{Float32}
345+
@test blocktype(a′) <: arrayt{Float32,3}
346+
@test axes(a) == (blockedrange([2, 3]), blockedrange([3, 4]))
347+
348+
# Test similar on broadcasted expressions with axes specified.
349+
a = dev(BlockSparseArray{elt}(undef, ([2, 3], [3, 4])))
350+
bc = Broadcast.broadcasted(+, a, a)
351+
a′ = similar(
352+
bc, Float32, (blockedrange([2, 4]), blockedrange([2, 5]), blockedrange([2, 2]))
353+
)
354+
@test a′ isa BlockSparseArray{Float32}
355+
@test blocktype(a′) <: arrayt{Float32,3}
356+
@test axes(a′) == (blockedrange([2, 4]), blockedrange([2, 5]), blockedrange([2, 2]))
357+
340358
a = dev(BlockSparseArray{elt}(undef, ([2, 3], [3, 4])))
341359
@views for b in [Block(1, 2), Block(2, 1)]
342360
a[b] = dev(randn(elt, size(a[b])))

0 commit comments

Comments
 (0)