diff options
author | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2014-06-24 05:18:20 +0200 |
---|---|---|
committer | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2014-06-28 05:36:54 +0200 |
commit | dead39dc5f21c6eac41788e93426c50ddd398c24 (patch) | |
tree | 8f6c5dec0c27258c84f91db7b723372cdd822edf | |
parent | 6887029f100e2c3a90534768da074472f39cf14f (diff) | |
download | scala-dead39dc5f21c6eac41788e93426c50ddd398c24.tar.gz scala-dead39dc5f21c6eac41788e93426c50ddd398c24.tar.bz2 scala-dead39dc5f21c6eac41788e93426c50ddd398c24.zip |
SI-8677 Duration: Zero - Inf should be MinusInf
Fixes #8677. Add basic tests.
-rw-r--r-- | src/library/scala/concurrent/duration/Duration.scala | 2 | ||||
-rw-r--r-- | test/files/jvm/duration-tck.scala | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala index 1b50b7fa56..2eded9f060 100644 --- a/src/library/scala/concurrent/duration/Duration.scala +++ b/src/library/scala/concurrent/duration/Duration.scala @@ -621,7 +621,7 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio } def -(other: Duration) = other match { case x: FiniteDuration => add(-x.length, x.unit) - case _ => other + case _ => -other } def *(factor: Double) = diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index 3bc8a2c100..7db6c49964 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -61,6 +61,11 @@ object Test extends App { minf - inf mustBe minf minf + minf mustBe minf + for (i <- Seq(zero, one, two, three)) { + i - inf mustBe minf + i - minf mustBe inf + } + inf.compareTo(inf) mustBe 0 inf.compareTo(one) mustBe 1 inf.compareTo(minf) mustBe 1 |