From c555ff56db737bc65097add317946ee6d6166cd8 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 18 Sep 2012 15:00:48 +0200 Subject: enable integer multiplication/divison on FiniteDuration, see SI-6389 - without this "2.seconds * 2" will not return FiniteDuration but Duration - added test case verifying this behavior - matches normal arithmetics: integers throw on div-by-zero while doubles yield infinity; extended here to include overflow protection on integer multiplication --- test/files/jvm/duration-tck.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index 0947e84004..c5dbe2e133 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -177,10 +177,17 @@ object Test extends App { Thread.sleep(1.second.toMillis) assert(dead.timeLeft < 1.second) assert(dead2.timeLeft < 1.second) + + + // test integer mul/div + 500.millis * 2 mustBe 1.second + (500.millis * 2).unit mustBe MILLISECONDS + 1.second / 2 mustBe 500.millis + (1.second / 2).unit mustBe MILLISECONDS // check statically retaining finite-ness - val finiteDuration: FiniteDuration = 1.second plus 3.seconds minus 1.millisecond min 1.second max 1.second + val finiteDuration: FiniteDuration = 1.second * 2 / 3 mul 5 div 4 plus 3.seconds minus 1.millisecond min 1.second max 1.second } -- cgit v1.2.3