File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 2424
2525# Base.memoryindex exists in Julia 1.13 onwards.
2626@static if VERSION < v " 1.13"
27- # Note: For zero-sized elements, this always returns 1:x.len, which may not be
28- # the correct indices. However, the result is indistinguishable from the "correct"
29- # result, so it doesn't matter
3027 function Base. parentindices (x:: MemoryView )
3128 elz = Base. elsize (x)
3229 return if iszero (elz)
Original file line number Diff line number Diff line change 366366
367367 mem = MemoryView (view (Vector {String} (undef, 10 ), 5 : 7 ))
368368 @test parentindices (mem) == (5 : 7 ,)
369+
370+ mem = MemoryView (Vector {Nothing} (undef, 10 ))[4 : 7 ]
371+ @test parentindices (mem) == (4 : 7 ,)
372+
373+ struct ZeroSized end
374+ mem = MemoryView (Vector {ZeroSized} (undef, 8 ))[3 : 5 ]
375+ @test parentindices (mem) == (3 : 5 ,)
369376 end
370377
371378 @testset " Similar and empty" begin
755762 @test unsafe_from_parts (ref, 2 ) == [1 , 3 ]
756763 @test isempty (unsafe_from_parts (ref, 0 ))
757764 @test mem isa MutableMemoryView{Int}
765+
766+ v2 = MemoryView ([3 , 1 , 4 ])
767+ @test Base. cconvert (Ptr{Int}, v2) === v2. ref
758768end
759769
760770@testset " MemoryKind" begin
You can’t perform that action at this time.
0 commit comments