Skip to content

Commit

Permalink
make assume inline, add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evant committed Dec 5, 2023
1 parent e73f725 commit 270449d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assertk/src/jvmMain/kotlin/assertk/assume.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ package assertk
* }
* ```
*/
fun assume(f: () -> Unit) {
inline fun assume(f: () -> Unit) {
AssumptionFailure.run { f() }
}
15 changes: 15 additions & 0 deletions assertk/src/jvmTest/kotlin/test/assertk/assertions/AssumeTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package test.assertk.assertions

import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isTrue
import assertk.assume
import com.willowtreeapps.opentest4k.TestAbortedException
import test.assertk.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
Expand All @@ -25,4 +28,16 @@ class AssumeTest {
// this test should be skipped instead of failing
assume { assertThat(true).isFalse() }
}

@Test
fun assume_does_not_capture_unexpected_exceptions() {
assertFailsWith<NullPointerException> {
assume { throw NullPointerException() }
}
}

@Test
fun assume_aborts_when_suspend() = runTest {
assume { assertThat(suspend { true }()).isFalse() }
}
}

0 comments on commit 270449d

Please sign in to comment.