@@ -206,4 +206,27 @@ using Intervals: LeftEndpoint, RightEndpoint
206
206
@test RightEndpoint (1 , false ) != LeftEndpoint (1.0 , true )
207
207
@test RightEndpoint (1 , true ) == LeftEndpoint (1.0 , true )
208
208
end
209
+
210
+ @testset " hash" begin
211
+ # Need a complicated enough element type for this test to possibly fail. Using a
212
+ # ZonedDateTime with a VariableTimeZone should do the trick.
213
+ a = now (tz " Europe/London" )
214
+ b = deepcopy (a)
215
+ @test hash (a) == hash (b) # Double check
216
+
217
+ @test hash (LeftEndpoint (a, false )) == hash (LeftEndpoint (b, false ))
218
+ @test hash (LeftEndpoint (a, true )) != hash (LeftEndpoint (b, false ))
219
+ @test hash (LeftEndpoint (a, false )) != hash (LeftEndpoint (b, true ))
220
+ @test hash (LeftEndpoint (a, true )) == hash (LeftEndpoint (b, true ))
221
+
222
+ @test hash (RightEndpoint (a, false )) == hash (RightEndpoint (b, false ))
223
+ @test hash (RightEndpoint (a, true )) != hash (RightEndpoint (b, false ))
224
+ @test hash (RightEndpoint (a, false )) != hash (RightEndpoint (b, true ))
225
+ @test hash (RightEndpoint (a, true )) == hash (RightEndpoint (b, true ))
226
+
227
+ @test hash (LeftEndpoint (a, false )) != hash (RightEndpoint (b, false ))
228
+ @test hash (LeftEndpoint (a, true )) != hash (RightEndpoint (b, false ))
229
+ @test hash (LeftEndpoint (a, false )) != hash (RightEndpoint (b, true ))
230
+ @test hash (LeftEndpoint (a, true )) != hash (RightEndpoint (b, true ))
231
+ end
209
232
end
0 commit comments