We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e165867 commit 2223432Copy full SHA for 2223432
test/runtests.jl
@@ -216,3 +216,22 @@ SH.@batteries HashEqAsTS2 typesalt = 2
216
@test hash(HashEqAsTS1(identity, 1)) === 0x486b072c90d60e64
217
@test hash(HashEqAsTS2(x->5x, 1)) === 0xa4360acf486c15a4
218
end
219
+
220
+mutable struct HashEqErr
221
+ a
222
+ b
223
+end
224
+Base.hash(::HashEqErr, h::UInt) = error()
225
+Base.isequal(::HashEqErr, ::HashEqErr) = error()
226
+Base.:(==)(::HashEqErr, ::HashEqErr) = error()
227
228
+@testset "structural hash eq" begin
229
+ S = HashEqErr
230
+ @test SH.structural_eq(S(1,3), S(1,3))
231
+ @test !SH.structural_eq(S(1,NaN), S(1,NaN))
232
+ @test SH.structural_isequal(S(1,NaN), S(1,NaN))
233
+ @test !SH.structural_isequal(S(2,NaN), S(1,NaN))
234
+ @test SH.structural_hash(S(2,NaN), UInt(0)) != SH.structural_hash(S(1,NaN), UInt(0))
235
+ @test SH.structural_hash(S(2,NaN), UInt(0)) == SH.structural_hash(S(2,NaN), UInt(0))
236
+ @test SH.structural_hash(S(2,NaN), UInt(0)) != SH.structural_hash(S(2,NaN), UInt(1))
237
0 commit comments