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/scalacheck/range.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test/files/scalacheck') diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala index b14177e38b..6a0e83a47d 100644 --- a/test/files/scalacheck/range.scala +++ b/test/files/scalacheck/range.scala @@ -182,10 +182,25 @@ object SmallValuesRange extends RangeTest("smallValues") { override def myGen = genSmallRange } +object TooLargeRange extends Properties("Too Large Range") { + val genTooLargeStart = for { + start <- choose(-Int.MinValue, 0) + } yield start + + property("Too large range throws exception") = forAll(genTooLargeStart) { start => + try { + val r = Range.inclusive(start, Int.MaxValue, 1) + println("how here? r = " + r.toString) + false + } + catch { case _: IllegalArgumentException => true } + } +} + object Test extends Properties("Range") { import org.scalacheck.{ Test => STest } - List(NormalRangeTest, InclusiveRangeTest, ByOneRangeTest, InclusiveByOneRangeTest) foreach { ps => + List(NormalRangeTest, InclusiveRangeTest, ByOneRangeTest, InclusiveByOneRangeTest, TooLargeRange) foreach { ps => STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), ps) } } -- cgit v1.2.3