From 270449dbf4cd2167fe08e766aab68501c9ad7a85 Mon Sep 17 00:00:00 2001 From: Eva Tatarka Date: Tue, 5 Dec 2023 13:12:22 -0800 Subject: [PATCH] make assume inline, add additional tests --- assertk/src/jvmMain/kotlin/assertk/assume.kt | 2 +- .../kotlin/test/assertk/assertions/AssumeTest.kt | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/assertk/src/jvmMain/kotlin/assertk/assume.kt b/assertk/src/jvmMain/kotlin/assertk/assume.kt index 6f2ef94b..9cfd52cb 100644 --- a/assertk/src/jvmMain/kotlin/assertk/assume.kt +++ b/assertk/src/jvmMain/kotlin/assertk/assume.kt @@ -10,6 +10,6 @@ package assertk * } * ``` */ -fun assume(f: () -> Unit) { +inline fun assume(f: () -> Unit) { AssumptionFailure.run { f() } } \ No newline at end of file diff --git a/assertk/src/jvmTest/kotlin/test/assertk/assertions/AssumeTest.kt b/assertk/src/jvmTest/kotlin/test/assertk/assertions/AssumeTest.kt index 4468c5cd..2acf64c7 100644 --- a/assertk/src/jvmTest/kotlin/test/assertk/assertions/AssumeTest.kt +++ b/assertk/src/jvmTest/kotlin/test/assertk/assertions/AssumeTest.kt @@ -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 @@ -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 { + assume { throw NullPointerException() } + } + } + + @Test + fun assume_aborts_when_suspend() = runTest { + assume { assertThat(suspend { true }()).isFalse() } + } } \ No newline at end of file