Hi,
I like ScalaCheck, but have two questions. I am using the following generator code
val genLeaf = const(Leaf)
def genNode(level: Int) = for {
left <- genTree(level);
right <- genTree(level)
} yield Node(left, right)
def genTree(level: Int): Gen[Tree] =
if (level == 0) genLeaf
else oneOf(genLeaf, genNode(level - 1))
in order to generate simple binary trees up to a certain size/level. I needed to restrict the size, because otherwise
I received occasionally heap overflow exceptions in some samples. I assume the generation was called to "deeply".
Anyway, my questions are:
(1) Is there an easy way with ScalaCheck to generate all trees up to a certain size and then test
a property exhaustively on the generated trees?
(2) Even if I cannot generate all trees, is there a way to generate the random test cases according to an
order? For example generate trees according to the size, first small trees and then bigger trees. In this
case it would be guaranteed that no case is tested twice....in the code above it will test the Leaf-case many
times over.
Thank you very much,
Christian