@@ -107,7 +107,7 @@ fun assertAll(vararg executables: () -> Unit) = assertAll(executables.toList().s
107
107
fun assertAll (
108
108
heading : String? ,
109
109
vararg executables : () -> Unit
110
- ) = assertAll(heading, executables.toList().stream() )
110
+ ) = assertAll(heading, executables.toList())
111
111
112
112
/* *
113
113
* Example usage:
@@ -267,7 +267,11 @@ fun assertNotNull(
267
267
* ```
268
268
* @see Assertions.assertThrows
269
269
*/
270
+ @OptIn(ExperimentalContracts ::class )
270
271
inline fun <reified T : Throwable > assertThrows (executable : () -> Unit ): T {
272
+ contract {
273
+ callsInPlace(executable, EXACTLY_ONCE )
274
+ }
271
275
val throwable: Throwable ? =
272
276
try {
273
277
executable()
@@ -394,8 +398,8 @@ inline fun <R> assertDoesNotThrow(
394
398
executable : () -> R
395
399
): R {
396
400
contract {
397
- callsInPlace(executable, EXACTLY_ONCE )
398
401
callsInPlace(message, AT_MOST_ONCE )
402
+ callsInPlace(executable, EXACTLY_ONCE )
399
403
}
400
404
401
405
return Assertions .assertDoesNotThrow(
@@ -478,8 +482,8 @@ fun <R> assertTimeout(
478
482
executable : () -> R
479
483
): R {
480
484
contract {
481
- callsInPlace(executable, EXACTLY_ONCE )
482
485
callsInPlace(message, AT_MOST_ONCE )
486
+ callsInPlace(executable, EXACTLY_ONCE )
483
487
}
484
488
485
489
return Assertions .assertTimeout(timeout, executable, message)
@@ -495,11 +499,17 @@ fun <R> assertTimeout(
495
499
* @see Assertions.assertTimeoutPreemptively
496
500
* @param R the result of the [executable].
497
501
*/
502
+ @OptIn(ExperimentalContracts ::class )
498
503
@API(status = STABLE , since = " 5.11" )
499
504
fun <R > assertTimeoutPreemptively (
500
505
timeout : Duration ,
501
506
executable : () -> R
502
- ): R = Assertions .assertTimeoutPreemptively(timeout, executable)
507
+ ): R {
508
+ contract {
509
+ callsInPlace(executable, EXACTLY_ONCE )
510
+ }
511
+ return Assertions .assertTimeoutPreemptively(timeout, executable)
512
+ }
503
513
504
514
/* *
505
515
* Example usage:
@@ -511,12 +521,18 @@ fun <R> assertTimeoutPreemptively(
511
521
* @see Assertions.assertTimeoutPreemptively
512
522
* @param R the result of the [executable].
513
523
*/
524
+ @OptIn(ExperimentalContracts ::class )
514
525
@API(status = STABLE , since = " 5.11" )
515
526
fun <R > assertTimeoutPreemptively (
516
527
timeout : Duration ,
517
528
message : String ,
518
529
executable : () -> R
519
- ): R = Assertions .assertTimeoutPreemptively(timeout, executable, message)
530
+ ): R {
531
+ contract {
532
+ callsInPlace(executable, EXACTLY_ONCE )
533
+ }
534
+ return Assertions .assertTimeoutPreemptively(timeout, executable, message)
535
+ }
520
536
521
537
/* *
522
538
* Example usage:
@@ -537,6 +553,7 @@ fun <R> assertTimeoutPreemptively(
537
553
): R {
538
554
contract {
539
555
callsInPlace(message, AT_MOST_ONCE )
556
+ callsInPlace(executable, EXACTLY_ONCE )
540
557
}
541
558
542
559
return Assertions .assertTimeoutPreemptively(timeout, executable, message)
0 commit comments