Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions src/main/scala/scalachecklib/GeneratorsSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ object GeneratorsSection extends Checkers with Matchers with org.scalaexercises.

val validChars: Seq[Char] = res0

check(forAll(vowel) { v =>
validChars.contains(v)
})
check {
forAll(vowel) { v =>
validChars.contains(v)
}
}
}

/** The distribution is uniform, but if you want to control it you can use the frequency combinator:
Expand Down Expand Up @@ -98,9 +100,13 @@ object GeneratorsSection extends Checkers with Matchers with org.scalaexercises.
import org.scalacheck.Gen.{alphaChar, posNum, listOfN}
import org.scalacheck.Prop.forAll

check(forAll(alphaChar)(_.isDigit == res0))
check {
forAll(alphaChar)(_.isDigit == res0)
}

check(forAll(posNum[Int])(n => (n > 0) == res1))
check {
forAll(posNum[Int])(n => (n > 0) == res1)
}

check {
forAll(listOfN(10, posNum[Int])) { list =>
Expand All @@ -125,7 +131,9 @@ object GeneratorsSection extends Checkers with Matchers with org.scalaexercises.

val smallEvenInteger = Gen.choose(0,200) suchThat (_ % 2 == 0)

check(forAll(smallEvenInteger)(_ % 2 == res0))
check {
forAll(smallEvenInteger)(_ % 2 == res0)
}
}

/** ==Case class Generators==
Expand All @@ -146,9 +154,11 @@ object GeneratorsSection extends Checkers with Matchers with org.scalaexercises.
charValue <- Gen.alphaChar
} yield Foo(intValue, charValue)

check(forAll(fooGen) {
foo => foo.intValue > 0 && foo.charValue.isDigit == res0
})
check {
forAll(fooGen) {
foo => foo.intValue > 0 && foo.charValue.isDigit == res0
}
}
}

/** ==Sized Generators==
Expand Down Expand Up @@ -179,10 +189,12 @@ object GeneratorsSection extends Checkers with Matchers with org.scalaexercises.
} yield (size, posNumList, negNumList)
}

check(forAll(myGen) {
case (genSize, posN, negN) =>
posN.length == genSize / res0 && negN.length == genSize * res1 / 3
})
check {
forAll(myGen) {
case (genSize, posN, negN) =>
posN.length == genSize / res0 && negN.length == genSize * res1 / 3
}
}
}

/** ==Generating Containers==
Expand Down Expand Up @@ -214,7 +226,9 @@ object GeneratorsSection extends Checkers with Matchers with org.scalaexercises.

val validNumbers: List[Int] = res0

check(forAll(genIntList)(_ forall (elem => validNumbers.contains(elem))))
check {
forAll(genIntList)(_ forall (elem => validNumbers.contains(elem)))
}
}

}
2 changes: 1 addition & 1 deletion src/main/scala/scalachecklib/PropertiesSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object PropertiesSection extends Checkers with Matchers with org.scalaexercises.

check {
forAll(smallInteger) { n => (n > 100) == res0 } &&
forAll(smallInteger) { n => (n >= 0) == res1 }
forAll(smallInteger) { n => (n >= 0) == res1 }
}

}
Expand Down