Skip to content

Commit

Permalink
Add tests for Result#fromCatchingNonFatal
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg authored and MateuszKubuszok committed Aug 23, 2024
1 parent fed460e commit a4db665
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,23 @@ class PartialResultSpec extends ChimneySpec {
partial.Result.fromCatching(throw exception) ==> partial.Result.fromErrorThrowable(exception)
}

test("fromCatchingNonFatal converts thunk to Result caching NonFatal Throwable as Error") {
val nseEx = new NoSuchElementException("oops")
partial.Result.fromCatchingNonFatal(1) ==> partial.Result.fromValue(1)
partial.Result.fromCatchingNonFatal(throw nseEx) ==> partial.Result.fromErrorThrowable(nseEx)
}

test("fromCatchingNonFatal propagates Fatal Throwable") {
try
partial.Result.fromCatchingNonFatal(throw new OutOfMemoryError("oops"))
catch {
case _: VirtualMachineError =>
()
case th: Throwable =>
throw th
}
}

test(
"traverse with failFast = false preserves parallel semantics (both branches are executed even if one of them fails)"
) {
Expand Down

0 comments on commit a4db665

Please sign in to comment.