From 99aef715d0db0a948801210c734b41c15114f243 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Mon, 29 Mar 2021 22:26:18 +0200 Subject: [PATCH] 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. --- .../atrium/creating/AssertionContainer.kt | 6 ++++-- .../atrium/creating/impl/BaseExpectImpl.kt | 5 +++-- .../impl/ComponentFactoryContainerImpl.kt | 1 - .../contains/steps/impl/sharedCheckers.kt | 16 ++++++---------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionContainer.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionContainer.kt index 2cf170eab..ec54ad019 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionContainer.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionContainer.kt @@ -26,9 +26,11 @@ interface AssertionContainer : @kotlin.Suppress("DEPRECATION") SubjectProvide override val maybeSubject: Option /** - * 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 getImpl(kClass: KClass, defaultFactory: () -> I): I diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt index ae20d7eeb..842770e33 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt @@ -17,7 +17,8 @@ abstract class BaseExpectImpl( override val maybeSubject: Option ) : ExpectInternal { - // 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, (() -> Nothing) -> () -> Any> = mutableMapOf() @@ -35,7 +36,7 @@ abstract class BaseExpectImpl( implFactories[kClass] = implFactory } - //TODO 0.16.0 move to ExpectOptions + //TODO 0.17.0 move to RootExpectOptions? inline fun withImplFactory(noinline implFactory: (oldFactory: () -> I) -> () -> I) { registerImpl(I::class, implFactory) } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/ComponentFactoryContainerImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/ComponentFactoryContainerImpl.kt index 718c4432b..5080ac620 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/ComponentFactoryContainerImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/ComponentFactoryContainerImpl.kt @@ -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) diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/charsequence/contains/steps/impl/sharedCheckers.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/charsequence/contains/steps/impl/sharedCheckers.kt index 63e1e5a50..ab6367ea3 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/charsequence/contains/steps/impl/sharedCheckers.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/charsequence/contains/steps/impl/sharedCheckers.kt @@ -14,11 +14,9 @@ fun 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 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) +}