Skip to content

Commit 5a71af3

Browse files
authored
Merge pull request #35624 from JuliaLang/mb/test35598
More hashing tests for offset arrays
2 parents 9010b7f + 9d4b33c commit 5a71af3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/hashing.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
using Random, LinearAlgebra, SparseArrays
4+
isdefined(Main, :OffsetArrays) || @eval Main include("testhelpers/OffsetArrays.jl")
5+
using .Main.OffsetArrays
46

57
types = Any[
68
Bool,
@@ -93,6 +95,10 @@ vals = Any[
9395
1:4, 1:1:4, 1:-1:0, 1.0:4.0, 1.0:1.0:4.0, range(1, stop=4, length=4),
9496
# issue #35597, when `LinearIndices` does not begin at 1
9597
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),
96102
'a':'e', ['a', 'b', 'c', 'd', 'e'],
97103
# check that hash is still consistent with heterogeneous arrays for which - is defined
98104
# for some pairs and not others
@@ -105,8 +111,11 @@ end
105111

106112
for a in vals
107113
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
110119
end
111120

112121
vals = Any[

0 commit comments

Comments
 (0)