Skip to content

Commit

Permalink
Add test for cancelable leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Feb 28, 2023
1 parent 73a379d commit 84e7ef1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/shared/src/test/scala/cats/effect/IOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,14 @@ class IOSpec extends BaseSpec with Discipline with IOPlatformSpecification {
test.start.flatMap(_.cancel) must completeAs(())
}

"cancelable should not leak" in ticked { implicit ticker =>
val test = IO.deferred[Unit] flatMap { latch =>
latch.get.uncancelable.cancelable(latch.complete(()).void)
}

test.start.flatMap(f => f.cancel *> f.join).flatMap(_.embedError) must completeAs(())
}

"only unmask within current fiber" in ticked { implicit ticker =>
var passed = false
val test = IO uncancelable { poll =>
Expand Down

0 comments on commit 84e7ef1

Please sign in to comment.