From ef05daf1001efb579ab04e43a0b6a7c4d8d9b92c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 16 Sep 2009 22:46:46 +0000 Subject: An enhanced scalacheck with new powers (includi... An enhanced scalacheck with new powers (including arbUnit, for all your arbitrary Unit needs) and some tests for recent Array-related crashers, including test case for the now working #2299. --- test/files/lib/ScalaCheck.jar.desired.sha1 | 2 +- test/files/scalacheck/array.scala | 37 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/files/scalacheck/array.scala (limited to 'test/files') diff --git a/test/files/lib/ScalaCheck.jar.desired.sha1 b/test/files/lib/ScalaCheck.jar.desired.sha1 index 55aa27f176..eaf6a10124 100644 --- a/test/files/lib/ScalaCheck.jar.desired.sha1 +++ b/test/files/lib/ScalaCheck.jar.desired.sha1 @@ -1 +1 @@ -08cea28f282d8360a6344a8cfb853522e18915bb ?ScalaCheck.jar +11d0f9f9235146558bbfe94f3270aa5be3930079 ?ScalaCheck.jar diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array.scala new file mode 100644 index 0000000000..0b7dee5716 --- /dev/null +++ b/test/files/scalacheck/array.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ +import util._ +import Buildable._ + +object Test extends Properties("Array") { + val myGens: Seq[Gen[Array[_]]] = List( + arbArray[Int], + arbArray[Array[Int]], + arbArray[List[String]], + arbArray[String], + arbArray[Boolean], + arbArray[AnyVal](arbAnyVal) + ) map (_.arbitrary) + + property("eq/ne") = + forAll(oneOf(myGens: _*)) { c1 => + forAll(oneOf(myGens: _*)) { c2 => + (c1 eq c2) || (c1 ne c2) + } + } + + def smallInt = choose(1, 10) + property("ofDim") = forAll(smallInt) { i1 => + forAll(smallInt) { i2 => + forAll(smallInt) { i3 => + val arr = Array.ofDim[String](i1, i2, i3) + val flattened = arr flatMap (x => x) flatMap (x => x) + + flattened.length == i1 * i2 * i3 + } + } + } +} + -- cgit v1.2.3