|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license
|
2 | 2 |
|
3 | 3 | using Random, LinearAlgebra, SparseArrays
|
| 4 | +isdefined(Main, :OffsetArrays) || @eval Main include("testhelpers/OffsetArrays.jl") |
| 5 | +using .Main.OffsetArrays |
4 | 6 |
|
5 | 7 | types = Any[
|
6 | 8 | Bool,
|
@@ -93,6 +95,10 @@ vals = Any[
|
93 | 95 | 1:4, 1:1:4, 1:-1:0, 1.0:4.0, 1.0:1.0:4.0, range(1, stop=4, length=4),
|
94 | 96 | # issue #35597, when `LinearIndices` does not begin at 1
|
95 | 97 | Base.IdentityUnitRange(2:4),
|
| 98 | + OffsetArray(1:4, -2), |
| 99 | + OffsetArray([1 3; 2 4], -2, 2), |
| 100 | + OffsetArray(1:4, 0), |
| 101 | + OffsetArray([1 3; 2 4], 0, 0), |
96 | 102 | 'a':'e', ['a', 'b', 'c', 'd', 'e'],
|
97 | 103 | # check that hash is still consistent with heterogeneous arrays for which - is defined
|
98 | 104 | # for some pairs and not others
|
|
105 | 111 |
|
106 | 112 | for a in vals
|
107 | 113 | a isa AbstractArray || continue
|
108 |
| - keys(a) == keys(Array(a)) || continue |
109 |
| - @test hash(a) == hash(Array(a)) == hash(Array{Any}(a)) |
| 114 | + if keys(a) == keys(Array(a)) |
| 115 | + @test hash(a) == hash(Array(a)) == hash(Array{Any}(a)) |
| 116 | + else |
| 117 | + @test hash(a) == hash(OffsetArray(Array(a), (first.(axes(a)).-1)...)) == hash(OffsetArray(Array{Any}(a), (first.(axes(a)).-1)...)) |
| 118 | + end |
110 | 119 | end
|
111 | 120 |
|
112 | 121 | vals = Any[
|
|
0 commit comments