@@ -268,6 +268,8 @@ fun assertNotNull(
268
268
* @see Assertions.assertThrows
269
269
*/
270
270
inline fun <reified T : Throwable > assertThrows (executable : () -> Unit ): T {
271
+ // no contract for `executable` because it is expected to throw an exception instead
272
+ // of being executed completely (see https://youtrack.jetbrains.com/issue/KT-27748)
271
273
val throwable: Throwable ? =
272
274
try {
273
275
executable()
@@ -314,6 +316,8 @@ inline fun <reified T : Throwable> assertThrows(
314
316
): T {
315
317
contract {
316
318
callsInPlace(message, AT_MOST_ONCE )
319
+ // no contract for `executable` because it is expected to throw an exception instead
320
+ // of being executed completely (see https://youtrack.jetbrains.com/issue/KT-27748)
317
321
}
318
322
319
323
val throwable: Throwable ? =
@@ -499,7 +503,10 @@ fun <R> assertTimeout(
499
503
fun <R > assertTimeoutPreemptively (
500
504
timeout : Duration ,
501
505
executable : () -> R
502
- ): R = Assertions .assertTimeoutPreemptively(timeout, executable)
506
+ ): R =
507
+ // no contract for `executable` because it might be interrupted and throw an exception
508
+ // (see https://youtrack.jetbrains.com/issue/KT-27748)
509
+ Assertions .assertTimeoutPreemptively(timeout, executable)
503
510
504
511
/* *
505
512
* Example usage:
@@ -516,7 +523,10 @@ fun <R> assertTimeoutPreemptively(
516
523
timeout : Duration ,
517
524
message : String ,
518
525
executable : () -> R
519
- ): R = Assertions .assertTimeoutPreemptively(timeout, executable, message)
526
+ ): R =
527
+ // no contract for `executable` because it might be interrupted and throw an exception
528
+ // (see https://youtrack.jetbrains.com/issue/KT-27748)
529
+ Assertions .assertTimeoutPreemptively(timeout, executable, message)
520
530
521
531
/* *
522
532
* Example usage:
@@ -537,6 +547,8 @@ fun <R> assertTimeoutPreemptively(
537
547
): R {
538
548
contract {
539
549
callsInPlace(message, AT_MOST_ONCE )
550
+ // no contract for `executable` because it might be interrupted and throw an exception
551
+ // (see https://youtrack.jetbrains.com/issue/KT-27748)
540
552
}
541
553
542
554
return Assertions .assertTimeoutPreemptively(timeout, executable, message)
0 commit comments