Skip to content

Commit

Permalink
Applies TestRunner change to assert on EvaluationFail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Aug 8, 2024
1 parent 9a7bbc2 commit ff35761
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class TestRunner<T, V>(private val factory: TestExecutor.Factory<T, V>) {
case.statements.forEach { run(it, case, executor) }
}

private class TestRunnerException(message: String) : RuntimeException(message)

private fun run(input: String, case: TestCase, executor: TestExecutor<T, V>) {
val assertion = case.assertion
try {
Expand All @@ -41,9 +43,11 @@ class TestRunner<T, V>(private val factory: TestExecutor.Factory<T, V>) {
}
is Assertion.EvaluationFailure -> {
val ion = executor.toIon(actual)
error("Expected error to be thrown but none was thrown.\n${case.name}\nActual result: $ion")
throw TestRunnerException("Expected error to be thrown but none was thrown.\n${case.name}\nActual result: $ion")
}
}
} catch (e: TestRunnerException) {
throw TestRunnerException(e.message ?: "Expected error to be thrown but none was thrown.")
} catch (e: Exception) {
when (case.assertion) {
is Assertion.EvaluationSuccess -> throw IllegalStateException("Expected success but exception thrown.", e)
Expand Down

0 comments on commit ff35761

Please sign in to comment.