Skip to content

Commit

Permalink
Merge pull request #10 from JuliaMath/teh/depwarn0.6
Browse files Browse the repository at this point in the history
Fix typealias and inner constructor depwarns on 0.6
  • Loading branch information
timholy authored Feb 18, 2017
2 parents e7777c2 + 6bc3738 commit dfd1e19
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
julia 0.5-
julia 0.5
Compat 0.18
5 changes: 4 additions & 1 deletion src/IntervalSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ module IntervalSets
using Base: @pure
import Base: eltype, convert, show, in, length, isempty, isequal, issubset, ==, hash, union, intersect, minimum, maximum

using Compat

export AbstractInterval, ClosedInterval, , .., ±, ordered, width

abstract AbstractInterval{T}
@compat abstract type AbstractInterval{T} end

include("closed.jl")

Expand All @@ -27,6 +29,7 @@ ordered(a, b) = ordered(promote(a, b)...)

checked_conversion{T}(::Type{T}, a, b) = _checked_conversion(T, convert(T, a), convert(T, b))
_checked_conversion{T}(::Type{T}, a::T, b::T) = a, b
_checked_conversion(::Type{Any}, a, b) = throw(ArgumentError("$a and $b promoted to type Any"))
_checked_conversion{T}(::Type{T}, a, b) = throw(ArgumentError("$a and $b are not both of type $T"))

end # module
2 changes: 1 addition & 1 deletion src/closed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ immutable ClosedInterval{T} <: AbstractInterval{T}
left::T
right::T

ClosedInterval(l::T, r::T) = new(l, r)
(::Type{ClosedInterval{T}}){T}(l::T, r::T) = new{T}(l, r)
end

ClosedInterval{T}(left::T, right::T) = ClosedInterval{T}(left, right)
Expand Down
7 changes: 2 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ using IntervalSets
using Base.Test

@testset "IntervalSets" begin
io = IOBuffer()
@test ordered(2, 1) == (1, 2)
@test ordered(1, 2) == (1, 2)
@test ordered(Float16(1), 2) == (1, 2)

@testset "Closed Sets" begin
@test_throws ArgumentError :a .. "b"
I = 0..3
print(io, I)
@test takebuf_string(io) == "0..3"
@test string(I) == "0..3"
J = 3..2
K = 5..4
L = 3 ± 2
M = ClosedInterval(2, 5.0)
print(io, M)
@test takebuf_string(io) == "2.0..5.0"
@test string(M) == "2.0..5.0"
N = ClosedInterval(UInt8(255), 300)
O = CartesianIndex(1, 2, 3, 4) ± 2
@test O == (-1..3, 0..4, 1..5, 2..6)
Expand Down

0 comments on commit dfd1e19

Please sign in to comment.