Skip to content

Commit

Permalink
WIP Extract configuration logic
Browse files Browse the repository at this point in the history
TODO
- Readme module.
- iterationFailures unused?
- remove check failure in next commit?
- check if PException was caught on next iteration
- configured shouldn't catch PException
- vanilla `parameterize` docs, and other configuration docs
- merge iterator -> state (vanilla & configured)

Improves performance of unconfigured parameterize, and greatly simplifies core logic
configuration may be dropped later
  • Loading branch information
BenWoodworth committed Oct 24, 2024
1 parent e5ddee7 commit 005fd86
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ internal class ConfiguredParameterizeState(
private var currentIterationScope: ConfiguredParameterizeScope? = null // Non-null if afterEach still needs to be called
private var decoratorCoroutine: DecoratorCoroutine? = null

var isFirstIteration: Boolean = true
private set
val isFirstIteration: Boolean
get() = iterationCount == 1L

/**
* Signals the start of a new [parameterize] iteration, and returns its scope if there is one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.benwoodworth.parameterize

import com.benwoodworth.parameterize.ParameterizeConfiguration.*
import com.benwoodworth.parameterize.test.parameterizeBlockExitTestCases
import com.benwoodworth.parameterize.test.configuredParameterizeExitingBlockEdgeCases
import com.benwoodworth.parameterize.test.testAll
import kotlin.coroutines.RestrictsSuspension
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
Expand Down Expand Up @@ -130,8 +130,8 @@ class ParameterizeConfigurationSpec_decorator {

@Test
fun iteration_function_should_return_regardless_of_how_parameterize_block_is_exited() = testAll(
parameterizeBlockExitTestCases
) { parameterizeWithBlockExit ->
configuredParameterizeExitingBlockEdgeCases
) { parameterizeExitingBlock ->
var returned = false

val configuration = ParameterizeConfiguration {
Expand All @@ -141,7 +141,7 @@ class ParameterizeConfigurationSpec_decorator {
}
}

parameterizeWithBlockExit(configuration)
parameterizeExitingBlock(configuration)

assertTrue(returned, "returned")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.benwoodworth.parameterize.*
/**
* Configured [parameterize] calls with blocks that exit different ways.
*/
val parameterizeBlockExitTestCases = listOf(
val configuredParameterizeExitingBlockEdgeCases = listOf(
"Return normally" to { configuration: ParameterizeConfiguration ->
parameterize(configuration) {}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.benwoodworth.parameterize

import com.benwoodworth.parameterize.test.EdgeCases
import com.benwoodworth.parameterize.test.parameterizeState
import com.benwoodworth.parameterize.test.probeThrow
import com.benwoodworth.parameterize.test.testAll
import kotlin.test.*
Expand Down
53 changes: 0 additions & 53 deletions parameterize-core/src/commonTest/kotlin/test/EdgeCases.kt

This file was deleted.

0 comments on commit 005fd86

Please sign in to comment.