From 00b42b18ed462db89956de881bbc13740cd8ba82 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 1 Nov 2010 14:26:28 +0000 Subject: Took a step back and massively simplified Range. all the boundary conditions I'm aware of, including not yet reported ones such as scala> 5 until 5 last res0: Int = 4 and scala> 1073741823 to Int.MaxValue by (1 << 24) size res0: Int = 65 scala> 1073741823 to Int.MaxValue by (1 << 24) drop 100 size res1: Int = 256 Also includes conformance improvements (e.g. 5 until 5 init should throw an exception, not return empty) and general improvements (e.g. 1 to 10 tail should return a Range.) Will close associated tickets such as #3232 after I complete similar work on NumericRange. Review by community. --- test/files/run/bug3232.scala | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/files/run/bug3232.scala (limited to 'test/files/run/bug3232.scala') diff --git a/test/files/run/bug3232.scala b/test/files/run/bug3232.scala new file mode 100644 index 0000000000..acb1a1e0e9 --- /dev/null +++ b/test/files/run/bug3232.scala @@ -0,0 +1,21 @@ +object Test { + // some maximally sized ranges + val r1 = 0 until Int.MaxValue + val r2 = 1 to Int.MaxValue + val r3 = Int.MinValue to -2 + val r4 = Int.MinValue until -1 + + // some exceptional conditions + val e1 = () => (0 to Int.MaxValue).length + val e2 = () => (5 until 5).last + + def main(args: Array[String]): Unit = { + List(r1, r2, r3, r4) foreach (x => assert(x.length == Int.MaxValue)) + + // exception required + List(e1, e2) foreach { f => + try { f() ; assert(false) } + catch { case _ => () } + } + } +} -- cgit v1.2.3