Remove functions which could conflict with the kotlin.assert function.
This commit is contained in:
@@ -16,17 +16,6 @@ private fun locked<T>(lock : Lock, body : () -> T) : T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks boolean value which should be true. If it is false, throws Assertion Error
|
|
||||||
*
|
|
||||||
* @param value value to be checked
|
|
||||||
*/
|
|
||||||
public fun assert(value : Boolean) {
|
|
||||||
if (!value) {
|
|
||||||
throw AssertionError()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list containing all elements which first contains and second does not.
|
* Returns list containing all elements which first contains and second does not.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,23 +61,12 @@ private fun <T> testSuite(builder: TestBuilder<T>, description: TestBuilder<T>.(
|
|||||||
fun <T> testSuite(name: String, description: TestBuilder<T>.() -> Unit) : TestSuite? =
|
fun <T> testSuite(name: String, description: TestBuilder<T>.() -> Unit) : TestSuite? =
|
||||||
testSuite(TestBuilder<T>(name), description)
|
testSuite(TestBuilder<T>(name), description)
|
||||||
|
|
||||||
fun assert(message: String, block: ()-> Boolean) {
|
|
||||||
val actual = block()
|
|
||||||
Assert.assertTrue(message, actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun assert(block: ()-> Boolean) = assert(block.toString(), block)
|
|
||||||
|
|
||||||
fun assertNot(message: String, block: ()-> Boolean) {
|
fun assertNot(message: String, block: ()-> Boolean) {
|
||||||
assert(message){ !block() }
|
Assert.assertTrue(message, block())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertNot(block: ()-> Boolean) = assertNot(block.toString(), block)
|
fun assertNot(block: ()-> Boolean) = assertNot(block.toString(), block)
|
||||||
|
|
||||||
fun assert(actual: Boolean, message: String) {
|
|
||||||
println("Answer: ${actual} for ${message}")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun assertTrue(actual: Boolean, message: String = "") {
|
fun assertTrue(actual: Boolean, message: String = "") {
|
||||||
return assertEquals(true, actual, message)
|
return assertEquals(true, actual, message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public val suite : TestSuite? = testSuite<Int>("test group") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"test 2" - {
|
"test 2" - {
|
||||||
assert(state == 31, "message")
|
assertTrue(state == 31, "message")
|
||||||
println("test '${getName()}': state: $state")
|
println("test '${getName()}': state: $state")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user