diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2014-07-09 16:23:46 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2014-07-09 16:23:46 +0200 |
commit | 4d3ede90b599a344b6d88316a7f62472ef8520e2 (patch) | |
tree | 08066cbe3dfe4f617db1e65cbfc5ea6d1abaa576 | |
parent | d1fa9ac2dc8a9432925e3c7fb4d63e62bdc98a29 (diff) | |
parent | acab0fa000e89d91ef6a809cd1cb70d519d29d5a (diff) | |
download | scala-4d3ede90b599a344b6d88316a7f62472ef8520e2.tar.gz scala-4d3ede90b599a344b6d88316a7f62472ef8520e2.tar.bz2 scala-4d3ede90b599a344b6d88316a7f62472ef8520e2.zip |
Merge pull request #3866 from Blaisorblade/issue/8677-backport
SI-8677 Duration: Zero - Inf should be MinusInf
-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 |