@@ -114,6 +114,7 @@ internal fun AdventSpec<*>.definePart(
114114 * @param examples A configuration block defining the example values.
115115 */
116116@OptIn(ExperimentalKotest ::class )
117+ @Suppress(" SuspendFunWithCoroutineScopeReceiver" )
117118private suspend fun FunSpecContainerScope.defineExamples (
118119 config : AdventSpecConfig ,
119120 partFunction : (String ) -> Any ,
@@ -148,6 +149,7 @@ private suspend fun FunSpecContainerScope.defineExamples(
148149 * @param correctAnswer The actual puzzle solution, if known.
149150 */
150151@OptIn(ExperimentalKotest ::class )
152+ @Suppress(" SuspendFunWithCoroutineScopeReceiver" )
151153private suspend fun FunSpecContainerScope.defineInput (
152154 config : AdventSpecConfig ,
153155 expensive : Boolean ,
@@ -156,11 +158,11 @@ private suspend fun FunSpecContainerScope.defineInput(
156158 correctAnswer : PuzzleAnswer ? ,
157159) {
158160 context(" The solution" ).config(enabled = config.executionMode != ExecMode .ExamplesOnly ) {
159- val solutionKnown = correctAnswer != null
161+ val isSolutionKnown = correctAnswer != null
160162 var answer: PuzzleAnswer ? = null
161163 var duration: Duration ? = null
162164
163- test(name = if (solutionKnown ) " Is correct" else " Computes an answer" ) {
165+ test(name = if (isSolutionKnown ) " Is correct" else " Computes an answer" ) {
164166 runCatching {
165167 val (value, time) = measureTimedValue { partFunction(input.toString()) }
166168 answer = PuzzleAnswer (value.toString())
@@ -172,15 +174,15 @@ private suspend fun FunSpecContainerScope.defineInput(
172174 .build()
173175 }
174176
175- if (solutionKnown ) {
177+ if (isSolutionKnown ) {
176178 withClue(" Got different answer than the known solution." ) {
177179 answer shouldBe correctAnswer
178180 }
179181 }
180182 }
181183
182184 // If solution is unverified, create a dummy ignored test to display the value in the test report.
183- if (! solutionKnown && answer != null ) {
185+ if (! isSolutionKnown && answer != null ) {
184186 xtest(" Has unverified answer ($answer )" ) {}
185187 }
186188
@@ -192,7 +194,7 @@ private suspend fun FunSpecContainerScope.defineInput(
192194 }
193195
194196 val benchmark = config.efficiencyBenchmark
195- val durationSuffix = if ( answer != null ) duration .toString() else " N/A"
197+ val durationSuffix = duration?. takeIf { answer != null }? .toString() ? : " N/A"
196198 test(" Is reasonably efficient ($durationSuffix )" ).config(enabled = enableSpeedTesting) {
197199 withClue(" The solution did not complete under the configured benchmark of $benchmark " ) {
198200 @Suppress(" UnsafeCallOnNullableType" )
0 commit comments