Skip to content

Commit e83b982

Browse files
authored
Merge pull request #12 from JuliaMath/teh/ranges
Support conversions from Ranges
2 parents 9c79dfc + 3c4a92a commit e83b982

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
environment:
22
matrix:
3-
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
4-
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
3+
- JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
4+
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
55
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
66
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
77

src/IntervalSets.jl

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ function convert{I<:AbstractInterval}(::Type{I}, i::AbstractInterval)
2323
T = eltype(I)
2424
I(convert(T, i.left), convert(T, i.right))
2525
end
26+
function convert{I<:AbstractInterval}(::Type{I}, r::Range)
27+
T = eltype(I)
28+
I(convert(T, minimum(r)), convert(T, maximum(r)))
29+
end
2630

2731
ordered{T}(a::T, b::T) = ifelse(a < b, (a, b), (b, a))
2832
ordered(a, b) = ordered(promote(a, b)...)

test/runtests.jl

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using Base.Test
2222
@test eltype(I) == Int
2323
@test eltype(M) == Float64
2424
@test convert(ClosedInterval{Float64}, I) === 0.0..3.0
25+
@test convert(ClosedInterval{Float64}, 0:3) === 0.0..3.0
2526
@test !(convert(ClosedInterval{Float64}, I) === 0..3)
2627
@test ClosedInterval{Float64}(1,3) === 1.0..3.0
2728
@test ClosedInterval(0.5..2.5) === 0.5..2.5
@@ -81,3 +82,5 @@ using Base.Test
8182
@test width(ClosedInterval(4.0,8.0)) 4.0
8283
end
8384
end
85+
86+
nothing

0 commit comments

Comments
 (0)