remove TODO on getImpl to replace it with components.

getImpl will be used in the future to create ProofFactory related types.
We will most likely rename it but it has a different purpose than
components. I think it will be much less likely that components are
actually exchanged where a user needs to define an own assertion verb to
do so. On the other hand, I could imagine that one wants to provide
an own implementation for a ProofFactory, e.g. to override one
particular expectation function, where with getImpl one is decoupled
from the assertion verb and instead provides an extension function
on the logic level.
This commit is contained in:
Robert Stoll
2021-03-29 22:26:18 +02:00
parent 9dbe73ae61
commit 99aef715d0
4 changed files with 13 additions and 15 deletions

View File

@@ -26,9 +26,11 @@ interface AssertionContainer<T> : @kotlin.Suppress("DEPRECATION") SubjectProvide
override val maybeSubject: Option<T>
/**
* Do not use yet, this is experimental
* Do not use yet, this is experimental and will definitely change in 0.17.0 or 0.18.0.
*
* Might be we completely remove it without prior notice.
*/
//TODO 0.16.0 replace by components?
//TODO 0.17.0/0.18.0 maybe it would be better to have proofFactories as val like we have components?
@ExperimentalNewExpectTypes
fun <I : Any> getImpl(kClass: KClass<I>, defaultFactory: () -> I): I

View File

@@ -17,7 +17,8 @@ abstract class BaseExpectImpl<T>(
override val maybeSubject: Option<T>
) : ExpectInternal<T> {
// TODO 0.16.0 not every expect should have an own implFactories but only the root,
// TODO 0.17.0 not every expect should have an own implFactories but only the root,
// maybe also FeatureExpect but surely not DelegatingExpect or CollectingExpect
private val implFactories: MutableMap<KClass<*>, (() -> Nothing) -> () -> Any> = mutableMapOf()
@@ -35,7 +36,7 @@ abstract class BaseExpectImpl<T>(
implFactories[kClass] = implFactory
}
//TODO 0.16.0 move to ExpectOptions
//TODO 0.17.0 move to RootExpectOptions?
inline fun <reified I : Any> withImplFactory(noinline implFactory: (oldFactory: () -> I) -> () -> I) {
registerImpl(I::class, implFactory)
}

View File

@@ -75,7 +75,6 @@ internal abstract class ComponentFactoryContainerImpl : ComponentFactoryContaine
private val redefiningFactoryContainer: ComponentFactoryContainer
) : ComponentFactoryContainerImpl() {
override fun getFactoryOrNull(kClass: KClass<*>): ComponentFactory? =
redefiningFactoryContainer.getFactoryOrNull(kClass) ?: previousFactoryContainer.getFactoryOrNull(kClass)

View File

@@ -14,11 +14,9 @@ fun <T : CharSequence> atLeastChecker(
times: Int,
nameContainsNotFun: String,
atLeastCall: (Int) -> String
): AtLeastChecker =
//TODO 0.16.0 use components.build instead?
container.getImpl(AtLeastChecker::class) {
DefaultAtLeastChecker(times, nameContainsNotFun, atLeastCall)
}
): AtLeastChecker = container.getImpl(AtLeastChecker::class) {
DefaultAtLeastChecker(times, nameContainsNotFun, atLeastCall)
}
@Suppress( /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2*/ "DEPRECATION")
@UseExperimental(ExperimentalNewExpectTypes::class)
@@ -27,8 +25,6 @@ fun <T : CharSequence> atMostChecker(
times: Int,
nameContainsNotFun: String,
atMostCall: (Int) -> String
): AtMostChecker =
container.getImpl(AtMostChecker::class) {
DefaultAtMostChecker(times, nameContainsNotFun, atMostCall)
}
): AtMostChecker = container.getImpl(AtMostChecker::class) {
DefaultAtMostChecker(times, nameContainsNotFun, atMostCall)
}