diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 148fdd24..d4b7accb 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/libraries/action-async/src/commonMain/kotlin/com/zegreatrob/testmints/action/ActionCannon.kt b/libraries/action-async/src/commonMain/kotlin/com/zegreatrob/testmints/action/ActionCannon.kt
index b843edb2..813583d7 100644
--- a/libraries/action-async/src/commonMain/kotlin/com/zegreatrob/testmints/action/ActionCannon.kt
+++ b/libraries/action-async/src/commonMain/kotlin/com/zegreatrob/testmints/action/ActionCannon.kt
@@ -6,8 +6,7 @@ interface ActionCannon {
suspend fun fire(action: SuspendAction): R
companion object {
- operator fun invoke(dispatcher: D, pipe: ActionPipe = ActionPipe): ActionCannon =
- DispatcherPipeCannon(dispatcher, pipe)
+ operator fun invoke(dispatcher: D, pipe: ActionPipe = ActionPipe): ActionCannon = DispatcherPipeCannon(dispatcher, pipe)
}
}
diff --git a/libraries/action-async/src/commonTest/kotlin/com/zegreatrob/testmints/action/async/GeneralSuspendActionDispatcherTest.kt b/libraries/action-async/src/commonTest/kotlin/com/zegreatrob/testmints/action/async/GeneralSuspendActionDispatcherTest.kt
index 33155bfa..bf028494 100644
--- a/libraries/action-async/src/commonTest/kotlin/com/zegreatrob/testmints/action/async/GeneralSuspendActionDispatcherTest.kt
+++ b/libraries/action-async/src/commonTest/kotlin/com/zegreatrob/testmints/action/async/GeneralSuspendActionDispatcherTest.kt
@@ -16,28 +16,26 @@ class GeneralSuspendActionDispatcherTest {
}
@Test
- fun syntaxAllowsInterceptionOfActionExecutionIncludingReplacingResult() =
- asyncSetup(object : GeneralSuspendActionDispatcherSyntax {
- val expectedReplacedResult = 127
- override val generalDispatcher = generalDispatcherSpy().apply { spyWillReturn(expectedReplacedResult) }
- val action = DivideAction(6, 7)
- val divideDispatcherSpy = SpyData()
- val divideDispatcher: DivideActionDispatcher = { divideDispatcherSpy.spyFunction(it) }
- }) exercise {
- divideDispatcher.execute(action)
- } verify { result ->
- result.assertIsEqualTo(expectedReplacedResult)
- generalDispatcher.spyReceivedValues
- .assertIsEqualTo(listOf(action to divideDispatcher))
- divideDispatcherSpy.spyReceivedValues
- .assertIsEqualTo(emptyList())
- }
+ fun syntaxAllowsInterceptionOfActionExecutionIncludingReplacingResult() = asyncSetup(object : GeneralSuspendActionDispatcherSyntax {
+ val expectedReplacedResult = 127
+ override val generalDispatcher = generalDispatcherSpy().apply { spyWillReturn(expectedReplacedResult) }
+ val action = DivideAction(6, 7)
+ val divideDispatcherSpy = SpyData()
+ val divideDispatcher: DivideActionDispatcher = { divideDispatcherSpy.spyFunction(it) }
+ }) exercise {
+ divideDispatcher.execute(action)
+ } verify { result ->
+ result.assertIsEqualTo(expectedReplacedResult)
+ generalDispatcher.spyReceivedValues
+ .assertIsEqualTo(listOf(action to divideDispatcher))
+ divideDispatcherSpy.spyReceivedValues
+ .assertIsEqualTo(emptyList())
+ }
private fun generalDispatcherSpy() = object :
GeneralSuspendActionDispatcher,
Spy, *>, Any> by SpyData() {
@Suppress("UNCHECKED_CAST")
- override suspend fun dispatch(action: SuspendAction, dispatcher: D): R =
- spyFunction(action to dispatcher) as R
+ override suspend fun dispatch(action: SuspendAction, dispatcher: D): R = spyFunction(action to dispatcher) as R
}
}
diff --git a/libraries/action/src/commonTest/kotlin/com/zegreatrob/testmints/action/GeneralExecutableActionDispatcherTest.kt b/libraries/action/src/commonTest/kotlin/com/zegreatrob/testmints/action/GeneralExecutableActionDispatcherTest.kt
index cacb04ec..a18573cc 100644
--- a/libraries/action/src/commonTest/kotlin/com/zegreatrob/testmints/action/GeneralExecutableActionDispatcherTest.kt
+++ b/libraries/action/src/commonTest/kotlin/com/zegreatrob/testmints/action/GeneralExecutableActionDispatcherTest.kt
@@ -38,7 +38,6 @@ class GeneralExecutableActionDispatcherTest {
GeneralExecutableActionDispatcher,
Spy, *>, Any> by SpyData() {
@Suppress("UNCHECKED_CAST")
- override fun dispatch(action: ExecutableAction, dispatcher: D): R =
- spyFunction(action to dispatcher) as R
+ override fun dispatch(action: ExecutableAction, dispatcher: D): R = spyFunction(action to dispatcher) as R
}
}
diff --git a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/AsyncMintDispatcher.kt b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/AsyncMintDispatcher.kt
index 87f59928..be0b1447 100644
--- a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/AsyncMintDispatcher.kt
+++ b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/AsyncMintDispatcher.kt
@@ -45,19 +45,16 @@ internal fun Any.chooseTestScope() = if (this is ScopeMint) testScope else mintS
val asyncSetup: TestTemplate get() = AsyncMints.asyncSetup
-fun asyncTestTemplate(sharedSetup: suspend () -> SC, sharedTeardown: suspend (SC) -> Unit = {}) =
- AsyncMints.asyncTestTemplate(sharedSetup, sharedTeardown)
+fun asyncTestTemplate(sharedSetup: suspend () -> SC, sharedTeardown: suspend (SC) -> Unit = {}) = AsyncMints.asyncTestTemplate(sharedSetup, sharedTeardown)
fun asyncTestTemplate(beforeAll: suspend () -> SC) = AsyncMints.asyncTestTemplate(beforeAll = beforeAll)
-fun asyncTestTemplate(sharedSetup: suspend () -> Unit, sharedTeardown: suspend () -> Unit) =
- AsyncMints.asyncTestTemplate(sharedSetup) { sharedTeardown() }
+fun asyncTestTemplate(sharedSetup: suspend () -> Unit, sharedTeardown: suspend () -> Unit) = AsyncMints.asyncTestTemplate(sharedSetup) { sharedTeardown() }
@JvmName("asyncTestTemplateSimple")
fun asyncTestTemplate(wrapper: suspend (suspend () -> Unit) -> Unit) = AsyncMints.asyncTestTemplateSimple(wrapper)
@JvmName("asyncTestTemplateSC")
-fun asyncTestTemplate(wrapper: suspend (TestFunc) -> Unit) =
- AsyncMints.asyncTestTemplate(wrapper)
+fun asyncTestTemplate(wrapper: suspend (TestFunc) -> Unit) = AsyncMints.asyncTestTemplate(wrapper)
object AsyncMints : AsyncMintDispatcher, ReporterProvider by MintReporterConfig
diff --git a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/ExerciseAsync.kt b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/ExerciseAsync.kt
index f6c7d116..1fb1d149 100644
--- a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/ExerciseAsync.kt
+++ b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/ExerciseAsync.kt
@@ -2,6 +2,5 @@ package com.zegreatrob.testmints.async
class ExerciseAsync(private val context: C, private val result: R) {
@Suppress("unused")
- suspend infix fun verifyAsync(assertionFunctions: suspend C.(R) -> R2) =
- context.assertionFunctions(result)
+ suspend infix fun verifyAsync(assertionFunctions: suspend C.(R) -> R2) = context.assertionFunctions(result)
}
diff --git a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/Setup.kt b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/Setup.kt
index 79266070..0946af47 100644
--- a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/Setup.kt
+++ b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/Setup.kt
@@ -81,13 +81,12 @@ class Setup(
return context
}
- private suspend fun performExercise(context: C, exerciseFunc: suspend C.() -> R) =
- runCodeUnderTest(context, exerciseFunc)
- .also {
- if (context is ScopeMint) {
- waitForJobsToFinish(context.exerciseScope)
- }
+ private suspend fun performExercise(context: C, exerciseFunc: suspend C.() -> R) = runCodeUnderTest(context, exerciseFunc)
+ .also {
+ if (context is ScopeMint) {
+ waitForJobsToFinish(context.exerciseScope)
}
+ }
}
private fun Throwable.wrapCause() = CancellationException("Test failure.", this)
diff --git a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/SetupAsync.kt b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/SetupAsync.kt
index f39a8715..f3eb593b 100644
--- a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/SetupAsync.kt
+++ b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/SetupAsync.kt
@@ -2,6 +2,5 @@ package com.zegreatrob.testmints.async
class SetupAsync(private val context: C) {
@Suppress("unused")
- suspend infix fun exerciseAsync(codeUnderTest: suspend C.() -> R) =
- ExerciseAsync(context, context.codeUnderTest())
+ suspend infix fun exerciseAsync(codeUnderTest: suspend C.() -> R) = ExerciseAsync(context, context.codeUnderTest())
}
diff --git a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/TestTemplate.kt b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/TestTemplate.kt
index 5620f51a..f4b85c9b 100644
--- a/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/TestTemplate.kt
+++ b/libraries/async/src/commonMain/kotlin/com/zegreatrob/testmints/async/TestTemplate.kt
@@ -15,12 +15,11 @@ class TestTemplate(
this.wrapper { sc1 -> wrapper(sc1, test) }
}
- fun extend(sharedSetup: suspend (SC) -> SC2, sharedTeardown: suspend (SC2) -> Unit = {}) =
- extend { sc1, test ->
- val sc2 = sharedSetup(sc1)
- test(sc2)
- sharedTeardown(sc2)
- }
+ fun extend(sharedSetup: suspend (SC) -> SC2, sharedTeardown: suspend (SC2) -> Unit = {}) = extend { sc1, test ->
+ val sc2 = sharedSetup(sc1)
+ test(sc2)
+ sharedTeardown(sc2)
+ }
fun extend(sharedSetup: suspend () -> Unit = {}, sharedTeardown: suspend () -> Unit = {}) = TestTemplate(reporterProvider) { test ->
wrapper {
@@ -45,15 +44,14 @@ class TestTemplate(
})
}
- operator fun invoke(context: C, timeoutMs: Long = 60_000L, additionalActions: suspend C.() -> Unit = {}) =
- Setup(
- { context },
- context.chooseTestScope(),
- additionalActions,
- reporterProvider.reporter,
- timeoutMs,
- wrapper,
- )
+ operator fun invoke(context: C, timeoutMs: Long = 60_000L, additionalActions: suspend C.() -> Unit = {}) = Setup(
+ { context },
+ context.chooseTestScope(),
+ additionalActions,
+ reporterProvider.reporter,
+ timeoutMs,
+ wrapper,
+ )
operator fun invoke(timeoutMs: Long = 60_000L, additionalActions: suspend SC.() -> Unit = {}) = Setup(
{ it },
diff --git a/libraries/minassert/src/commonMain/kotlin/com/zegreatrob/minassert/Assertions.kt b/libraries/minassert/src/commonMain/kotlin/com/zegreatrob/minassert/Assertions.kt
index 72cc427c..2e4a4d0c 100644
--- a/libraries/minassert/src/commonMain/kotlin/com/zegreatrob/minassert/Assertions.kt
+++ b/libraries/minassert/src/commonMain/kotlin/com/zegreatrob/minassert/Assertions.kt
@@ -4,11 +4,9 @@ import com.zegreatrob.mindiff.stringDiff
import kotlin.test.assertEquals
import kotlin.test.assertTrue
-fun T?.assertIsEqualTo(expected: T, message: String? = null) =
- assertEquals(expected, this, message.appendDiff(expected, this))
+fun T?.assertIsEqualTo(expected: T, message: String? = null) = assertEquals(expected, this, message.appendDiff(expected, this))
-private fun String?.appendDiff(expected: T, t1: T?): String =
- "${this ?: ""}\n${stringDiff(expected.toString(), t1.toString())}\n"
+private fun String?.appendDiff(expected: T, t1: T?): String = "${this ?: ""}\n${stringDiff(expected.toString(), t1.toString())}\n"
fun T?.assertIsNotEqualTo(expected: T, message: String? = null) {
assertTrue("${if (message == null) "" else "$message. "}Two values were unexpectedly identical: $expected") {
diff --git a/libraries/mindiff/src/commonMain/kotlin/com/zegreatrob/mindiff/StringDiff.kt b/libraries/mindiff/src/commonMain/kotlin/com/zegreatrob/mindiff/StringDiff.kt
index ed673f7f..d68f68ac 100644
--- a/libraries/mindiff/src/commonMain/kotlin/com/zegreatrob/mindiff/StringDiff.kt
+++ b/libraries/mindiff/src/commonMain/kotlin/com/zegreatrob/mindiff/StringDiff.kt
@@ -60,9 +60,8 @@ private fun diffDescription(index: Int, eDiff: String, aDiff: String) = listOf(
"A: $aDiff",
)
-private fun String.diffRange(firstDiffIndex: Int, endOfString: Int) =
- (firstDiffIndex until endOfString).let {
- substring(it)
- }
+private fun String.diffRange(firstDiffIndex: Int, endOfString: Int) = (firstDiffIndex until endOfString).let {
+ substring(it)
+}
private fun String.firstDiffIndex() = indexOf("x")
diff --git a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/Setup.kt b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/Setup.kt
index 341f47d1..3c23951b 100644
--- a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/Setup.kt
+++ b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/Setup.kt
@@ -81,14 +81,13 @@ private fun exceptionDescriptionMap(
teardownException: Throwable?,
templateTeardownException: Throwable?,
failure: Throwable?,
-) =
- mapOf(
- "Failure" to failure,
- "Teardown exception" to teardownException,
- "Template teardown exception" to templateTeardownException,
- )
- .mapNotNull { (descriptor, exception) -> exception?.let { descriptor to exception } }
- .toMap()
+) = mapOf(
+ "Failure" to failure,
+ "Teardown exception" to teardownException,
+ "Template teardown exception" to templateTeardownException,
+)
+ .mapNotNull { (descriptor, exception) -> exception?.let { descriptor to exception } }
+ .toMap()
private fun checkedInvoke(wrapper: (TestFunc) -> Unit, test: TestFunc) = captureException {
var testWasInvoked = false
diff --git a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMintDispatcher.kt b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMintDispatcher.kt
index 543a5c8b..eeae71df 100644
--- a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMintDispatcher.kt
+++ b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMintDispatcher.kt
@@ -19,8 +19,7 @@ interface StandardMintDispatcher : ReporterProvider {
return testTemplate(wrapper = { it(lazy) })
}
- fun testTemplateSimple(wrapper: (() -> Unit) -> Unit): TestTemplate =
- testTemplate(wrapper = { wrapper { it(Unit) } })
+ fun testTemplateSimple(wrapper: (() -> Unit) -> Unit): TestTemplate = testTemplate(wrapper = { wrapper { it(Unit) } })
}
typealias ExerciseFunc = C.() -> R
diff --git a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMints.kt b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMints.kt
index d49b6798..995eee77 100644
--- a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMints.kt
+++ b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/StandardMints.kt
@@ -8,13 +8,11 @@ object StandardMints : StandardMintDispatcher, ReporterProvider by MintReporterC
val setup get() = StandardMints.setup
-fun testTemplate(sharedSetup: () -> SC, sharedTeardown: (SC) -> Unit = {}) =
- StandardMints.testTemplate(sharedSetup, sharedTeardown)
+fun testTemplate(sharedSetup: () -> SC, sharedTeardown: (SC) -> Unit = {}) = StandardMints.testTemplate(sharedSetup, sharedTeardown)
fun testTemplate(beforeAll: () -> SC) = StandardMints.testTemplate(beforeAll = beforeAll)
-fun testTemplate(sharedSetup: () -> Unit, sharedTeardown: () -> Unit) =
- StandardMints.testTemplate(sharedSetup, { sharedTeardown() })
+fun testTemplate(sharedSetup: () -> Unit, sharedTeardown: () -> Unit) = StandardMints.testTemplate(sharedSetup, { sharedTeardown() })
@JvmName("testTemplateSimple")
fun testTemplate(wrapper: SimpleWrapper) = StandardMints.testTemplateSimple(wrapper)
diff --git a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/TestTemplate.kt b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/TestTemplate.kt
index 70cc61fd..3fc282fd 100644
--- a/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/TestTemplate.kt
+++ b/libraries/standard/src/commonMain/kotlin/com/zegreatrob/testmints/TestTemplate.kt
@@ -34,14 +34,12 @@ class TestTemplate(val reporterProvider: ReporterProvider, val wrapper
return TestTemplate(reporterProvider) { test -> wrapper { sc -> test(mergeContext(sc, lazy)) } }
}
- operator fun invoke(contextProvider: (SC) -> C, additionalSetupActions: C.() -> Unit = {}) =
- Setup(contextProvider, reporterProvider.reporter, additionalSetupActions, wrapper)
+ operator fun invoke(contextProvider: (SC) -> C, additionalSetupActions: C.() -> Unit = {}) = Setup(contextProvider, reporterProvider.reporter, additionalSetupActions, wrapper)
operator fun invoke(
context: C,
additionalSetupActions: C.() -> Unit = {},
) = Setup({ context }, reporterProvider.reporter, additionalSetupActions, wrapper)
- operator fun invoke(additionalSetupActions: SC.() -> Unit = {}): Setup =
- Setup({ it }, reporterProvider.reporter, additionalSetupActions, wrapper)
+ operator fun invoke(additionalSetupActions: SC.() -> Unit = {}): Setup = Setup({ it }, reporterProvider.reporter, additionalSetupActions, wrapper)
}
diff --git a/plugins-test/mint-action-test/src/commonMain/kotlin/com/zegreatrob/testmints/action/MultiplyAction.kt b/plugins-test/mint-action-test/src/commonMain/kotlin/com/zegreatrob/testmints/action/MultiplyAction.kt
index 27d30d67..b8c8c63d 100644
--- a/plugins-test/mint-action-test/src/commonMain/kotlin/com/zegreatrob/testmints/action/MultiplyAction.kt
+++ b/plugins-test/mint-action-test/src/commonMain/kotlin/com/zegreatrob/testmints/action/MultiplyAction.kt
@@ -16,8 +16,7 @@ data class MultiplyAction(val left: Int, val right: Int) {
}
interface ExampleActionDispatcher : MultiplyAction.Dispatcher {
- override suspend fun handle(action: MultiplyAction): MultiplyAction.Result =
- MultiplyAction.Result.Success(action.left * action.right)
+ override suspend fun handle(action: MultiplyAction): MultiplyAction.Result = MultiplyAction.Result.Success(action.left * action.right)
}
@ActionMint
diff --git a/plugins-test/mint-action-test/src/commonTest/kotlin/com/zegreatrob/testmints/action/ActionMintTest.kt b/plugins-test/mint-action-test/src/commonTest/kotlin/com/zegreatrob/testmints/action/ActionMintTest.kt
index 8156d736..07aea130 100644
--- a/plugins-test/mint-action-test/src/commonTest/kotlin/com/zegreatrob/testmints/action/ActionMintTest.kt
+++ b/plugins-test/mint-action-test/src/commonTest/kotlin/com/zegreatrob/testmints/action/ActionMintTest.kt
@@ -130,9 +130,8 @@ class ActionMintTest : ActionPipe {
val allExecutedActions = mutableListOf()
val pipe = object : ActionPipe {
- override suspend fun execute(dispatcher: D, action: SuspendAction): R =
- action.execute(dispatcher)
- .also { allExecutedActions.add((action as? ActionWrapper<*, *>)?.action) }
+ override suspend fun execute(dispatcher: D, action: SuspendAction): R = action.execute(dispatcher)
+ .also { allExecutedActions.add((action as? ActionWrapper<*, *>)?.action) }
}
val cannon = ActionCannon(dispatcher, pipe)
}) exercise {
@@ -156,9 +155,8 @@ class ActionMintTest : ActionPipe {
val allExecutedActions = mutableListOf()
val pipe = object : ActionPipe {
- override suspend fun execute(dispatcher: D, action: SuspendAction): R =
- action.execute(dispatcher)
- .also { allExecutedActions.add((action as? ActionWrapper<*, *>)?.action) }
+ override suspend fun execute(dispatcher: D, action: SuspendAction): R = action.execute(dispatcher)
+ .also { allExecutedActions.add((action as? ActionWrapper<*, *>)?.action) }
}
val cannon = ActionCannon(dispatcher, pipe)
}) exercise {
@@ -177,9 +175,8 @@ class ActionMintTest : ActionPipe {
val allExecutedActions = mutableListOf()
val pipe = object : ActionPipe {
- override suspend fun execute(dispatcher: D, action: SuspendAction): R =
- action.execute(dispatcher)
- .also { allExecutedActions.add((action as? ActionWrapper<*, *>)?.action) }
+ override suspend fun execute(dispatcher: D, action: SuspendAction): R = action.execute(dispatcher)
+ .also { allExecutedActions.add((action as? ActionWrapper<*, *>)?.action) }
}
val cannon = ActionCannon(dispatcher, pipe)
}) exercise {