diff --git a/src/Containers/DenseAxisArray.jl b/src/Containers/DenseAxisArray.jl index 0e421cd36c6..4f124de0a50 100644 --- a/src/Containers/DenseAxisArray.jl +++ b/src/Containers/DenseAxisArray.jl @@ -12,7 +12,6 @@ struct _AxisLookup{D} data::D end -Base.:(==)(x::_AxisLookup{D}, y::_AxisLookup{D}) where {D} = x.data == y.data # Default fallbacks. Base.getindex(::_AxisLookup, key) = throw(KeyError(key)) diff --git a/test/Containers/test_DenseAxisArray.jl b/test/Containers/test_DenseAxisArray.jl index fd780720a35..5d4d1345621 100644 --- a/test/Containers/test_DenseAxisArray.jl +++ b/test/Containers/test_DenseAxisArray.jl @@ -874,4 +874,51 @@ function test_multi_arg_eachindex() return end +function test_LinearIndices() + Containers.@container(x[i in 2:3], i) + @test_throws( + ErrorException("DenseAxisArray does not support this operation."), + LinearIndices(x), + ) + return +end + +function test_CartesianIndices() + Containers.@container(x[i in 2:3], i) + @test CartesianIndices(x) == CartesianIndices((2,)) + return +end + +function test_show_nd() + Containers.@container( + x[a in 2:3, b in 2:3, c in 2:14, d in 2:14], + (a, b, c, d), + ) + s = sprint(io -> show(IOContext(io, :limit => true), x)) + limit_indices = [2, 3, 4, 12, 13, 14] + for c in 2:14, d in 2:14 + is_visible = (c in limit_indices && d in limit_indices) + @test occursin("[:, :, $c, $d]", s) == is_visible + for a in 2:3, b in 2:3 + @test occursin("($a, $b, $c, $d)", s) == is_visible + end + end + s = sprint(io -> show(IOContext(io, :limit => false), x)) + limit_indices = [2, 3, 4, 12, 13, 14] + for c in 2:14, d in 2:14 + @test occursin("[:, :, $c, $d]", s) + for a in 2:3, b in 2:3 + @test occursin("($a, $b, $c, $d)", s) + end + end + return +end + +function test_view_DenseAxisArray() + Containers.@container(x[a in 2:3], a) + @test_throws KeyError view(x, 3:4) + @test_throws KeyError view(x, 4) + return +end + end # module diff --git a/test/Containers/test_SparseAxisArray.jl b/test/Containers/test_SparseAxisArray.jl index 86a6b0d85df..296dc83dfba 100644 --- a/test/Containers/test_SparseAxisArray.jl +++ b/test/Containers/test_SparseAxisArray.jl @@ -381,4 +381,11 @@ function test_sparseaxisarray_order() return end +function test_show_empty_limit() + x = SparseAxisArray(Dict{Tuple{Int},Int}()) + @test sprint(io -> show(IOContext(io, :limit => false), x)) == + "$SparseAxisArray{$Int, 1, Tuple{$Int}} with 0 entries" + return +end + end # module diff --git a/test/Containers/test_macro.jl b/test/Containers/test_macro.jl index 9227e240fe0..a4c11493c91 100644 --- a/test/Containers/test_macro.jl +++ b/test/Containers/test_macro.jl @@ -266,4 +266,10 @@ function test_add_additional_args() return end +function test_trailing_semicolon() + Containers.@container(x[a in 2:3; ], a) + @test x isa DenseAxisArray + return +end + end # module diff --git a/test/Containers/test_vectorized_product_iterator.jl b/test/Containers/test_vectorized_product_iterator.jl index 03b509fbbf3..67f7ae5bbf3 100644 --- a/test/Containers/test_vectorized_product_iterator.jl +++ b/test/Containers/test_vectorized_product_iterator.jl @@ -19,6 +19,7 @@ function test_VectorizedProductIterator() @test isempty(collect(Containers.vectorized_product(2, I, 1:0))) @test collect(Containers.vectorized_product(2, I)) == [(2, 1) (2, 3) (2, 2) (2, 4)] + @test ndims(Containers.vectorized_product(2, I)) == 2 return end @@ -35,4 +36,14 @@ function test_infinite_size() return end +function test_container_two_arg() + a = Containers.container(Containers.vectorized_product(2:3, 1:2)) do i, j + return (i, j) + end + Containers.@container(b[i in 2:3, j in 1:2], (i, j)) + @test a == b + return +end + + end # module