@@ -3219,42 +3219,23 @@ end
32193219 end
32203220end
32213221
3222- @testset " Wrapping Memory into Arrays with view and reshape" begin
3223- mem:: Memory{Int} = Memory {Int} (undef, 10 ) .= 11 : 20
3224-
3225- @test_throws DimensionMismatch reshape (mem, 10 , 10 )
3226- @test_throws DimensionMismatch reshape (mem, 5 )
3227- @test_throws BoundsError view (mem, 1 : 10 , 1 : 10 )
3228- @test_throws BoundsError view (mem, 1 : 11 )
3229- @test_throws BoundsError view (mem, 3 : 11 )
3230- @test_throws BoundsError view (mem, 0 : 4 )
3231-
3232- @test @inferred (view (mem, 1 : 5 )):: Vector{Int} == 11 : 15
3233- @test @inferred (view (mem, 1 : 2 )):: Vector{Int} == 11 : 12
3234- @test @inferred (view (mem, 1 : 10 )):: Vector{Int} == 11 : 20
3235- @test @inferred (view (mem, 3 : 8 )):: Vector{Int} == 13 : 18
3236- @test @inferred (view (mem, 20 : 19 )):: Vector{Int} == []
3237- @test @inferred (view (mem, - 5 : - 7 )):: Vector{Int} == []
3238- @test @inferred (view (mem, :)):: Vector{Int} == mem
3239- @test @inferred (reshape (mem, 5 , 2 )):: Matrix{Int} == reshape (11 : 20 , 5 , 2 )
3240-
3241- # 53990
3242- @test @inferred (view (mem, unsigned (1 ): 10 )):: Vector{Int} == 11 : 20
3243-
3244- empty_mem = Memory {Module} (undef, 0 )
3245- @test_throws BoundsError view (empty_mem, 0 : 1 )
3246- @test_throws BoundsError view (empty_mem, 1 : 2 )
3247- @test_throws DimensionMismatch reshape (empty_mem, 1 )
3248- @test_throws DimensionMismatch reshape (empty_mem, 1 , 2 , 3 )
3249- @test_throws ArgumentError reshape (empty_mem, 2 ^ 16 , 2 ^ 16 , 2 ^ 16 , 2 ^ 16 )
3250-
3251- @test @inferred (view (empty_mem, 1 : 0 )):: Vector{Module} == []
3252- @test @inferred (view (empty_mem, 10 : 3 )):: Vector{Module} == []
3253- @test @inferred (view (empty_mem, :)):: Vector{Module} == empty_mem
3254- @test isempty (@inferred (reshape (empty_mem, 0 , 7 , 1 )):: Array{Module, 3} )
3255-
3256- offset_inds = OffsetArrays. IdOffsetRange (values= 3 : 6 , indices= 53 : 56 )
3257- @test @inferred (view (collect (mem), offset_inds)) == view (mem, offset_inds)
3222+ @testset " Wrapping Memory into Arrays" begin
3223+ mem = Memory {Int} (undef, 10 ) .= 1
3224+ memref = memoryref (mem)
3225+ @test_throws DimensionMismatch Base. wrap (Array, mem, (10 , 10 ))
3226+ @test Base. wrap (Array, mem, (5 ,)) == ones (Int, 5 )
3227+ @test Base. wrap (Array, mem, 2 ) == ones (Int, 2 )
3228+ @test Base. wrap (Array, memref, 10 ) == ones (Int, 10 )
3229+ @test Base. wrap (Array, memref, (2 ,2 ,2 )) == ones (Int,2 ,2 ,2 )
3230+ @test Base. wrap (Array, mem, (5 , 2 )) == ones (Int, 5 , 2 )
3231+
3232+ memref2 = memoryref (mem, 3 )
3233+ @test Base. wrap (Array, memref2, (5 ,)) == ones (Int, 5 )
3234+ @test Base. wrap (Array, memref2, 2 ) == ones (Int, 2 )
3235+ @test Base. wrap (Array, memref2, (2 ,2 ,2 )) == ones (Int,2 ,2 ,2 )
3236+ @test Base. wrap (Array, memref2, (3 , 2 )) == ones (Int, 3 , 2 )
3237+ @test_throws DimensionMismatch Base. wrap (Array, memref2, 9 )
3238+ @test_throws DimensionMismatch Base. wrap (Array, memref2, 10 )
32583239end
32593240
32603241@testset " Memory size" begin
0 commit comments