Skip to content

Commit fbad7e3

Browse files
committed
Move extension helper.
1 parent d437ee6 commit fbad7e3

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

aockt-test/src/main/kotlin/internal/AdventSpecConfig.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package io.github.jadarma.aockt.test.internal
22

33
import io.github.jadarma.aockt.test.AdventSpec
4-
import io.github.jadarma.aockt.test.AocKtExtension
54
import io.github.jadarma.aockt.test.ExecMode
6-
import kotlinx.coroutines.currentCoroutineContext
75
import kotlin.coroutines.AbstractCoroutineContextElement
86
import kotlin.coroutines.CoroutineContext
97
import kotlin.time.Duration
@@ -44,18 +42,3 @@ internal data class AdventSpecConfig(
4442
)
4543
}
4644
}
47-
48-
/**
49-
* Retrieves the [AdventSpecConfig] for this spec from the test runner coroutine.
50-
* If an [AocKtExtension] has been registered, use the user-provided configuration.
51-
* Otherwise, returns the sane defaults.
52-
* Additionally, any non-null config parameters passed will be overridden in the final result.
53-
*/
54-
@Suppress("UnusedReceiverParameter")
55-
internal suspend fun AdventSpec<*>.configuration(
56-
efficiencyBenchmark: Duration?,
57-
executionMode: ExecMode?,
58-
): AdventSpecConfig =
59-
currentCoroutineContext()[AdventSpecConfig.Key]
60-
.run { this ?: AdventSpecConfig.Default }
61-
.override(efficiencyBenchmark, executionMode)

aockt-test/src/main/kotlin/internal/AdventSpecExt.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.github.jadarma.aockt.test.internal
33
import io.github.jadarma.aockt.core.Solution
44
import io.github.jadarma.aockt.test.AdventPartScope
55
import io.github.jadarma.aockt.test.AdventSpec
6+
import io.github.jadarma.aockt.test.AocKtExtension
67
import io.github.jadarma.aockt.test.ExecMode
78
import io.github.jadarma.aockt.test.Expensive
89
import io.kotest.assertions.AssertionErrorBuilder
@@ -13,6 +14,7 @@ import io.kotest.common.reflection.ReflectionInstantiations.newInstanceNoArgCons
1314
import io.kotest.core.spec.style.scopes.FunSpecContainerScope
1415
import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo
1516
import io.kotest.matchers.shouldBe
17+
import kotlinx.coroutines.currentCoroutineContext
1618
import kotlin.reflect.KClass
1719
import kotlin.reflect.full.isSubtypeOf
1820
import kotlin.reflect.full.starProjectedType
@@ -38,6 +40,21 @@ internal fun AdventSpec<*>.injectSolution(): Solution = this::class
3840
.getOrElse { throw MissingNoArgConstructorException(this) }
3941
}
4042

43+
/**
44+
* Retrieves the [AdventSpecConfig] for this spec from the test runner coroutine.
45+
* If an [AocKtExtension] has been registered, use the user-provided configuration.
46+
* Otherwise, returns the sane defaults.
47+
* Additionally, any non-null config parameters passed will be overridden in the final result.
48+
*/
49+
@Suppress("UnusedReceiverParameter")
50+
internal suspend fun AdventSpec<*>.configuration(
51+
efficiencyBenchmark: Duration?,
52+
executionMode: ExecMode?,
53+
): AdventSpecConfig =
54+
currentCoroutineContext()[AdventSpecConfig.Key]
55+
.run { this ?: AdventSpecConfig.Default }
56+
.override(efficiencyBenchmark, executionMode)
57+
4158
/**
4259
* Defines the rootContext to test the implementation of one [part] of a [Solution].
4360
*

0 commit comments

Comments
 (0)