0

I have a basic question about scalacheck's whenever clause. For some reason, my compiler doesn't recognize whenever, nor the (conditional subset) ==> part.

(I am following along Odersky's second scala course on Coursera, and I've written a scalacheck property as:

property("deleteMin ...") = forAll{
h:H => whenever (isEmpty(h)) {...

The compiler doesn't recognize whenever. Is there something I need to import additionally to

import org.scalacheck._
import Arbitrary._
import Gen._
import Prop._

?

Allen Wang
  • 2,426
  • 2
  • 24
  • 48
  • Don't know about `whenever`, but `==>` can be made available in the current scope via [`org.scalacheck.Prop.BooleanOperators`](https://github.com/rickynils/scalacheck/blob/31e745fcd5936736681b882566c663adcbd727ab/src/main/scala/org/scalacheck/Prop.scala#L342). – jub0bs Aug 23 '16 at 12:14

2 Answers2

1

I'm not an expert on scalacheck, but I have completed the Coursera assignment.

  1. It can be done without whenever.
  2. I can't find whenever mentioned in the API documentation.
jwvh
  • 50,871
  • 7
  • 38
  • 64
1

Scalacheck doesn't have the "whenever" function, but you can use the ==> method instead. (you will need to import org.scalacheck.Prop.BooleanOperators)

If you want to use scalatest property based testing instead of scalacheck you can mix in the Trait PropertyChecks (import org.scalatest.prop.PropertyChecks) and you can use the "whenever" function.