Skip to content

Commit

Permalink
Handle DecoratedInterval(a,b,dec) without constructing Interval(a,b) …
Browse files Browse the repository at this point in the history
…directly
  • Loading branch information
Luis Benet committed May 12, 2016
1 parent edeab3b commit 807cb5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/decorations/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ function DecoratedInterval{T<:Real}(a::T, b::T, d::DECORATION)
DecoratedInterval(Interval(a,b), d)
end
DecoratedInterval{T<:Real}(a::T, d::DECORATION) = DecoratedInterval(Interval(a,a), d)
DecoratedInterval(a::Tuple, d::DECORATION) = DecoratedInterval(Interval(a...), d)
DecoratedInterval(a::Tuple, d::DECORATION) = DecoratedInterval(a..., d)
DecoratedInterval{T<:Real, S<:Real}(a::T, b::S, d::DECORATION) =
DecoratedInterval(Interval(promote(a,b)...), d)
DecoratedInterval(promote(a,b)..., d)

# Automatic decorations for an interval
DecoratedInterval(I::Interval) = DecoratedInterval(I, decoration(I))
Expand Down
4 changes: 4 additions & 0 deletions test/decoration_tests/decoration_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ facts("DecoratedInterval tests") do
d = DecoratedInterval(a, dac)
@fact decoration(d) --> dac

@fact decoration(DecoratedInterval(1.1)) --> com
@fact decoration(DecoratedInterval(1.1, dac)) --> dac

@fact decoration(DecoratedInterval(2, 0.1, com)) --> ill
@fact decoration(DecoratedInterval(2, 0.1)) --> ill
@fact isnai(interval_part(DecoratedInterval(2, 0.1))) --> true
@fact decoration(@decorated(2, 0.1)) --> ill
Expand Down

0 comments on commit 807cb5d

Please sign in to comment.