PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: willowtreeapps/assertk (kotlin)
Issue: assertFailure isn't inline
We have several usages of `assertThat { ... }` that test suspending functions. This works well with `assertThat` since it's inline but the new replacement, `assertFailure`, is not inlined so it cannot be used to test suspending functions.
Pull request description: This change makes `assertFailure` inline so it can be used to test suspending functions.

This fixes #471

Patch:
diff --git a/assertk/build.gradle.kts b/assertk/build.gradle.kts
index 26382a12..15794a29 100644
--- a/assertk/build.gradle.kts
+++ b/assertk/build.gradle.kts
@@ -29,6 +29,7 @@ kotlin {
             dependencies {
                 implementation(kotlin("test"))
                 implementation(libs.kotlinx.coroutines)
+                implementation(libs.kotlinx.coroutines.test)
             }
             kotlin.srcDir(compileTestTemplates)
         }
diff --git a/assertk/src/commonMain/kotlin/assertk/assert.kt b/assertk/src/commonMain/kotlin/assertk/assert.kt
index a09b0f04..354dc427 100644
--- a/assertk/src/commonMain/kotlin/assertk/assert.kt
+++ b/assertk/src/commonMain/kotlin/assertk/assert.kt
@@ -200,7 +200,7 @@ inline fun assertAll(f: () -> Unit) {
 /**
  * Asserts that the given block will throw an exception rather than complete successfully.
  */
-fun assertFailure(f: () -> Unit): Assert<Throwable> {
+inline fun assertFailure(f: () -> Unit): Assert<Throwable> {
     @Suppress("TooGenericExceptionCaught") // Intentionally capturing all exceptions.
     try {
         f()


Test patch:
diff --git a/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt b/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt
index cdb7a4ee..8bf0e6da 100644
--- a/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt
+++ b/assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt
@@ -2,9 +2,14 @@ package test.assertk
 
 import assertk.assertFailure
 import assertk.assertions.isEqualTo
+import assertk.assertions.isInstanceOf
 import assertk.assertions.message
 import com.willowtreeapps.opentest4k.AssertionFailedError
+import kotlinx.coroutines.test.runTest
 import test.assertk.assertions.valueOrFail
+import kotlin.coroutines.resume
+import kotlin.coroutines.resumeWithException
+import kotlin.coroutines.suspendCoroutine
 import kotlin.test.Test
 import kotlin.test.assertEquals
 import kotlin.test.assertFailsWith
@@ -35,4 +40,22 @@ class AssertFailureTest {
         }
         assertEquals("expected failure but lambda completed successfully", t.message)
     }
+
+    @Test
+    fun suspending_functions_can_succeed() = runTest {
+        val t = assertFailsWith<AssertionFailedError> {
+            assertFailure {
+                suspendCoroutine { it.resume(Unit) }
+            }
+        }
+        assertEquals("expected failure but lambda completed successfully", t.message)
+    }
+
+    @Test
+    fun suspending_functions_fail() = runTest {
+        val t = assertFailure {
+            suspendCoroutine { it.resumeWithException(IllegalArgumentException()) }
+        }
+        t.isInstanceOf<IllegalArgumentException>()
+    }
 }