Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in QuickCheckHeap#genHeap function #1

Open
lucaslabs opened this issue Apr 16, 2015 · 6 comments
Open

Issue in QuickCheckHeap#genHeap function #1

lucaslabs opened this issue Apr 16, 2015 · 6 comments

Comments

@lucaslabs
Copy link

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?

@glebd
Copy link
Owner

glebd commented Apr 16, 2015

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?

@lucaslabs
Copy link
Author

Yes, I was thinking about Scala version.

@dgomesbr
Copy link

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

@lucaslabs
Copy link
Author

Yes @dgomesbr, that do the trick/fix. Thanks for the answer :)

@sigmabooma
Copy link

" This issue is the value() function. Try using Gen.const(empty), genHeap "

@abossenbroek
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants