summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-07-03 11:01:02 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-07-03 11:01:02 +0200
commit08782ee9857763bf8c9185c1778dc4a6ce6deac4 (patch)
tree65f7c3e25c6071c202cd566fa3ed8a8b9bc68994
parent716362a6c9d0eac327b5e7a954bded4436ae8f95 (diff)
parentdead39dc5f21c6eac41788e93426c50ddd398c24 (diff)
downloadscala-08782ee9857763bf8c9185c1778dc4a6ce6deac4.tar.gz
scala-08782ee9857763bf8c9185c1778dc4a6ce6deac4.tar.bz2
scala-08782ee9857763bf8c9185c1778dc4a6ce6deac4.zip
Merge pull request #3843 from Blaisorblade/topic/fix-minus-inf
SI-8677 Duration: Zero - Inf should be MinusInf
-rw-r--r--src/library/scala/concurrent/duration/Duration.scala2
-rw-r--r--test/files/jvm/duration-tck.scala5
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