Skip to content

Commit a0821f4

Browse files
committed
Fix tests for Dates
1 parent f3775de commit a0821f4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

stdlib/Dates/test/ranges.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ using Dates
77

88
using InteractiveUtils: subtypes
99

10+
# Compare ranges by comparing their `first` and `last` elements and their `length`. This
11+
# returns `false` if empty ranges have different startpoints.
12+
==(r::AbstractRange, s::AbstractRange) =
13+
(first(r) == first(s)) & (length(r) == length(s)) & (last(r) == last(s))
14+
1015
let
1116
for T in (Dates.Date, Dates.DateTime)
1217
f1 = T(2014); l1 = T(2013, 12, 31)
@@ -35,7 +40,7 @@ let
3540
@test first(reverse(dr)) < f1
3641
@test last(reverse(dr)) >= f1
3742
@test issorted(dr)
38-
@test sortperm(dr) === Int64(1):Int64(1):Int64(0)
43+
@test sortperm(dr) ==1:1:0
3944
@test !(f1 in dr)
4045
@test !(l1 in dr)
4146
@test !(f1 - pos_step in dr)
@@ -93,7 +98,7 @@ let
9398
@test first(reverse(dr)) > l1
9499
@test last(reverse(dr)) <= l1
95100
@test issorted(dr)
96-
@test sortperm(dr) === Int64(1):Int64(1):Int64(0)
101+
@test sortperm(dr) ==1:1:0
97102
@test !(l1 in dr)
98103
@test !(l1 in dr)
99104
@test !(l1 - neg_step in dr)
@@ -153,7 +158,7 @@ let
153158
@test first(reverse(dr)) < f1
154159
@test last(reverse(dr)) >= f1
155160
@test issorted(dr)
156-
@test sortperm(dr) === Int64(1):Int64(1):Int64(0)
161+
@test sortperm(dr) ==1:1:0
157162
@test !(f1 in dr)
158163
@test !(l1 in dr)
159164
@test !(f1 - pos_step in dr)
@@ -211,7 +216,7 @@ let
211216
@test first(reverse(dr)) > l1
212217
@test last(reverse(dr)) <= l1
213218
@test issorted(dr)
214-
@test sortperm(dr) === Int64(1):Int64(1):Int64(0)
219+
@test sortperm(dr) ==1:1:0
215220
@test !(l1 in dr)
216221
@test !(l1 in dr)
217222
@test !(l1 - neg_step in dr)

0 commit comments

Comments
 (0)