diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-19 15:27:19 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-19 15:27:19 +0000 |
commit | 5bb967a3de039830dcc453bb92d3b6a0b794684f (patch) | |
tree | cc33748f925b4c0f307bd23b4b442c57f9b2046a /test | |
parent | 8f0ff8bc2aaaa5299ebe4f617ab9e28443f994bd (diff) | |
download | scala-5bb967a3de039830dcc453bb92d3b6a0b794684f.tar.gz scala-5bb967a3de039830dcc453bb92d3b6a0b794684f.tar.bz2 scala-5bb967a3de039830dcc453bb92d3b6a0b794684f.zip |
Some boundary conditions in range.
infix implicits to Integral and Fractional. As a bonus this patch
knocked 10,000 long boxings off a specialized test. Who knew. Closes
#4308, #4321, review by community.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/implicit-infix-ops.scala | 16 | ||||
-rw-r--r-- | test/files/run/range.scala | 14 | ||||
-rw-r--r-- | test/files/specialized/fft.check | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/test/files/pos/implicit-infix-ops.scala b/test/files/pos/implicit-infix-ops.scala index ef4512fa6b..66f3718e86 100644 --- a/test/files/pos/implicit-infix-ops.scala +++ b/test/files/pos/implicit-infix-ops.scala @@ -5,3 +5,19 @@ object Test { def f1[T: Numeric](x: T, y: T, z: T) = x + y + z def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z) } + +object Int { + import Ordering.Implicits._ + import math.Integral.Implicits._ + + def f1[T: Integral](x: T, y: T, z: T) = (x + y + z) / z + def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z) +} + +object Frac { + import Ordering.Implicits._ + import math.Fractional.Implicits._ + + def f1[T: Fractional](x: T, y: T, z: T) = (x + y + z) / z + def f2[T: Ordering](x: T, y: T, z: T) = if (x < y) (z > y) else (x < z) +}
\ No newline at end of file diff --git a/test/files/run/range.scala b/test/files/run/range.scala index 31d90f2d6d..2dc0bae330 100644 --- a/test/files/run/range.scala +++ b/test/files/run/range.scala @@ -7,6 +7,17 @@ object Test { assert(buffer.toList == range.iterator.toList, buffer.toList+"/"+range.iterator.toList) } + def boundaryTests() = { + // #4321 + assert((Int.MinValue to Int.MaxValue by Int.MaxValue).size == 3) + // #4308 + val caught = ( + try { (Long.MinValue to Long.MaxValue).sum ; false } + catch { case _: IllegalArgumentException => true } + ) + assert(caught) + } + case class GR[T](val x: T)(implicit val num: Integral[T]) { import num._ @@ -54,5 +65,8 @@ object Test { rangeForeach(10 until 1 by -1); rangeForeach(10 to 1 by -3); rangeForeach(10 until 1 by -3); + + // living on the edges + boundaryTests() } } diff --git a/test/files/specialized/fft.check b/test/files/specialized/fft.check index eb56a2a879..69a3a61f36 100644 --- a/test/files/specialized/fft.check +++ b/test/files/specialized/fft.check @@ -1,4 +1,4 @@ Processing 65536 items Boxed doubles: 0 Boxed ints: 2 -Boxed longs: 1442031 +Boxed longs: 1310921 |