Skip to content

Commit

Permalink
simplify when statement
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy committed Jul 21, 2022
1 parent 29ac88c commit 2ca2423
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,13 @@ class VerifyingState(
}

private fun failIfNotPassed(outcome: VerificationResult, inverse: Boolean) {
if (inverse) {
when (outcome) {
is VerificationResult.OK -> {
val callsReport = VerificationHelpers.formatCalls(outcome.verifiedCalls)
throw AssertionError("Inverse verification failed.\n\nVerified calls:\n$callsReport")
}
is VerificationResult.Failure -> {}
when (outcome) {
is VerificationResult.OK -> if (inverse) {
val callsReport = VerificationHelpers.formatCalls(outcome.verifiedCalls)
throw AssertionError("Inverse verification failed.\n\nVerified calls:\n$callsReport")
}
} else {
when (outcome) {
is VerificationResult.Failure -> throw AssertionError("Verification failed: ${outcome.message}")
is VerificationResult.OK -> {}
is VerificationResult.Failure -> if (!inverse) {
throw AssertionError("Verification failed: ${outcome.message}")
}
}
}
Expand Down

0 comments on commit 2ca2423

Please sign in to comment.