-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionSyntaxSpec.scala
31 lines (26 loc) · 1.01 KB
/
OptionSyntaxSpec.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.lightbend.hedgehog.implicits
import com.lightbend.hedgehog.Logs
import com.lightbend.hedgehog.generators.IntGenerators.genInt
import com.lightbend.hedgehog.generators.OptionGenerators._
import com.lightbend.hedgehog.generators.core.ResultGenerators._
import com.lightbend.hedgehog.runner.TestRunner
import hedgehog._
import hedgehog.runner.{property, Test}
object OptionSyntaxSpec extends TestRunner with Logs with OptionImplicits {
override def tests: List[Test] = List(
property("isSome of none fails", propIsSomeOfNoneFails),
property("isSome of some returns result of f", propIsSomeOfSomeIsResult)
)
private def propIsSomeOfNoneFails: Property = forAll {
for {
none <- genNone
result <- genResult
} yield none.isSome((_: Any) => result) ==== Result.failure.log("=== None ===").log(None.toString)
}
private def propIsSomeOfSomeIsResult: Property = forAll {
for {
opt <- genSome(genInt)
result <- genResult
} yield opt.isSome(_ => result) ==== result
}
}