Skip to content

Commit 19d8d5d

Browse files
authored
Fix spacing with Base.show (#135)
* fix spacing with `Base.show` * fix tests for new output format
1 parent c88d162 commit 19d8d5d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/interval.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ Construct a ClosedInterval `iv` spanning the region from
9494
±(x, y) = ClosedInterval(x - y, x + y)
9595
±(x::CartesianIndex, y::CartesianIndex) = ClosedInterval(x-y, x+y)
9696

97-
show(io::IO, I::ClosedInterval) = print(io, leftendpoint(I), "..", rightendpoint(I))
98-
show(io::IO, I::OpenInterval) = print(io, leftendpoint(I), "..", rightendpoint(I), " (open)")
99-
show(io::IO, I::Interval{:open,:closed}) = print(io, leftendpoint(I), "..", rightendpoint(I), " (openclosed)")
100-
show(io::IO, I::Interval{:closed,:open}) = print(io, leftendpoint(I), "..", rightendpoint(I), " (closedopen)")
97+
show(io::IO, I::ClosedInterval) = print(io, leftendpoint(I), " .. ", rightendpoint(I))
98+
show(io::IO, I::OpenInterval) = print(io, leftendpoint(I), " .. ", rightendpoint(I), " (open)")
99+
show(io::IO, I::Interval{:open,:closed}) = print(io, leftendpoint(I), " .. ", rightendpoint(I), " (open-closed)")
100+
show(io::IO, I::Interval{:closed,:open}) = print(io, leftendpoint(I), " .. ", rightendpoint(I), " (closed-open)")
101101

102102
# The following are not typestable for mixed endpoint types
103103
_left_intersect_type(::Type{Val{:open}}, ::Type{Val{L2}}, a1, a2) where L2 = a1 < a2 ? (a2,L2) : (a1,:open)

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct IncompleteInterval <: AbstractInterval{Int} end
3636
I = 0..3
3737
@test I === ClosedInterval(0,3) === ClosedInterval{Int}(0,3) ===
3838
Interval(0,3)
39-
@test string(I) == "0..3"
39+
@test string(I) == "0 .. 3"
4040
@test @inferred(UnitRange(I)) === 0:3
4141
@test @inferred(range(I)) === 0:3
4242
@test @inferred(UnitRange{Int16}(I)) === Int16(0):Int16(3)
@@ -47,7 +47,7 @@ struct IncompleteInterval <: AbstractInterval{Int} end
4747
K = 5..4
4848
L = 3 ± 2
4949
M = @inferred(ClosedInterval(2, 5.0))
50-
@test string(M) == "2.0..5.0"
50+
@test string(M) == "2.0 .. 5.0"
5151
N = @inferred(ClosedInterval(UInt8(255), 300))
5252

5353
x, y = CartesianIndex(1, 2, 3, 4), CartesianIndex(1, 2, 3, 4)

0 commit comments

Comments
 (0)