Skip to content

Commit

Permalink
Add a unit test for ContT.defer
Browse files Browse the repository at this point in the history
  • Loading branch information
cb372 committed Jan 15, 2019
1 parent 4ba3a12 commit bbf90b9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/src/test/scala/cats/tests/ContTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,19 @@ class ContTSuite extends CatsSuite {
withContLaw[Eval, Int, String, Int]
}

test("ContT.defer defers evaluation until run is invoked") {
forAll { (b: Int, cb: Int => Eval[String]) =>
var didSideEffect = false

val contT = ContT.defer[Eval, String, Int] {
didSideEffect = true
b
}
didSideEffect should ===(false)

contT.run(cb)
didSideEffect should ===(true)
}
}

}

0 comments on commit bbf90b9

Please sign in to comment.