mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
deprecate resultAssertions, use new ...Expectations in api-infix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.SuccessWithCreator
|
||||
import ch.tutteli.atrium.api.infix.en_GB.success
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic._logic
|
||||
import ch.tutteli.atrium.logic.kotlin_1_3.isFailureOfType
|
||||
@@ -15,7 +14,12 @@ import ch.tutteli.atrium.logic.kotlin_1_3.isSuccess
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
infix fun <E, T : Result<E>> Expect<T>.toBe(@Suppress("UNUSED_PARAMETER") success: success): Expect<E> =
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated(
|
||||
"Use toBe ASuccess; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toBe<E, T>(aSuccess)", "ch.tutteli.atrium.api.infix.en_GB.aSuccess")
|
||||
)
|
||||
infix fun <E, T : Result<E>> Expect<T>.toBe(@Suppress("UNUSED_PARAMETER") success: ch.tutteli.atrium.api.infix.en_GB.success): Expect<E> =
|
||||
_logic.isSuccess().transform()
|
||||
|
||||
//TODO move to resultExpectations with 0.18.0
|
||||
@@ -40,6 +44,7 @@ infix fun <E, T : Result<E>> Expect<T>.toBe(success: SuccessWithCreator<E>): Exp
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
@Deprecated("Use toBeAFailure; will be removed with 1.0.0 at the latest", ReplaceWith("this.toBeAFailure<TExpected>()"))
|
||||
inline fun <reified TExpected : Throwable> Expect<out Result<*>>.isFailure(): Expect<TExpected> =
|
||||
_logic.isFailureOfType(TExpected::class).transform()
|
||||
|
||||
@@ -52,6 +57,10 @@ inline fun <reified TExpected : Throwable> Expect<out Result<*>>.isFailure(): Ex
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
@Deprecated(
|
||||
"Use toBeAFailure; will be removed with 1.0.0 at the latest",
|
||||
ReplaceWith("this.toBeAFailure<TExpected>(assertionCreator)")
|
||||
)
|
||||
inline infix fun <reified TExpected : Throwable> Expect<out Result<*>>.isFailure(
|
||||
noinline assertionCreator: Expect<TExpected>.() -> Unit
|
||||
): Expect<TExpected> = _logic.isFailureOfType(TExpected::class).transformAndAppend(assertionCreator)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.aSuccess
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.SuccessWithCreator
|
||||
import ch.tutteli.atrium.api.infix.en_GB.success
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic._logic
|
||||
import ch.tutteli.atrium.logic.kotlin_1_3.isFailureOfType
|
||||
|
||||
@@ -45,23 +45,23 @@ class ResultExpectationsSpec : ResultExpectationsSpec(
|
||||
|
||||
var star: Expect<Result<*>> = notImplemented()
|
||||
|
||||
a1 toBe success
|
||||
a1 = a1 toBe success { }
|
||||
a1 toBe aSuccess
|
||||
a1 = a1 toBe aSuccess { }
|
||||
|
||||
a1.isFailure<IllegalArgumentException>()
|
||||
val r1: Expect<IllegalArgumentException> = a1.isFailure<IllegalArgumentException> { }
|
||||
a1.toBeAFailure<IllegalArgumentException>()
|
||||
val r1: Expect<IllegalArgumentException> = a1.toBeAFailure<IllegalArgumentException> { }
|
||||
|
||||
a1b toBe success
|
||||
a1b = a1b toBe success { }
|
||||
a1b toBe aSuccess
|
||||
a1b = a1b toBe aSuccess { }
|
||||
|
||||
a1b.isFailure<IllegalArgumentException>()
|
||||
val r1b: Expect<IllegalArgumentException> = a1b.isFailure<IllegalArgumentException> { }
|
||||
a1b.toBeAFailure<IllegalArgumentException>()
|
||||
val r1b: Expect<IllegalArgumentException> = a1b.toBeAFailure<IllegalArgumentException> { }
|
||||
|
||||
star toBe success
|
||||
star = star toBe success { }
|
||||
star toBe aSuccess
|
||||
star = star toBe aSuccess { }
|
||||
|
||||
star.isFailure<IllegalArgumentException>()
|
||||
val r3: Expect<IllegalArgumentException> = star.isFailure<IllegalArgumentException> { }
|
||||
star.toBeAFailure<IllegalArgumentException>()
|
||||
val r3: Expect<IllegalArgumentException> = star.toBeAFailure<IllegalArgumentException> { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package custom
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3.toBe
|
||||
import ch.tutteli.atrium.api.infix.en_GB.success
|
||||
import ch.tutteli.atrium.api.infix.en_GB.aSuccess
|
||||
import ch.tutteli.atrium.api.infix.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import ch.tutteli.atrium.assertions.Assertion
|
||||
@@ -26,7 +26,7 @@ object SmokeSpec : Spek({
|
||||
}
|
||||
|
||||
test("see if `Result.isSuccess` can be used") {
|
||||
expect(Result.success(1)) toBe success
|
||||
expect(Result.success(1)) toBe aSuccess
|
||||
}
|
||||
|
||||
test("see if own expectation function without i18n can be used") {
|
||||
|
||||
Reference in New Issue
Block a user