diff --git a/Project.toml b/Project.toml index 4b4f7dd7..0d8880ac 100644 --- a/Project.toml +++ b/Project.toml @@ -23,11 +23,10 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" [targets] -test = ["Test", "JLArrays", "StaticArrays", "OffsetArrays", "PooledArrays", "TypedTables", "WeakRefStrings", "Documenter", "Random"] +test = ["Test", "JLArrays", "StaticArrays", "OffsetArrays", "PooledArrays", "TypedTables", "WeakRefStrings", "Documenter"] diff --git a/test/runtests.jl b/test/runtests.jl index f6a389b8..9ac56f6f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,7 +7,6 @@ using TypedTables: Table using DataAPI: refarray, refvalue using Adapt: adapt, Adapt using JLArrays -using Random using Test using Documenter: doctest @@ -1166,11 +1165,11 @@ Base.BroadcastStyle(::Broadcast.ArrayStyle{MyArray2}, S::Broadcast.DefaultArrayS test_set = Any[s1, s2, s3, s4] tested_style = Any[] dotaddadd((a, b, c),) = @. a + b + c - for is in Iterators.product(randperm(4), randperm(4), randperm(4)) - as = map(i -> test_set[i], is) + for as in Iterators.product(test_set, test_set, test_set) ares = map(a->a.re, as) aims = map(a->a.im, as) style = Broadcast.combine_styles(ares...) + @test Broadcast.combine_styles(as...) === StructArrayStyle{typeof(style),1}() if !(style in tested_style) push!(tested_style, style) if style isa Broadcast.ArrayStyle{MyArray3} @@ -1216,8 +1215,7 @@ Base.BroadcastStyle(::Broadcast.ArrayStyle{MyArray2}, S::Broadcast.DefaultArrayS 1] tested_style = StructArrayStyle[] dotaddsub((a, b, c),) = @. a + b - c - for is in Iterators.product(randperm(6), randperm(6), randperm(6)) - as = map(i -> test_set[i], is) + for as in Iterators.product(test_set, test_set, test_set) if any(a -> a isa StructArray, as) style = Broadcast.combine_styles(as...) if !(style in tested_style) @@ -1229,6 +1227,12 @@ Base.BroadcastStyle(::Broadcast.ArrayStyle{MyArray2}, S::Broadcast.DefaultArrayS @test length(tested_style) == 4 end + @testset "allocation test" begin + a = StructArray{ComplexF64}(undef, 1) + allocated(a) = @allocated a .+ 1 + @test allocated(a) == 2allocated(a.re) + end + @testset "StructStaticArray" begin bclog(s) = log.(s) test_allocated(f, s) = @test (@allocated f(s)) == 0