Moved failsWith to TestJVM.

This commit is contained in:
Evgeny Gerashchenko
2013-01-29 20:43:05 +04:00
parent 63484e28e0
commit 66ce736a81
2 changed files with 13 additions and 13 deletions
-13
View File
@@ -85,19 +85,6 @@ public fun fails(block: ()-> Unit): Throwable? {
}
}
/** Asserts that a block fails with a specific exception being thrown */
public fun <T: Throwable> failsWith(block: ()-> Any): T {
try {
block()
asserter.fail("Expected an exception to be thrown")
throw IllegalStateException("Should have failed")
} catch (e: T) {
//println("Caught expected exception: $e")
// OK
return e
}
}
/**
* A plugin for performing assertions which can reuse JUnit or TestNG
*/
@@ -2,6 +2,19 @@ package kotlin.test
import java.util.ServiceLoader
/** Asserts that a block fails with a specific exception being thrown */
public fun <T: Throwable> failsWith(block: ()-> Any): T {
try {
block()
asserter.fail("Expected an exception to be thrown")
throw IllegalStateException("Should have failed")
} catch (e: T) {
//println("Caught expected exception: $e")
// OK
return e
}
}
/**
* Comments out a block of test code until it is implemented while keeping a link to the code
* to implement in your unit test output