Skip to content

Commit

Permalink
Add tests for cancelable bug with non-happy-path finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Aug 15, 2024
1 parent be1b656 commit 333ec28
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/shared/src/test/scala/cats/effect/IOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,17 @@ class IOSpec extends BaseSpec with Discipline with IOPlatformSpecification {
} must completeAs(())
}

"cancelable waits for termination if finalizer errors" in ticked { implicit ticker =>
val test = IO.never.uncancelable.cancelable(IO.raiseError(new Exception))
test.start.flatMap(IO.sleep(1.second) *> _.cancel) must nonTerminate
}

"cancelable waits for termination if finalizer self-cancels" in ticked {
implicit ticker =>
val test = IO.never.uncancelable.cancelable(IO.canceled)
test.start.flatMap(IO.sleep(1.second) *> _.cancel) must nonTerminate
}

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

0 comments on commit 333ec28

Please sign in to comment.