Remove usages of deprecated failsWith

This commit is contained in:
Ilya Gorbunov
2015-09-07 16:38:18 +03:00
parent c14f376d21
commit f7c2f034b3
4 changed files with 57 additions and 57 deletions
+13 -13
View File
@@ -14,7 +14,7 @@ class PreconditionsTest() {
}
test fun failingRequire() {
val error = failsWith(javaClass<IllegalArgumentException>()) {
val error = assertFailsWith(IllegalArgumentException::class) {
require(false)
}
assertNotNull(error.getMessage())
@@ -25,14 +25,14 @@ class PreconditionsTest() {
}
test fun failingRequireWithMessage() {
val error = failsWith(javaClass<IllegalArgumentException>()) {
val error = assertFailsWith(IllegalArgumentException::class) {
require(false, "Hello")
}
assertEquals("Hello", error.getMessage())
}
test fun failingRequireWithLazyMessage() {
val error = failsWith(javaClass<IllegalArgumentException>()) {
val error = assertFailsWith(IllegalArgumentException::class) {
require(false) { "Hello" }
}
assertEquals("Hello", error.getMessage())
@@ -47,7 +47,7 @@ class PreconditionsTest() {
}
test fun failingCheck() {
val error = failsWith(javaClass<IllegalStateException>()) {
val error = assertFailsWith(IllegalStateException::class) {
check(false)
}
assertNotNull(error.getMessage())
@@ -58,14 +58,14 @@ class PreconditionsTest() {
}
test fun failingCheckWithMessage() {
val error = failsWith(javaClass<IllegalStateException>()) {
val error = assertFailsWith(IllegalStateException::class) {
check(false, "Hello")
}
assertEquals("Hello", error.getMessage())
}
test fun failingCheckWithLazyMessage() {
val error = failsWith(javaClass<IllegalStateException>()) {
val error = assertFailsWith(IllegalStateException::class) {
check(false) { "Hello" }
}
assertEquals("Hello", error.getMessage())
@@ -78,14 +78,14 @@ class PreconditionsTest() {
}
test fun requireNotNullFails() {
failsWith(javaClass<IllegalArgumentException>()) {
assertFailsWith(IllegalArgumentException::class) {
val s2: String? = null
requireNotNull(s2)
}
}
test fun requireNotNullWithLazyMessage() {
val error = failsWith(javaClass<IllegalArgumentException>()) {
val error = assertFailsWith(IllegalArgumentException::class) {
val obj: Any? = null
requireNotNull(obj) { "Message" }
}
@@ -106,7 +106,7 @@ class PreconditionsTest() {
}
test fun checkNotNullFails() {
failsWith(javaClass<IllegalStateException>()) {
assertFailsWith(IllegalStateException::class) {
val s2: String? = null
checkNotNull(s2)
}
@@ -122,7 +122,7 @@ class PreconditionsTest() {
test fun failingAssert() {
val error = fails {
val error = assertFails {
assert(false)
}
if (error is AssertionError) {
@@ -133,7 +133,7 @@ class PreconditionsTest() {
}
test fun error() {
val error = fails {
val error = assertFails {
error("There was a problem")
}
if (error is IllegalStateException) {
@@ -148,7 +148,7 @@ class PreconditionsTest() {
}
test fun failingAssertWithMessage() {
val error = fails {
val error = assertFails {
assert(false, "Hello")
}
if (error is AssertionError) {
@@ -159,7 +159,7 @@ class PreconditionsTest() {
}
test fun failingAssertWithLazyMessage() {
val error = fails {
val error = assertFails {
assert(false) { "Hello" }
}
if (error is AssertionError) {
@@ -2,7 +2,6 @@ package iterators
import kotlin.test.assertEquals
import org.junit.Test as test
import kotlin.test.failsWith
class IteratorsJVMTest {
+42 -41
View File
@@ -23,55 +23,56 @@ public class RangeJVMTest {
}
test fun illegalProgressionCreation() {
fun assertFailsWithIllegalArgument(f: () -> Unit) = assertFailsWith(IllegalArgumentException::class, block = f)
// create Progression explicitly with increment = 0
failsWith(javaClass<IllegalArgumentException>()) { IntProgression(0, 5, 0) }
failsWith(javaClass<IllegalArgumentException>()) { ByteProgression(0, 5, 0) }
failsWith(javaClass<IllegalArgumentException>()) { ShortProgression(0, 5, 0) }
failsWith(javaClass<IllegalArgumentException>()) { LongProgression(0, 5, 0) }
failsWith(javaClass<IllegalArgumentException>()) { CharProgression('a', 'z', 0) }
failsWith(javaClass<IllegalArgumentException>()) { DoubleProgression(0.0, 5.0, 0.0) }
failsWith(javaClass<IllegalArgumentException>()) { FloatProgression(0.0f, 5.0f, 0.0f) }
assertFailsWithIllegalArgument { IntProgression(0, 5, 0) }
assertFailsWithIllegalArgument { ByteProgression(0, 5, 0) }
assertFailsWithIllegalArgument { ShortProgression(0, 5, 0) }
assertFailsWithIllegalArgument { LongProgression(0, 5, 0) }
assertFailsWithIllegalArgument { CharProgression('a', 'z', 0) }
assertFailsWithIllegalArgument { DoubleProgression(0.0, 5.0, 0.0) }
assertFailsWithIllegalArgument { FloatProgression(0.0f, 5.0f, 0.0f) }
failsWith(javaClass<IllegalArgumentException>()) { 0..5 step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toByte()..5.toByte() step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toShort()..5.toShort() step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0L..5L step 0L }
failsWith(javaClass<IllegalArgumentException>()) { 'a'..'z' step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0..5.0 step 0.0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0f..5.0f step 0.0f }
assertFailsWithIllegalArgument { 0..5 step 0 }
assertFailsWithIllegalArgument { 0.toByte()..5.toByte() step 0 }
assertFailsWithIllegalArgument { 0.toShort()..5.toShort() step 0 }
assertFailsWithIllegalArgument { 0L..5L step 0L }
assertFailsWithIllegalArgument { 'a'..'z' step 0 }
assertFailsWithIllegalArgument { 0.0..5.0 step 0.0 }
assertFailsWithIllegalArgument { 0.0f..5.0f step 0.0f }
failsWith(javaClass<IllegalArgumentException>()) { 0 downTo -5 step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toByte() downTo -5.toByte() step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toShort() downTo -5.toShort() step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0L downTo -5L step 0L }
failsWith(javaClass<IllegalArgumentException>()) { 'z' downTo 'a' step 0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0 downTo -5.0 step 0.0 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0f downTo -5.0f step 0.0f }
assertFailsWithIllegalArgument { 0 downTo -5 step 0 }
assertFailsWithIllegalArgument { 0.toByte() downTo -5.toByte() step 0 }
assertFailsWithIllegalArgument { 0.toShort() downTo -5.toShort() step 0 }
assertFailsWithIllegalArgument { 0L downTo -5L step 0L }
assertFailsWithIllegalArgument { 'z' downTo 'a' step 0 }
assertFailsWithIllegalArgument { 0.0 downTo -5.0 step 0.0 }
assertFailsWithIllegalArgument { 0.0f downTo -5.0f step 0.0f }
failsWith(javaClass<IllegalArgumentException>()) { 0..5 step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toByte()..5.toByte() step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toShort()..5.toShort() step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0L..5L step -2L }
failsWith(javaClass<IllegalArgumentException>()) { 'a'..'z' step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0..5.0 step -0.5 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0f..5.0f step -0.5f }
assertFailsWithIllegalArgument { 0..5 step -2 }
assertFailsWithIllegalArgument { 0.toByte()..5.toByte() step -2 }
assertFailsWithIllegalArgument { 0.toShort()..5.toShort() step -2 }
assertFailsWithIllegalArgument { 0L..5L step -2L }
assertFailsWithIllegalArgument { 'a'..'z' step -2 }
assertFailsWithIllegalArgument { 0.0..5.0 step -0.5 }
assertFailsWithIllegalArgument { 0.0f..5.0f step -0.5f }
failsWith(javaClass<IllegalArgumentException>()) { 0 downTo -5 step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toByte() downTo -5.toByte() step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0.toShort() downTo -5.toShort() step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0L downTo -5L step -2L }
failsWith(javaClass<IllegalArgumentException>()) { 'z' downTo 'a' step -2 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0 downTo -5.0 step -0.5 }
failsWith(javaClass<IllegalArgumentException>()) { 0.0f downTo -5.0f step -0.5f }
assertFailsWithIllegalArgument { 0 downTo -5 step -2 }
assertFailsWithIllegalArgument { 0.toByte() downTo -5.toByte() step -2 }
assertFailsWithIllegalArgument { 0.toShort() downTo -5.toShort() step -2 }
assertFailsWithIllegalArgument { 0L downTo -5L step -2L }
assertFailsWithIllegalArgument { 'z' downTo 'a' step -2 }
assertFailsWithIllegalArgument { 0.0 downTo -5.0 step -0.5 }
assertFailsWithIllegalArgument { 0.0f downTo -5.0f step -0.5f }
// NaN increment or step
failsWith(javaClass<IllegalArgumentException>()) { DoubleProgression(0.0, 5.0, jDouble.NaN) }
failsWith(javaClass<IllegalArgumentException>()) { FloatProgression(0.0f, 5.0f, jFloat.NaN) }
assertFailsWithIllegalArgument { DoubleProgression(0.0, 5.0, jDouble.NaN) }
assertFailsWithIllegalArgument { FloatProgression(0.0f, 5.0f, jFloat.NaN) }
failsWith(javaClass<IllegalArgumentException>()) { 0.0..5.0 step jDouble.NaN }
failsWith(javaClass<IllegalArgumentException>()) { 0.0f..5.0f step jFloat.NaN }
assertFailsWithIllegalArgument { 0.0..5.0 step jDouble.NaN }
assertFailsWithIllegalArgument { 0.0f..5.0f step jFloat.NaN }
failsWith(javaClass<IllegalArgumentException>()) { 5.0 downTo 0.0 step jDouble.NaN }
failsWith(javaClass<IllegalArgumentException>()) { 5.0f downTo 0.0f step jFloat.NaN }
assertFailsWithIllegalArgument { 5.0 downTo 0.0 step jDouble.NaN }
assertFailsWithIllegalArgument { 5.0f downTo 0.0f step jFloat.NaN }
}
}
+2 -2
View File
@@ -213,7 +213,7 @@ class StringJVMTest {
// get the smallest character(by char value)
assertEquals('a', "bacfd".reduce { v, c -> if (v > c) c else v })
failsWith(javaClass<UnsupportedOperationException>()) {
assertFailsWith(UnsupportedOperationException::class) {
"".reduce { a, b -> '\n' }
}
}
@@ -222,7 +222,7 @@ class StringJVMTest {
// get the smallest character(by char value)
assertEquals('a', "bacfd".reduceRight { c, v -> if (v > c) c else v })
failsWith(javaClass<UnsupportedOperationException>()) {
assertFailsWith(UnsupportedOperationException::class) {
"".reduceRight { a, b -> '\n' }
}
}