Skip to content

Commit

Permalink
Merge pull request #4335 from eigenvariable/eigenvariable/2950
Browse files Browse the repository at this point in the history
Add stack-safety test for `ContT#map`
  • Loading branch information
armanbilge authored Nov 4, 2022
2 parents d30be68 + 59d8fbb commit 9c8c5ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/shared/src/test/scala/cats/tests/ContTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ class ContTSuite extends CatsSuite {
assert(contT.run(Eval.now(_)).value === maxIters)
}

// test from issue 2950
test("ContT.map stack-safety") {
val maxIters = 20000
var k = ContT.defer[Eval, Int, Int](0)
for (_ <- 1 to maxIters) {
k = k.map(x => x + 1)
}
assert(k.run(_.pure[Eval]).value == maxIters)
}

test("ContT.callCC short-circuits and invokes the continuation") {
forAll { (cb: Unit => Eval[Int]) =>
var shouldNotChange = false
Expand Down

0 comments on commit 9c8c5ef

Please sign in to comment.