1
import org.scalacheck._
7
import scala.collection.mutable.ArraySeq
9
object Test extends Properties("Array") {
10
/** At this moment the authentic scalacheck Array Builder/Arb bits are commented out.
12
implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] =
13
Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray))
15
val arrGen: Gen[Array[_]] = oneOf(
16
arbitrary[Array[Int]],
17
arbitrary[Array[Array[Int]]],
18
arbitrary[Array[List[String]]],
19
arbitrary[Array[String]],
20
arbitrary[Array[Boolean]],
21
arbitrary[Array[AnyVal]]
24
// inspired by #1857 and #2352
25
property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) =>
26
(c1 eq c2) || (c1 ne c2)
30
def smallInt = choose(1, 10)
31
property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) =>
32
val arr = Array.ofDim[String](i1, i2, i3)
33
val flattened = arr flatMap (x => x) flatMap (x => x)
34
flattened.length == i1 * i2 * i3