Issue in QuickCheckHeap#genHeap function
Opened this issue · 6 comments
Hi Gleb,
Just cloned your quickcheck example solution and, first of all, I'd like to say that is a great and self explanatory example :)
The thing is that the code is not compiling.
The issue is in the QuickCheckHeap#genHeap function:
lazy val genHeap: Gen[H] = for {
a <- arbitrary[Int]
h <- oneOf(value(empty), genHeap)
} yield insert(a, h)
The specific issue is for the value
method. The Eclipse Problems tab says: "not found: value value".
Any help?
It's been a while since I touched this code, but IIRC I was using IntelliJ IDEA -- maybe it's an Eclipse issue? Or maybe it's due to changes in a later version of Scala?
Yes, I was thinking about Scala version.
It's the scala version, but guys play fair and try to create your own. The corrected version for the scala should use const instead of value:
lazy val genHeap: Gen[H] = for {
v <- arbitrary[Int]
h <- oneOf(const(empty), genHeap)
} yield insert(v, h)
this fix #1
" This issue is the value() function. Try using Gen.const(empty), genHeap "
Somehow I get a NullPointerException
with this implementation,
val genQueue = for {
v <- arbitrary[Int]
orgQueue <- genHeap
} yield insert(v, orgQueue)
val meldQueue = for {
q1 <- genHeap
q2 <- genHeap
} yield meld(q1, q2)
lazy val genHeap: Gen[H] = oneOf(const(empty), genQueue, meldQueue)
any tips on what could possibly cause this, I am interested in learning from my mistakes.