Skip to content

Commit ed02ba8

Browse files
committed
Add contract for fail
Created another fail method with a non-nullable lambda parameter Issue: #1866
1 parent e3900cf commit ed02ba8

File tree

1 file changed

+12
-0
lines changed
  • junit-jupiter-api/src/main/kotlin/org/junit/jupiter/api

1 file changed

+12
-0
lines changed

Diff for: junit-jupiter-api/src/main/kotlin/org/junit/jupiter/api/Assertions.kt

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ import kotlin.contracts.contract
2929
fun fail(message: String?, throwable: Throwable? = null): Nothing =
3030
Assertions.fail<Nothing>(message, throwable)
3131

32+
/**
33+
* @see Assertions.fail
34+
*/
35+
@JvmName("fail_nonNullableLambda")
36+
fun fail(message: () -> String): Nothing {
37+
contract {
38+
callsInPlace(message)
39+
}
40+
41+
return Assertions.fail<Nothing>(message)
42+
}
43+
3244
/**
3345
* @see Assertions.fail
3446
*/

0 commit comments

Comments
 (0)