I have the following property:
import org.scalacheck.Prop.propBoolean
def elementsAreReversed(list: List[Int], reversed: List[Int]): Boolean =
if (list.isEmpty) true else {
val lastIdx = list.size - 1
list.zipWithIndex.forall { case (element, index) =>
element == reversed(lastIdx - index)
}
}
val propReversed = Prop.forAll { list: List[Int] =>
val reversed = list.reverse
if (list.isEmpty)
list == reversed
else {
val hasSameSize = reversed.size == list.size
val hasAllElements = list.forall(reversed.contains)
// It works until I add a label here:
hasSameSize && hasAllElements && elementsAreReversed(list, reversed)
}
If a add a label it breaks:
hasSameSize :| " a label which doesn't let the code compile" &&
hasAllElements &&
elementsAreReversed(list, reversed)
Compiler gives me the following:
Error:(47, 36) No implicit view available from Any => org.scalacheck.Prop. val propReversed = Prop.forAll { list: List[Int] =>
Error:(47, 36) not enough arguments for method forAll:
(implicit p: Any => org.scalacheck.Prop, implicit a1: org.scalacheck.Arbitrary[List[Int]], implicit s1: org.scalacheck.Shrink[List[Int]], implicit pp1: List[Int] => org.scalacheck.util.Pretty) org.scalacheck.Prop. Unspecified value parameters p, a1, s1...
val propReversed = Prop.forAll { list: List[Int] =>
I'm using ScalaCheck version 1.13.4