Skip to content

Commit

Permalink
resolve TODOs for 0.19.0 expect for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Dec 29, 2022
1 parent 780649d commit 65227ad
Show file tree
Hide file tree
Showing 54 changed files with 92 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package ch.tutteli.atrium.api.infix.en_GB

import ch.tutteli.atrium.api.verbs.internal.expect
//TODO 0.19.0 complains we are not in common module but we are. Check if error disappears once we use the default src folder
import kotlin.js.JsName

class WorstCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//TODO 0.19.0 rename package to proofWithHelpOnFailure when we rename DescriptiveAssertionWithFailureHint to ProofWithHelpOnFailure
//TODO 0.20.0 rename package to proofWithHelpOnFailure when we rename DescriptiveAssertionWithFailureHint to ProofWithHelpOnFailure
package ch.tutteli.atrium.assertions.builders.impl.descriptiveWithFailureHint

import ch.tutteli.atrium.assertions.Assertion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlin.reflect.KClass
*
* @param T The type of the subject of `this` expectation.
*/
//TODO 0.19.0 introduce ProofContainer
//TODO 0.20.0 introduce ProofContainer
interface AssertionContainer<T> {
/**
* Either [Some] wrapping the subject of an [Assertion] or [None] in case a previous subject transformation
Expand All @@ -32,8 +32,8 @@ interface AssertionContainer<T> {
*
* Might be we completely remove it without prior notice.
*/
//TODO 0.19.0/0.20.0 maybe it would be better to have proofFactories as val like we have components?
//TODO 0.19.0 I guess it would make sense to get rid of getImpl and only use the ComponentFactoryContainer approach
//TODO 0.20.0/0.21.0 maybe it would be better to have proofFactories as val like we have components?
//TODO 0.20.0 I guess it would make sense to get rid of getImpl and only use the ComponentFactoryContainer approach
// however, check if extensibility for a library author is still given. We don't want that a consumer of a third-party
// expectation function collection-library needs to use an own expectation verb
@ExperimentalNewExpectTypes
Expand Down Expand Up @@ -99,7 +99,7 @@ interface AssertionContainer<T> {
*
* @return an [Expect] for the subject of `this` expectation.
*/
//TODO remove SUPPRESS with 0.19.0 once the toExpect function is in core
//TODO remove SUPPRESS with 0.20.0 once the toExpect function is in core
@Suppress("UNCHECKED_CAST")
fun createAndAppend(description: Translatable, expected: Any?, test: (T) -> Boolean): Expect<T> =
append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,13 @@ import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
* Contains translations which are used in error like messages.
*/
enum class ErrorMessages(override val value: String) : StringBasedTranslatable {
@Deprecated(
"USE AT_LEAST_ONE_EXPECTATION_DEFINED, will be removed with 0.19.0",
ReplaceWith("AT_LEAST_ONE_EXPECTATION_DEFINED")
)
AT_LEAST_ONE_ASSERTION_DEFINED("at least one assertion defined"),

/** @since 0.18.0 */
AT_LEAST_ONE_EXPECTATION_DEFINED("at least one expectation defined"),

@Deprecated(
"USE FORGOT_DO_DEFINE_EXPECTATION, will be removed with 0.19.0",
ReplaceWith("FORGOT_DO_DEFINE_EXPECTATION")
)
FORGOT_DO_DEFINE_ASSERTION("You forgot to define assertions in the assertionCreator-lambda"),

/** @since 0.18.0 */
FORGOT_DO_DEFINE_EXPECTATION("You forgot to define expectations in the expectationCreator-lambda"),

@Deprecated(
"USE HINT_AT_LEAST_ONE_EXPECTATION_DEFINED, will be removed with 0.19.0",
ReplaceWith("HINT_AT_LEAST_ONE_EXPECTATION_DEFINED")
)
HINT_AT_LEAST_ONE_ASSERTION_DEFINED("Sometimes you can use an alternative to `{ }` For instance, instead of `toThrow<..> { }` you should use `toThrow<..>()`"),

/** @since 0.18.0 */
HINT_AT_LEAST_ONE_EXPECTATION_DEFINED("Sometimes you can use an alternative to `{ }` For instance, instead of `toThrow<..> { }` you should use `toThrow<..>()`"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class BaseExpectImpl<T>(
) : ExpectInternal<T> {


// TODO 0.19.0 not every expect should have an own implFactories but only the root,
// TODO 0.20.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()

Expand All @@ -36,7 +36,7 @@ abstract class BaseExpectImpl<T>(
implFactories[kClass] = implFactory
}

//TODO 0.19.0 move to RootExpectOptions?
//TODO 0.20.0 move to RootExpectOptions?
inline fun <reified I : Any> withImplFactory(noinline implFactory: (oldFactory: () -> I) -> () -> I) {
registerImpl(I::class, implFactory)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal class FeatureExpectImpl<T, R>(
}

override val components: ComponentFactoryContainer
// TODO 0.19.0 the function to turn an Expect into a ProofContainer should be located in core
// TODO 0.20.0 the function to turn an Expect into a ProofContainer should be located in core
get() = (previousExpect as AssertionContainer<*>).components

override fun append(assertion: Assertion): Expect<R> {
Expand Down
42 changes: 18 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import java.nio.file.Files
import java.nio.file.Paths
import java.util.stream.Collectors

buildscript {
rootProject.version = '0.19.0-SNAPSHOT'
Expand All @@ -18,8 +22,7 @@ buildscript {
junitPlatformVersion = '1.9.1'
jupiterVersion = '5.9.1'
spekVersion = '2.0.12'
//TODO 0.19.0 check if we can already update to kotestVersion = '4.6.4'
kotestVersion = '4.3.2'
kotestVersion = '4.6.4'
spekExtensionsVersion = '1.2.1'
spekExtensions = { "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensionsVersion" }
mockkVersion = '1.10.0'
Expand All @@ -35,8 +38,7 @@ buildscript {
// release
gradle_nexus_publish_plugin_version = '1.1.0'

//TODO 0.19.0 add all modules and remove this afterwards
newMultiplatformProjectNames = [
multiplatformProjectNames = [
"core",
"logic", "logic-kotlin_1_3",
"translations-en_GB", "translations-de_CH",
Expand Down Expand Up @@ -153,8 +155,8 @@ subprojects {



def newMultiplatformProjects = newMultiplatformProjectNames.collect { prefixedProject(it) }
configure(newMultiplatformProjects) { subproject ->
def multiplatformProjects = multiplatformProjectNames.collect { prefixedProject(it) }
configure(multiplatformProjects) { subproject ->
apply plugin: "kotlin-multiplatform"

kotlin {
Expand Down Expand Up @@ -247,14 +249,14 @@ configure(newMultiplatformProjects) { subproject ->
}
}

//TODO 0.19.0 update tutteli-gradle-plugins and remove as this is handled there
//TODO 0.20.0 update tutteli-gradle-plugins and remove as this is handled there
// calling the Kotlin extension function in buildSrc
ConfigureTestTasksKt.configureTestTasks(subproject)

sourceCompatibility = 11
targetCompatibility = 11

//TODO 0.19.0 update tutteli-gradle-plugins and remove as this is handled there and allows to use the normal java/ directory instead of module/
//TODO 0.20.0 update tutteli-gradle-plugins and remove as this is handled there and allows to use the normal java/ directory instead of module/
def moduleInfoReplaceMe = {
if (subproject.components.findByName('java') == null) throw new IllegalStateException("""\
Could not find the java component.
Expand Down Expand Up @@ -300,12 +302,10 @@ tasks.withType(KotlinCompile).configureEach {
}
}

//TODO 0.19.0 cleanup this file once we have transitioned all modules to the new MPP plugin

configure(subprojects.findAll {
def parentName = it.projectDir.parentFile.name
it.name != "bc-tests" && parentName != "old" && parentName != "bc-tests"
} - newMultiplatformProjects) { subproject ->
} - multiplatformProjects) { subproject ->
apply plugin: 'kotlin'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
Expand Down Expand Up @@ -345,8 +345,8 @@ configure(subprojects.findAll {
//}


//TODO 0.19.0 configure dokka plugins again also for newMultiplatformProjects
configure(subprojects - toolProjects - newMultiplatformProjects) { Project subproject ->
//TODO 0.19.0 configure dokka plugins again also for multiplatformProjects
configure(subprojects - toolProjects - multiplatformProjects) { Project subproject ->
apply plugin: 'ch.tutteli.dokka'
apply plugin: 'ch.tutteli.kotlin.module.info'

Expand Down Expand Up @@ -391,8 +391,8 @@ configure(apiProjects) { apiProject ->

def bundleSmokeTests = subprojects.findAll { it.name.contains('-smoke-test') }

//TODO 0.19.0 newMultiPlatformProject have to be published differently, update to tutteli-gradle-plugins
configure(subprojects - bundleSmokeTests - toolProjects - newMultiplatformProjects) { subproject ->
//TODO 0.19.0 multiplatformProjects have to be published differently, update to tutteli-gradle-plugins
configure(subprojects - bundleSmokeTests - toolProjects - multiplatformProjects) { subproject ->
apply plugin: 'ch.tutteli.publish'

tutteliPublish {
Expand All @@ -401,7 +401,7 @@ configure(subprojects - bundleSmokeTests - toolProjects - newMultiplatformProjec
}

//TODO 0.19.0 spek is used in another way, see above, but we have not yet applied the jacoco plugin
configure(jacocoMulti.jacocoProjects + getAndroidProjects() - newMultiplatformProjects) {
configure(jacocoMulti.jacocoProjects - multiplatformProjects) {
apply plugin: 'ch.tutteli.spek'
spek.version = spekVersion

Expand Down Expand Up @@ -438,8 +438,8 @@ configure(jacocoMulti.jacocoProjects + getAndroidProjects() - newMultiplatformPr
}


// this is already configured for newMultiplatformProjects further above, thus the substraction
configure(subprojects - toolProjects - newMultiplatformProjects) {
// this is already configured for multiplatformProjects further above, thus the substraction
configure(subprojects - toolProjects - multiplatformProjects) {
sourceSets.configureEach {
languageSettings {
useExperimentalAnnotation('kotlin.Experimental')
Expand Down Expand Up @@ -481,12 +481,6 @@ configure(bundleSmokeTests) {
}
}


import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import java.nio.file.Files
import java.nio.file.Paths
import java.util.stream.Collectors

def getSubprojectTasks(String name) {
return subprojects.collect { it.tasks.findByName(name) }.findAll { it != null }
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/check-dexer.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def preCheck_ATRIUM_ANDROID_JAR = task('preCheck_ATRIUM_ANDROID_JAR') {
}
}

def newMultiplatformProjects = newMultiplatformProjectNames.collect { prefixedProject(it) }
def dexerProjects = newMultiplatformProjects.findAll {
def multiplatformProjects = multiplatformProjectNames.collect { prefixedProject(it) }
def dexerProjects = multiplatformProjects.findAll {
!it.name.contains("-specs")
}
configure(dexerProjects) { subproject ->
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/gh-pages.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ task removeGhPages {
}

//TODO 0.19.0 configure dokka differently
def newMultiplatformProjects = newMultiplatformProjectNames.collect { prefixedProject(it) }
def projectsToConsider = docProjects - newMultiplatformProjects
def multiplatformProjects = multiplatformProjectNames.collect { prefixedProject(it) }
def projectsToConsider = docProjects - multiplatformProjects

task ghPages {
projectsToConsider.forEach { subProject ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import ch.tutteli.atrium.logic.creating.transformers.FeatureExtractorBuilder
* Collection of assertion functions and builders which are applicable to subjects with a [List] type.
*/
interface ListAssertions {
//TODO 0.19.0 change to ListLike in order that it works as well for arrays
//TODO 0.20.0 change to ListLike in order that it works as well for arrays
fun <E, T : List<E>> get(container: AssertionContainer<T>, index: Int): FeatureExtractorBuilder.ExecutionStep<T, E>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ abstract class ContainsAssertionCreator<T : Any, TT : Any, in SC, C : Contains.C
*/
protected abstract val descriptionToContain: Translatable

//TODO remove with 0.19.0
/**
* Provides the translation for `contains`.
*/
@Deprecated(
"Use descriptionToContain instead; will be removed with 0.19.0",
ReplaceWith("this.descriptionToContain ")
)
protected abstract val descriptionContains: Translatable


/**
* Provides the translation for when an item is not found in a `toContain.atLeast(1)` check.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class CharSequenceContainsAssertionCreator<T : CharSequence, in SC : Any, S : Se
) : ContainsObjectsAssertionCreator<T, String, SC, S, Checker>(searchBehaviour, checkers), Creator<T, SC> {

override val descriptionToContain: Translatable = DescriptionCharSequenceExpectation.TO_CONTAIN
@Suppress("OverridingDeprecatedMember")
override val descriptionContains: Translatable = descriptionToContain

override val descriptionNumberOfOccurrences: Translatable = DescriptionCharSequenceExpectation.NUMBER_OF_MATCHES
override val descriptionNotFound: Translatable = DescriptionCharSequenceExpectation.NOT_FOUND
override val descriptionNumberOfElementsFound: Translatable =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ch.tutteli.atrium.logic.collectForCompositionBasedOnSubject
/**
* Collects the assertions [assertionCreator] creates and uses them as [AssertionGroup.assertions].
*
* //TODO 0.19.0 in case we somehow incorporate the current container in AssertionsOptions, then remove container as parameter
* //TODO 0.20.0 in case we somehow incorporate the current container in AssertionsOptions, then remove container as parameter
*
* TODO 1.0.0 at the latest: use type ExplanatoryGroup.FinalStep when ExplanatoryAssertionGroupFinalStep is removed
*/
Expand All @@ -29,7 +29,7 @@ fun <T, G : ExplanatoryAssertionGroupType, R: ExplanatoryAssertionGroupFinalStep
maybeSubject: Option<T>,
assertionCreator: Expect<T>.() -> Unit
): ExplanatoryAssertionGroupFinalStep {
//TODO 0.19.0 simplify with new ProofContainer where we intend to return a flag for collectForCompositionBasedOnSubject which indicates whether
//TODO 0.20.0 simplify with new ProofContainer where we intend to return a flag for collectForCompositionBasedOnSubject which indicates whether
// no proof was created or not, this way we don't have to collect twice.
val collectingExpect = CollectingExpect<T>(None, container.components)
// not using addAssertionsCreatedBy on purpose so that we don't append a failing assertion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//TODO 0.19.0 rename iterable.contains to iterablelike.contains
//TODO 0.20.0 rename iterable.contains to iterablelike.contains
package ch.tutteli.atrium.logic.creating.iterable.contains

import ch.tutteli.atrium.assertions.Assertion
Expand All @@ -18,7 +18,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable
* defines which [Checker]s should be applied and
* is finalized by one of the [IterableLikeContainsAssertions] which usually use a [Creator].
*/
//TODO 0.19.0 use IterableLikeToContains in combination with Proof
//TODO 0.20.0 use IterableLikeToContains in combination with Proof
interface IterableLikeContains {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//TODO 0.19.0 rename package to iterableLike
//TODO 0.20.0 rename package to iterableLike
package ch.tutteli.atrium.logic.creating.iterable.contains.checkers

import ch.tutteli.atrium.logic.creating.iterable.contains.IterableLikeContains
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//TODO 0.19.0 rename package to iterableLike
//TODO 0.20.0 rename package to iterableLike
package ch.tutteli.atrium.logic.creating.iterable.contains.checkers.impl

import ch.tutteli.atrium.assertions.Assertion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//TODO 0.19.0 rename package to iterablelike?
//TODO 0.20.0 rename package to iterablelike?
package ch.tutteli.atrium.logic.creating.iterable.contains.checkers.impl

import ch.tutteli.atrium.assertions.Assertion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ class InAnyOrderEntriesAssertionCreator<E : Any, T : IterableLike>(

override val descriptionToContain: Translatable = DescriptionIterableLikeExpectation.TO_CONTAIN

@Deprecated(
"Use descriptionToContain instead; will be removed with 0.19.0",
replaceWith = ReplaceWith("this.descriptionToContain ")
)
@Suppress("OverridingDeprecatedMember")
override val descriptionContains: Translatable = descriptionToContain
override val descriptionNotFound: Translatable = DescriptionIterableLikeExpectation.ELEMENT_NOT_FOUND
override val descriptionNumberOfElementsFound: Translatable =
DescriptionIterableLikeExpectation.NUMBER_OF_ELEMENTS_FOUND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ abstract class InAnyOrderOnlyAssertionCreator<E, T : IterableLike, in SC>(
searchCriteria: List<SC>
): AssertionGroup {
return LazyThreadUnsafeAssertionGroup {
//TODO 0.19.0 explicit type should not be necessary
//TODO 0.20.0 explicit type should not be necessary, report
val listFromWhichMatchesWillBeRemoved: MutableList<E?> = container.maybeSubject.fold({ mutableListOf<E?>() }) { converter(it).toMutableList() }
val initialSize = listFromWhichMatchesWillBeRemoved.size
val assertions = mutableListOf<Assertion>()
//TODO 0.19.0 could be moved out to a function, is also used in InOrderOnlyBaseAssertionCreator
//TODO 0.20.0 could be moved out to a function, is also used in InOrderOnlyBaseAssertionCreator
val sizeAssertion = container.collectBasedOnSubject(Some(listFromWhichMatchesWillBeRemoved)) {
_logic
.size { it }
Expand All @@ -66,7 +66,7 @@ abstract class InAnyOrderOnlyAssertionCreator<E, T : IterableLike, in SC>(
}

val description = searchBehaviour.decorateDescription(TO_CONTAIN)
//TODO 0.19.0 could be moved out to a function, is also used in InOrderOnlyBaseAssertionCreator
//TODO 0.20.0 could be moved out to a function, is also used in InOrderOnlyBaseAssertionCreator
val options = InAnyOrderOnlyReportingOptionsImpl().apply(reportingOptions)
val assertionGroup = (if (searchCriteria.size <= options.maxNumberOfExpectedElementsForSummary) {
assertionBuilder.summary.withDescription(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class InAnyOrderValuesAssertionCreator<SC, T : IterableLike>(

override val descriptionToContain: Translatable = DescriptionIterableLikeExpectation.TO_CONTAIN

@Suppress("OverridingDeprecatedMember")
override val descriptionContains: Translatable = descriptionToContain
override val descriptionNumberOfOccurrences: Translatable =
DescriptionIterableLikeExpectation.NUMBER_OF_SUCH_ELEMENTS
override val groupDescription: Translatable = DescriptionIterableLikeExpectation.AN_ELEMENT_WHICH_EQUALS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ abstract class InOrderOnlyBaseAssertionCreator<E, T : IterableLike, SC>(
searchCriteria: List<SC>
): AssertionGroup {
return LazyThreadUnsafeAssertionGroup {
// TODO 0.19.0 more efficient and pragmatic than turnSubjectToList, use at other places too
// TODO 0.20.0 more efficient and pragmatic than turnSubjectToList, use at other places too
val maybeList = container.maybeSubject.map {
//TODO move into when with 1.0.0, update to Kotlin >= 1.4 respectively
//TODO move into `when` with the update to Kotlin >= 1.3
val iterable = converter(it)
when (iterable) {
is List -> iterable
Expand Down
Loading

0 comments on commit 65227ad

Please sign in to comment.