From f41d3ade90c3cfee772b6475eca7350883b81e2c Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 7 Sep 2012 21:35:17 +0200 Subject: fix some one more issue in Duration - Inf / Zero == Inf - add some more missing test cases - clarify magic constant - move exception descriptions into proper @throws docs --- test/files/jvm/duration-tck.scala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'test/files/jvm/duration-tck.scala') diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala index aa1ac50078..87ffa196ca 100644 --- a/test/files/jvm/duration-tck.scala +++ b/test/files/jvm/duration-tck.scala @@ -88,6 +88,7 @@ object Test extends App { inputs filterNot (_.isFinite) foreach (x => x / zero mustBe x.toUnit(DAYS)) inputs filterNot (_.isFinite) foreach (_ * 0d mustBe undef) + inputs filterNot (_.isFinite) foreach (_ * -0d mustBe undef) inputs filterNot (_.isFinite) foreach (x => x * Double.PositiveInfinity mustBe x) inputs filterNot (_.isFinite) foreach (x => x * Double.NegativeInfinity mustBe -x) @@ -112,7 +113,13 @@ object Test extends App { inputs foreach (undef + _ mustBe undef) inputs foreach (undef - _ mustBe undef) inputs foreach (undef / _ mustBe nan) - inputs filter (_.isFinite) foreach (x => x / zero mustBe x.toUnit(SECONDS) / 0d) + undef / 1 mustBe undef + undef / nan mustBe undef + undef * 1 mustBe undef + undef * nan mustBe undef + inputs foreach (x => x / zero mustBe x.toUnit(SECONDS) / 0d) + inputs foreach (x => x / 0d mustBe Duration.fromNanos(x.toUnit(NANOSECONDS) / 0d)) + inputs foreach (x => x / -0d mustBe Duration.fromNanos(x.toUnit(NANOSECONDS) / -0d)) inputs filterNot (_ eq undef) foreach (_ compareTo undef mustBe -1) inputs filterNot (_ eq undef) foreach (undef compareTo _ mustBe 1) @@ -170,12 +177,11 @@ object Test extends App { // test Deadline val dead = 2.seconds.fromNow val dead2 = 2 seconds fromNow - // view bounds vs. very local type inference vs. operator precedence: sigh - assert(dead.timeLeft > (1 second: Duration)) - assert(dead2.timeLeft > (1 second: Duration)) + assert(dead.timeLeft > 1.second) + assert(dead2.timeLeft > 1.second) Thread.sleep(1.second.toMillis) - assert(dead.timeLeft < (1 second: Duration)) - assert(dead2.timeLeft < (1 second: Duration)) + assert(dead.timeLeft < 1.second) + assert(dead2.timeLeft < 1.second) // check statically retaining finite-ness -- cgit v1.2.3