diff --git a/docs/src/index.md b/docs/src/index.md index 0e75faf8..c7bb368e 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -32,23 +32,23 @@ This package defines: ```jldoctest julia> a = 1..10 -Interval{Int64,Closed,Closed}(1, 10) +Interval{Int64, Closed, Closed}(1, 10) julia> b = 5..15 -Interval{Int64,Closed,Closed}(5, 15) +Interval{Int64, Closed, Closed}(5, 15) julia> intersect(a, b) -Interval{Int64,Closed,Closed}(5, 10) +Interval{Int64, Closed, Closed}(5, 10) ``` ### Bounds ```jldoctest -julia> a = Interval{Closed,Closed}(1, 10) -Interval{Int64,Closed,Closed}(1, 10) +julia> a = Interval{Closed, Closed}(1, 10) +Interval{Int64, Closed, Closed}(1, 10) -julia> b = Interval{Open,Open}(5, 15) -Interval{Int64,Open,Open}(5, 15) +julia> b = Interval{Open, Open}(5, 15) +Interval{Int64, Open, Open}(5, 15) julia> 5 in a true @@ -57,10 +57,10 @@ julia> 5 in b false julia> intersect(a, b) -Interval{Int64,Open,Closed}(5, 10) +Interval{Int64, Open, Closed}(5, 10) julia> c = Interval(15, 20) -Interval{Int64,Closed,Closed}(15, 20) +Interval{Int64, Closed, Closed}(15, 20) julia> isempty(intersect(b, c)) true @@ -70,21 +70,21 @@ true ```jldoctest julia> a = Interval('a', 'z') -Interval{Char,Closed,Closed}('a', 'z') +Interval{Char, Closed, Closed}('a', 'z') julia> string(a) "[a .. z]" julia> using Dates -julia> b = Interval{Closed,Open}(Date(2013), Date(2016)) -Interval{Date,Closed,Open}(Date("2013-01-01"), Date("2016-01-01")) +julia> b = Interval{Closed, Open}(Date(2013), Date(2016)) +Interval{Date, Closed, Open}(Date("2013-01-01"), Date("2016-01-01")) julia> string(b) "[2013-01-01 .. 2016-01-01)" julia> c = HourEnding(DateTime(2016, 8, 11)) -AnchoredInterval{Hour(-1),DateTime,Open,Closed}(DateTime("2016-08-11T00:00:00")) +HourEnding{DateTime, Open, Closed}(DateTime("2016-08-11T00:00:00")) julia> string(c) "(2016-08-10 HE24]" @@ -96,13 +96,13 @@ julia> string(c) julia> using TimeZones, Dates julia> unrounded = HourEnding(ZonedDateTime(2013, 2, 13, 0, 30, tz"America/Winnipeg")) -AnchoredInterval{Hour(-1),ZonedDateTime,Open,Closed}(ZonedDateTime(2013, 2, 13, 0, 30, tz"America/Winnipeg")) +HourEnding{ZonedDateTime, Open, Closed}(ZonedDateTime(2013, 2, 13, 0, 30, tz"America/Winnipeg")) julia> he = HE(ZonedDateTime(2013, 2, 13, 0, 30, tz"America/Winnipeg")) -AnchoredInterval{Hour(-1),ZonedDateTime,Open,Closed}(ZonedDateTime(2013, 2, 13, 1, tz"America/Winnipeg")) +HourEnding{ZonedDateTime, Open, Closed}(ZonedDateTime(2013, 2, 13, 1, tz"America/Winnipeg")) julia> he + Hour(1) -AnchoredInterval{Hour(-1),ZonedDateTime,Open,Closed}(ZonedDateTime(2013, 2, 13, 2, tz"America/Winnipeg")) +HourEnding{ZonedDateTime, Open, Closed}(ZonedDateTime(2013, 2, 13, 2, tz"America/Winnipeg")) julia> foreach(println, he:he + Day(1)) (2013-02-13 HE01-06:00] @@ -168,14 +168,14 @@ Two `AbstractInterval`s are considered equal if they have identical left and rig endpoints (taking bounds into account): ```jldoctest -julia> a = Interval{Closed,Open}(DateTime(2013, 2, 13), DateTime(2013, 2, 13, 1)) -Interval{DateTime,Closed,Open}(DateTime("2013-02-13T00:00:00"), DateTime("2013-02-13T01:00:00")) +julia> a = Interval{Closed, Open}(DateTime(2013, 2, 13), DateTime(2013, 2, 13, 1)) +Interval{DateTime, Closed, Open}(DateTime("2013-02-13T00:00:00"), DateTime("2013-02-13T01:00:00")) -julia> b = Interval{Open,Closed}(DateTime(2013, 2, 13), DateTime(2013, 2, 13, 1)) -Interval{DateTime,Open,Closed}(DateTime("2013-02-13T00:00:00"), DateTime("2013-02-13T01:00:00")) +julia> b = Interval{Open, Closed}(DateTime(2013, 2, 13), DateTime(2013, 2, 13, 1)) +Interval{DateTime, Open, Closed}(DateTime("2013-02-13T00:00:00"), DateTime("2013-02-13T01:00:00")) julia> c = HourEnding(DateTime(2013, 2, 13, 1)) -AnchoredInterval{Hour(-1),DateTime,Open,Closed}(DateTime("2013-02-13T01:00:00")) +HourEnding{DateTime, Open, Closed}(DateTime("2013-02-13T01:00:00")) julia> a == b false @@ -219,32 +219,32 @@ endpoint should be used for rounding. Valid options are `:left`, `:right`, or ```jldoctest julia> floor(Interval(0.0, 1.0), on=:left) -Interval{Float64,Closed,Closed}(0.0, 1.0) +Interval{Float64, Closed, Closed}(0.0, 1.0) julia> floor(Interval(0.5, 1.0), on=:left) -Interval{Float64,Closed,Closed}(0.0, 0.5) +Interval{Float64, Closed, Closed}(0.0, 0.5) julia> floor(Interval(0.5, 1.5), on=:right) -Interval{Float64,Closed,Closed}(0.0, 1.0) +Interval{Float64, Closed, Closed}(0.0, 1.0) ``` Anchored intervals default to rounding using the anchor point. ```jldoctest julia> round(AnchoredInterval{-0.5}(1.0)) -AnchoredInterval{-0.5,Float64,Open,Closed}(1.0) +AnchoredInterval{-0.5, Float64, Open, Closed}(1.0) julia> round(AnchoredInterval{+0.5}(0.5)) -AnchoredInterval{0.5,Float64,Closed,Open}(0.0) +AnchoredInterval{0.5, Float64, Closed, Open}(0.0) julia> round(AnchoredInterval{+0.5}(0.5), on=:anchor) -AnchoredInterval{0.5,Float64,Closed,Open}(0.0) +AnchoredInterval{0.5, Float64, Closed, Open}(0.0) julia> round(AnchoredInterval{+0.5}(0.5), on=:left) -AnchoredInterval{0.5,Float64,Closed,Open}(0.0) +AnchoredInterval{0.5, Float64, Closed, Open}(0.0) julia> round(AnchoredInterval{+0.5}(0.5), on=:right) -AnchoredInterval{0.5,Float64,Closed,Open}(0.5) +AnchoredInterval{0.5, Float64, Closed, Open}(0.5) ``` ## API diff --git a/src/anchoredinterval.jl b/src/anchoredinterval.jl index 5553dcd7..b406cc37 100644 --- a/src/anchoredinterval.jl +++ b/src/anchoredinterval.jl @@ -29,7 +29,7 @@ specific hour, the constructor makes no guarantees that the anchor provided is r ```jldoctest; setup = :(using Intervals, Dates), filter = r"AnchoredInterval\\{(Day|Hour|Minute)\\(-?\\d+\\),|Hour(Ending|Beginning)\\{" julia> HourEnding(DateTime(2016, 8, 11, 2, 30)) -AnchoredInterval{Hour(-1),DateTime,Open,Closed}(DateTime("2016-08-11T02:30:00")) +HourEnding{DateTime, Open, Closed}(DateTime("2016-08-11T02:30:00")) ``` The `HE` and `HB` pseudoconstructors round the input up or down to the nearest hour, as @@ -37,23 +37,23 @@ appropriate: ```jldoctest; setup = :(using Intervals, Dates), filter = r"AnchoredInterval\\{(Day|Hour|Minute)\\(-?\\d+\\),|Hour(Ending|Beginning)\\{" julia> HE(DateTime(2016, 8, 11, 2, 30)) -AnchoredInterval{Hour(-1),DateTime,Open,Closed}(DateTime("2016-08-11T03:00:00")) +HourEnding{DateTime, Open, Closed}(DateTime("2016-08-11T03:00:00")) julia> HB(DateTime(2016, 8, 11, 2, 30)) -AnchoredInterval{Hour(1),DateTime,Closed,Open}(DateTime("2016-08-11T02:00:00")) +HourBeginning{DateTime, Closed, Open}(DateTime("2016-08-11T02:00:00")) ``` ### Example ```jldoctest; setup = :(using Intervals, Dates), filter = r"AnchoredInterval\\{(Day|Hour|Minute)\\(-?\\d+\\),|Hour(Ending|Beginning)\\{" julia> AnchoredInterval{Hour(-1)}(DateTime(2016, 8, 11, 12)) -AnchoredInterval{Hour(-1),DateTime,Open,Closed}(DateTime("2016-08-11T12:00:00")) +HourEnding{DateTime, Open, Closed}(DateTime("2016-08-11T12:00:00")) julia> AnchoredInterval{Day(1)}(DateTime(2016, 8, 11)) -AnchoredInterval{Day(1),DateTime,Closed,Open}(DateTime("2016-08-11T00:00:00")) +AnchoredInterval{Day(1), DateTime, Closed, Open}(DateTime("2016-08-11T00:00:00")) julia> AnchoredInterval{Minute(5),Closed,Closed}(DateTime(2016, 8, 11, 12, 30)) -AnchoredInterval{Minute(5),DateTime,Closed,Closed}(DateTime("2016-08-11T12:30:00")) +AnchoredInterval{Minute(5), DateTime, Closed, Closed}(DateTime("2016-08-11T12:30:00")) ``` See also: [`Interval`](@ref), [`HE`](@ref), [`HB`](@ref) diff --git a/src/docstrings.jl b/src/docstrings.jl index fa9af823..f64263be 100644 --- a/src/docstrings.jl +++ b/src/docstrings.jl @@ -51,10 +51,10 @@ to each other. ```jldoctest; setup = :(using Intervals; using Intervals: LeftEndpoint) julia> LeftEndpoint(Interval(0.0, 1.0)) -Intervals.Endpoint{Float64,Intervals.Direction{:Left}(),Closed}(0.0) +Intervals.Endpoint{Float64, Intervals.Direction{:Left}(), Closed}(0.0) julia> LeftEndpoint{Closed}(1.0) -Intervals.Endpoint{Float64,Intervals.Direction{:Left}(),Closed}(1.0) +Intervals.Endpoint{Float64, Intervals.Direction{:Left}(), Closed}(1.0) julia> LeftEndpoint{Closed}(1) < LeftEndpoint{Closed}(2) true @@ -80,10 +80,10 @@ to each other. ```jldoctest; setup = :(using Intervals; using Intervals: RightEndpoint) julia> RightEndpoint(Interval(0.0, 1.0)) -Intervals.Endpoint{Float64,Intervals.Direction{:Right}(),Closed}(1.0) +Intervals.Endpoint{Float64, Intervals.Direction{:Right}(), Closed}(1.0) julia> RightEndpoint{Closed}(1.0) -Intervals.Endpoint{Float64,Intervals.Direction{:Right}(),Closed}(1.0) +Intervals.Endpoint{Float64, Intervals.Direction{:Right}(), Closed}(1.0) julia> RightEndpoint{Closed}(1) < RightEndpoint{Closed}(2) true diff --git a/test/anchoredinterval.jl b/test/anchoredinterval.jl index 2dc513cf..6a21a2ff 100644 --- a/test/anchoredinterval.jl +++ b/test/anchoredinterval.jl @@ -248,27 +248,37 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded where_lr = "where R<:$Bounded where L<:$Bounded" where_tlr = "$where_lr where T" - if VERSION >= v"1.6.0-DEV.347" + where_lr2 = "where {L<:$Bounded, R<:$Bounded}" + where_tlr2 = "where {T, L<:$Bounded, R<:$Bounded}" + + if VERSION >= v"1.6.0" @test sprint(show, AnchoredInterval{Hour(-1)}) == - "HourEnding{T,L,R} $where_tlr" + "HourEnding{T, L, R} $where_tlr2" @test sprint(show, AnchoredInterval{Hour(1)}) == - "HourBeginning{T,L,R} $where_tlr" + "HourBeginning{T, L, R} $where_tlr2" + @test sprint(show, AnchoredInterval{Day(-1)}) == + "AnchoredInterval{$(repr(Day(-1))), T, L, R} $where_tlr2" + @test sprint(show, AnchoredInterval{Day(1)}) == + "AnchoredInterval{$(repr(Day(1))), T, L, R} $where_tlr2" + @test sprint(show, AnchoredInterval{Day(-1), DateTime}) == + "AnchoredInterval{$(repr(Day(-1))), DateTime, L, R} $where_lr2" + @test sprint(show, AnchoredInterval{Day(1), DateTime}) == + "AnchoredInterval{$(repr(Day(1))), DateTime, L, R} $where_lr2" else @test sprint(show, AnchoredInterval{Hour(-1)}) == "AnchoredInterval{$(repr(Hour(-1))),T,L,R} $where_tlr" @test sprint(show, AnchoredInterval{Hour(1)}) == "AnchoredInterval{$(repr(Hour(1))),T,L,R} $where_tlr" + @test sprint(show, AnchoredInterval{Day(-1)}) == + "AnchoredInterval{$(repr(Day(-1))),T,L,R} $where_tlr" + @test sprint(show, AnchoredInterval{Day(1)}) == + "AnchoredInterval{$(repr(Day(1))),T,L,R} $where_tlr" + @test sprint(show, AnchoredInterval{Day(-1), DateTime}) == + "AnchoredInterval{$(repr(Day(-1))),DateTime,L,R} $where_lr" + @test sprint(show, AnchoredInterval{Day(1), DateTime}) == + "AnchoredInterval{$(repr(Day(1))),DateTime,L,R} $where_lr" end - @test sprint(show, AnchoredInterval{Day(-1)}) == - "AnchoredInterval{$(repr(Day(-1))),T,L,R} $where_tlr" - @test sprint(show, AnchoredInterval{Day(1)}) == - "AnchoredInterval{$(repr(Day(1))),T,L,R} $where_tlr" - @test sprint(show, AnchoredInterval{Day(-1), DateTime}) == - "AnchoredInterval{$(repr(Day(-1))),DateTime,L,R} $where_lr" - @test sprint(show, AnchoredInterval{Day(1), DateTime}) == - "AnchoredInterval{$(repr(Day(1))),DateTime,L,R} $where_lr" - # Tuples contain fields: interval, printed, shown tests = [ ( @@ -276,7 +286,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded "(2016-08-11 HE02]", string( if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime,Open,Closed}" + "HourEnding{DateTime, Open, Closed}" else "AnchoredInterval{$(repr(Hour(-1))),DateTime,Open,Closed}" end, @@ -288,7 +298,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded "[2013-02-12 HE24)", string( if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime,Closed,Open}" + "HourEnding{DateTime, Closed, Open}" else "AnchoredInterval{$(repr(Hour(-1))),DateTime,Closed,Open}" end, @@ -299,8 +309,8 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(dt + Minute(15) + Second(30)), "(2016-08-11 HE02:15:30]", string( - if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime,Open,Closed}" + if VERSION >= v"1.6.0" + "HourEnding{DateTime, Open, Closed}" else "AnchoredInterval{$(repr(Hour(-1))),DateTime,Open,Closed}" end, @@ -311,8 +321,8 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(dt + Millisecond(2)), "(2016-08-11 HE02:00:00.002]", string( - if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime,Open,Closed}" + if VERSION >= v"1.6.0" + "HourEnding{DateTime, Open, Closed}" else "AnchoredInterval{$(repr(Hour(-1))),DateTime,Open,Closed}" end, @@ -323,8 +333,8 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding{Closed, Open}(DateTime(2013, 2, 13, 0, 1)), "[2013-02-13 HE00:01:00)", string( - if VERSION >= v"1.6.0-DEV.347" - "HourEnding{DateTime,Closed,Open}" + if VERSION >= v"1.6.0" + "HourEnding{DateTime, Closed, Open}" else "AnchoredInterval{$(repr(Hour(-1))),DateTime,Closed,Open}" end, @@ -335,8 +345,8 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourBeginning(dt), "[2016-08-11 HB02)", string( - if VERSION >= v"1.6.0-DEV.347" - "HourBeginning{DateTime,Closed,Open}" + if VERSION >= v"1.6.0" + "HourBeginning{DateTime, Closed, Open}" else "AnchoredInterval{$(repr(Hour(1))),DateTime,Closed,Open}" end, @@ -347,8 +357,8 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourBeginning{Open, Closed}(DateTime(2013, 2, 13)), "(2013-02-13 HB00]", string( - if VERSION >= v"1.6.0-DEV.347" - "HourBeginning{DateTime,Open,Closed}" + if VERSION >= v"1.6.0" + "HourBeginning{DateTime, Open, Closed}" else "AnchoredInterval{$(repr(Hour(1))),DateTime,Open,Closed}" end, @@ -359,8 +369,8 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded HourEnding(ZonedDateTime(dt, tz"America/Winnipeg")), "(2016-08-11 HE02-05:00]", string( - if VERSION >= v"1.6.0-DEV.347" - "HourEnding{$ZonedDateTime,Open,Closed}" + if VERSION >= v"1.6.0" + "HourEnding{$ZonedDateTime, Open, Closed}" else "AnchoredInterval{$(repr(Hour(-1))),$ZonedDateTime,Open,Closed}" end, @@ -371,7 +381,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Year(-1)}(Date(dt)), "(YE 2016-08-11]", string( - "AnchoredInterval{$(repr(Year(-1))),Date,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Year(-1))), Date, Open, Closed}" + else + "AnchoredInterval{$(repr(Year(-1))),Date,Open,Closed}" + end, "($(repr(Date(2016, 8, 11))))", ), ), @@ -379,7 +393,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Year(-1)}(ceil(Date(dt), Year)), "(YE 2017-01-01]", string( - "AnchoredInterval{$(repr(Year(-1))),Date,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Year(-1))), Date, Open, Closed}" + else + "AnchoredInterval{$(repr(Year(-1))),Date,Open,Closed}" + end, "($(repr(Date(2017, 1, 1))))", ), ), @@ -387,7 +405,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Month(-1)}(dt), "(MoE 2016-08-11 02:00:00]", string( - "AnchoredInterval{$(repr(Month(-1))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Month(-1))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Month(-1))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 8, 11, 2, 0, 0))))", ), ), @@ -395,7 +417,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Month(-1)}(ceil(dt, Month)), "(MoE 2016-09-01]", string( - "AnchoredInterval{$(repr(Month(-1))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Month(-1))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Month(-1))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 9, 1))))", ), ), @@ -403,7 +429,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Day(-1)}(DateTime(dt)), "(DE 2016-08-11 02:00:00]", string( - "AnchoredInterval{$(repr(Day(-1))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Day(-1))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Day(-1))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -411,7 +441,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Day(-1)}(ceil(DateTime(dt), Day)), "(DE 2016-08-12]", string( - "AnchoredInterval{$(repr(Day(-1))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Day(-1))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Day(-1))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 8, 12))))", ), ), @@ -420,7 +454,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Day(-1)}(Date(dt)), "(DE 2016-08-11]", string( - "AnchoredInterval{$(repr(Day(-1))),Date,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Day(-1))), Date, Open, Closed}" + else + "AnchoredInterval{$(repr(Day(-1))),Date,Open,Closed}" + end, "($(repr(Date(2016, 8, 11))))", ), ), @@ -432,7 +470,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded ), "(DE 2016-08-12 00:00:00-05:00]", string( - "AnchoredInterval{$(repr(Day(-1))),$ZonedDateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Day(-1))), $ZonedDateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Day(-1))),$ZonedDateTime,Open,Closed}" + end, "($(repr(ZonedDateTime(2016, 8, 12, tz"America/Winnipeg"))))", ), ), @@ -440,7 +482,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Minute(-5)}(dt), "(2016-08-11 5ME02:00]", string( - "AnchoredInterval{$(repr(Minute(-5))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Minute(-5))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Minute(-5))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -448,7 +494,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Second(-30)}(dt), "(2016-08-11 30SE02:00:00]", string( - "AnchoredInterval{$(repr(Second(-30))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Second(-30))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Second(-30))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -456,7 +506,11 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded AnchoredInterval{Millisecond(-10)}(dt), "(2016-08-11 10msE02:00:00.000]", string( - "AnchoredInterval{$(repr(Millisecond(-10))),DateTime,Open,Closed}", + if VERSION >= v"1.6.0" + "AnchoredInterval{$(repr(Millisecond(-10))), DateTime, Open, Closed}" + else + "AnchoredInterval{$(repr(Millisecond(-10))),DateTime,Open,Closed}" + end, "($(repr(DateTime(2016, 8, 11, 2))))", ), ), @@ -477,14 +531,24 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded interval = AnchoredInterval{-10}(10) @test string(interval) == "(0 .. 10]" @test sprint(show, interval, context=:compact=>true) == string(interval) - @test sprint(show, interval) == + + shown = if VERSION >= v"1.6.0" + "AnchoredInterval{-10, $Int, Open, Closed}(10)" + else "AnchoredInterval{-10,$Int,Open,Closed}(10)" + end + @test sprint(show, interval) == shown interval = AnchoredInterval{25}('a') @test string(interval) == "[a .. z)" @test sprint(show, interval, context=:compact=>true) == string(interval) - @test sprint(show, interval) == + + shown = if VERSION >= v"1.6.0" + "AnchoredInterval{25, Char, Closed, Open}('a')" + else "AnchoredInterval{25,Char,Closed,Open}('a')" + end + @test sprint(show, interval) == shown end @testset "equality" begin diff --git a/test/interval.jl b/test/interval.jl index 4c07449b..84fd9818 100644 --- a/test/interval.jl +++ b/test/interval.jl @@ -282,16 +282,34 @@ interval = Interval{Open, Open}(1, 2) @test string(interval) == "(1 .. 2)" @test sprint(show, interval, context=:compact=>true) == string(interval) - @test sprint(show, interval) == "Interval{$Int,Open,Open}(1, 2)" + + shown = if VERSION >= v"1.6.0" + "Interval{$Int, Open, Open}(1, 2)" + else + "Interval{$Int,Open,Open}(1, 2)" + end + @test sprint(show, interval) == shown interval = Interval{Open, Closed}('a', 'b') @test string(interval) == "(a .. b]" @test sprint(show, interval, context=:compact=>true) == string(interval) - @test sprint(show, interval) == "Interval{Char,Open,Closed}('a', 'b')" + shown = if VERSION >= v"1.6.0" + "Interval{Char, Open, Closed}('a', 'b')" + else + "Interval{Char,Open,Closed}('a', 'b')" + end + @test sprint(show, interval) == shown interval = Interval{Closed, Open}(Date(2012), Date(2013)) + + type_str = if VERSION >= v"1.6.0" + "Interval{Date, Closed, Open}" + else + "Interval{Date,Closed,Open}" + end shown = string( - "Interval{Date,Closed,Open}(", + type_str, + "(", sprint(show, Date(2012, 1, 1)), ", ", sprint(show, Date(2013, 1, 1)), @@ -305,8 +323,12 @@ interval = Interval{Closed, Closed}("a", "b") @test string(interval) == "[a .. b]" @test sprint(show, interval, context=:compact=>true) == string(interval) - @test sprint(show, interval) == + shown = if VERSION >= v"1.6.0" + "Interval{String, Closed, Closed}(\"a\", \"b\")" + else "Interval{String,Closed,Closed}(\"a\", \"b\")" + end + @test sprint(show, interval) == shown end @testset "equality" begin diff --git a/test/runtests.jl b/test/runtests.jl index 2c9b64cf..c40d1f4e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,7 +23,7 @@ include("test_utils.jl") # Note: The output of the doctests currently requires a newer version of Julia # https://github.com/JuliaLang/julia/pull/34387 # The doctests fail on x86, so only run them on 64-bit hardware - if VERSION >= v"1.5.0-DEV.163" && Sys.WORD_SIZE == 64 + if v"1.6" <= VERSION < v"1.7" && Sys.WORD_SIZE == 64 doctest(Intervals) else @warn "Skipping doctests"