From cfda3b381928dacd28f5ca432bb9366eb1526006 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 2 Apr 2022 12:57:36 +0900 Subject: [PATCH 1/6] update type promotion --- src/interval.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interval.jl b/src/interval.jl index c9e8fbe..e48a690 100644 --- a/src/interval.jl +++ b/src/interval.jl @@ -27,7 +27,7 @@ mathematical notation, the constructed range is `(left, right)`. const OpenInterval{T} = Interval{:open,:open,T} Interval{L,R,T}(i::AbstractInterval) where {L,R,T} = Interval{L,R,T}(endpoints(i)...) -Interval{L,R}(left, right) where {L,R} = Interval{L,R,promote_type(typeof(left), typeof(right))}(left,right) +Interval{L,R}(left, right) where {L,R} = Interval{L,R}(promote(left,right)...) Interval{L,R}(left::T, right::T) where {L,R,T} = Interval{L,R,T}(left, right) Interval(left, right) = ClosedInterval(left, right) From 11450549dae82ba347fd6997b1f62e60258f310e Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 2 Apr 2022 12:58:42 +0900 Subject: [PATCH 2/6] update tests for type promotion error --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index f10ff41..ee4dd5c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -29,7 +29,7 @@ struct IncompleteInterval <: AbstractInterval{Int} end @test ordered(Float16(1), 2) == (1, 2) @testset "Basic Closed Sets" begin - @test_throws ArgumentError :a .. "b" + @test_throws ErrorException :a .. "b" I = 0..3 @test I === ClosedInterval(0,3) === ClosedInterval{Int}(0,3) === Interval(0,3) From b1aefba29c916123cc1a76b615c97d76c672925c Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sun, 15 May 2022 11:15:17 +0900 Subject: [PATCH 3/6] update tests around missing --- test/runtests.jl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index efb09fd..cdc2f20 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,6 +30,7 @@ struct IncompleteInterval <: AbstractInterval{Int} end @testset "Basic Closed Sets" begin @test_throws ErrorException :a .. "b" + @test_throws ErrorException 1 .. missing I = 0..3 @test I === ClosedInterval(0,3) === ClosedInterval{Int}(0,3) === Interval(0,3) @@ -640,12 +641,6 @@ struct IncompleteInterval <: AbstractInterval{Int} end @test I ∩ (0.0..0.5) === 0.0..0.5 end - @testset "Missing endpoints" begin - # TODO: Remove this testset in the next breaking release (#94) - @test ismissing(2 in 1..missing) - @test_broken ismissing(2 in missing..1) # would be fixed by julialang#31171 - end - @testset "in" begin @test in(0.1, 0.0..1.0) == true @test in(0.0, 0.0..1.0) == true From 52ff57bd1c4edc587c3fdb3e701a31a7a57528d5 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sun, 15 May 2022 12:11:01 +0900 Subject: [PATCH 4/6] add tests for Unitful interval --- test/runtests.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index cdc2f20..95e5281 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,7 @@ using Dates using Statistics import Statistics: mean using Random +using Unitful import IntervalSets: Domain, endpoints, closedendpoints, TypedEndpointsInterval @@ -140,6 +141,13 @@ struct IncompleteInterval <: AbstractInterval{Int} end @test_throws MethodError duration(1.2..2.4) end + @testset "Unitful interval" begin + @test 1.5u"m" in 1u"m" .. 2u"m" + @test 1500u"μm" in 1u"mm" .. 1u"m" + @test !(500u"μm" in 1u"mm" .. 1u"m") + @test 1u"m" .. 2u"m" == 1000u"mm" .. 2000u"mm" + end + @testset "Day interval" begin A = Date(1990, 1, 1); B = Date(1990, 3, 1) @test width(ClosedInterval(A, B)) == Dates.Day(59) From dd734beec5549b1ed6087ca18b3529629e96f825 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sun, 15 May 2022 12:11:33 +0900 Subject: [PATCH 5/6] update detect_ambiguities not to count ambiguities in Unitful --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 95e5281..7668e1c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,7 +23,7 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed) struct IncompleteInterval <: AbstractInterval{Int} end @testset "IntervalSets" begin - @test isempty(detect_ambiguities(IntervalSets, Base, Core)) + @test isempty(detect_ambiguities(IntervalSets)) @test ordered(2, 1) == (1, 2) @test ordered(1, 2) == (1, 2) From 34ed8a4ab6379c4d8b66a5d7ac580ba67f666670 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sun, 15 May 2022 19:59:38 +0900 Subject: [PATCH 6/6] add tests for 1u"m" .. 2u"s" --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index 7668e1c..4bb8567 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -32,6 +32,7 @@ struct IncompleteInterval <: AbstractInterval{Int} end @testset "Basic Closed Sets" begin @test_throws ErrorException :a .. "b" @test_throws ErrorException 1 .. missing + @test_throws ErrorException 1u"m" .. 2u"s" I = 0..3 @test I === ClosedInterval(0,3) === ClosedInterval{Int}(0,3) === Interval(0,3)