Merge branch 'wip-1514-duration-inf-rk'
This commit is contained in:
commit
85602fdc89
2 changed files with 12 additions and 4 deletions
|
|
@ -38,6 +38,16 @@ class DurationSpec extends WordSpec with MustMatchers {
|
|||
(inf - minf) must be(inf)
|
||||
(minf - inf) must be(minf)
|
||||
(minf + minf) must be(minf)
|
||||
assert(inf == inf)
|
||||
assert(minf == minf)
|
||||
inf.compareTo(inf) must be(0)
|
||||
inf.compareTo(one) must be(1)
|
||||
minf.compareTo(minf) must be(0)
|
||||
minf.compareTo(one) must be(-1)
|
||||
assert(inf != minf)
|
||||
assert(minf != inf)
|
||||
assert(one != inf)
|
||||
assert(minf != one)
|
||||
}
|
||||
|
||||
"support fromNow" in {
|
||||
|
|
|
|||
|
|
@ -148,8 +148,6 @@ object Duration {
|
|||
trait Infinite {
|
||||
this: Duration ⇒
|
||||
|
||||
override def equals(other: Any) = false
|
||||
|
||||
def +(other: Duration): Duration =
|
||||
other match {
|
||||
case _: this.type ⇒ this
|
||||
|
|
@ -192,7 +190,7 @@ object Duration {
|
|||
*/
|
||||
val Inf: Duration = new Duration with Infinite {
|
||||
override def toString = "Duration.Inf"
|
||||
def compare(other: Duration) = 1
|
||||
def compare(other: Duration) = if (other eq this) 0 else 1
|
||||
def unary_- : Duration = MinusInf
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +200,7 @@ object Duration {
|
|||
*/
|
||||
val MinusInf: Duration = new Duration with Infinite {
|
||||
override def toString = "Duration.MinusInf"
|
||||
def compare(other: Duration) = -1
|
||||
def compare(other: Duration) = if (other eq this) 0 else -1
|
||||
def unary_- : Duration = Inf
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue