@@ -114,6 +114,7 @@ internal fun AdventSpec<*>.definePart(
114
114
* @param examples A configuration block defining the example values.
115
115
*/
116
116
@OptIn(ExperimentalKotest ::class )
117
+ @Suppress(" SuspendFunWithCoroutineScopeReceiver" )
117
118
private suspend fun FunSpecContainerScope.defineExamples (
118
119
config : AdventSpecConfig ,
119
120
partFunction : (String ) -> Any ,
@@ -148,6 +149,7 @@ private suspend fun FunSpecContainerScope.defineExamples(
148
149
* @param correctAnswer The actual puzzle solution, if known.
149
150
*/
150
151
@OptIn(ExperimentalKotest ::class )
152
+ @Suppress(" SuspendFunWithCoroutineScopeReceiver" )
151
153
private suspend fun FunSpecContainerScope.defineInput (
152
154
config : AdventSpecConfig ,
153
155
expensive : Boolean ,
@@ -156,11 +158,11 @@ private suspend fun FunSpecContainerScope.defineInput(
156
158
correctAnswer : PuzzleAnswer ? ,
157
159
) {
158
160
context(" The solution" ).config(enabled = config.executionMode != ExecMode .ExamplesOnly ) {
159
- val solutionKnown = correctAnswer != null
161
+ val isSolutionKnown = correctAnswer != null
160
162
var answer: PuzzleAnswer ? = null
161
163
var duration: Duration ? = null
162
164
163
- test(name = if (solutionKnown ) " Is correct" else " Computes an answer" ) {
165
+ test(name = if (isSolutionKnown ) " Is correct" else " Computes an answer" ) {
164
166
runCatching {
165
167
val (value, time) = measureTimedValue { partFunction(input.toString()) }
166
168
answer = PuzzleAnswer (value.toString())
@@ -172,15 +174,15 @@ private suspend fun FunSpecContainerScope.defineInput(
172
174
.build()
173
175
}
174
176
175
- if (solutionKnown ) {
177
+ if (isSolutionKnown ) {
176
178
withClue(" Got different answer than the known solution." ) {
177
179
answer shouldBe correctAnswer
178
180
}
179
181
}
180
182
}
181
183
182
184
// 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 ) {
184
186
xtest(" Has unverified answer ($answer )" ) {}
185
187
}
186
188
@@ -192,7 +194,7 @@ private suspend fun FunSpecContainerScope.defineInput(
192
194
}
193
195
194
196
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"
196
198
test(" Is reasonably efficient ($durationSuffix )" ).config(enabled = enableSpeedTesting) {
197
199
withClue(" The solution did not complete under the configured benchmark of $benchmark " ) {
198
200
@Suppress(" UnsafeCallOnNullableType" )
0 commit comments