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:
Ilya Gorbunov
2016-01-13 04:16:42 +03:00
parent 8fdd8179b9
commit f91c01919b
9 changed files with 36 additions and 20 deletions
+3
View File
@@ -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;
+11 -2
View File
@@ -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)
}
}