mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user