kotlin.test: 'fail' returns Nothing, 'assertFails' returns Throwable (not nullable).
Js tests now fail at the first failed assertion. #KT-10289 Fixed #KT-10369 Fixed
This commit is contained in:
@@ -27,6 +27,9 @@ public class NumberFormatException(message: String? = null) : RuntimeException(m
|
||||
@library
|
||||
public class NullPointerException(message: String? = null) : RuntimeException(message) {}
|
||||
|
||||
@library
|
||||
public class AssertionError(message: String? = null) : Error(message) {}
|
||||
|
||||
@library
|
||||
public interface Runnable {
|
||||
public open fun run() : Unit;
|
||||
|
||||
@@ -18,14 +18,23 @@ public var asserter: Asserter = QUnitAsserter()
|
||||
public class QUnitAsserter(): Asserter {
|
||||
|
||||
public override fun assertTrue(lazyMessage: () -> String?, actual: Boolean) {
|
||||
QUnit.ok(actual, lazyMessage())
|
||||
assertTrue(actual, lazyMessage())
|
||||
}
|
||||
|
||||
public override fun assertTrue(message: String?, actual: Boolean) {
|
||||
QUnit.ok(actual, message)
|
||||
if (!actual) failWithMessage(message)
|
||||
}
|
||||
|
||||
public override fun fail(message: String?) {
|
||||
public override fun fail(message: String?): Nothing {
|
||||
QUnit.ok(false, message)
|
||||
failWithMessage(message)
|
||||
}
|
||||
|
||||
private fun failWithMessage(message: String?): Nothing {
|
||||
if (message == null)
|
||||
throw AssertionError()
|
||||
else
|
||||
throw AssertionError(message)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user