From aa319e34f4a5b38b61036ee634d14cdea3cbadfc Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 9 Jan 2021 22:59:26 +0100 Subject: [PATCH 1/3] remove deprecated stuff of Assertions in core and make internal... ... the Assertion which where announced to be made internal with 1.0.0 moreover: - deprecate evalOnce in core, not used by Atrium - adjust BC because we removed deprecated IndentAssertionGroup(Type) --- .../atrium/assertions/AssertionGroup.kt | 120 ------------------ .../atrium/assertions/BasicAssertionGroup.kt | 11 +- .../assertions/BasicDescriptiveAssertion.kt | 32 +---- .../assertions/BasicExplanatoryAssertion.kt | 11 +- .../atrium/assertions/DescriptiveAssertion.kt | 4 - ...mptyNameAndRepresentationAssertionGroup.kt | 5 +- .../assertions/ExplanatoryAssertionGroup.kt | 4 +- .../atrium/assertions/IndentAssertionGroup.kt | 14 -- .../assertions/IndentAssertionGroupType.kt | 16 --- .../assertions/InvisibleAssertionGroup.kt | 7 +- .../kotlin/ch/tutteli/atrium/core/evalOnce.kt | 2 + .../TextIndentAssertionGroupFormatter.kt | 45 ------- .../core/robstoll/CoreFactoryCommonImpl.kt | 4 - .../TextIndentAssertionGroupFormatterSpec.kt | 22 ---- .../AsciiBulletPointReporterFactory.kt | 2 - misc/tools/bc-tests/build.gradle.kts | 10 ++ 16 files changed, 20 insertions(+), 289 deletions(-) delete mode 100644 core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroup.kt delete mode 100644 core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroupType.kt delete mode 100644 core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatter.kt delete mode 100644 misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/AssertionGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/AssertionGroup.kt index c01183267..4bc8f49dd 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/AssertionGroup.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/AssertionGroup.kt @@ -1,7 +1,5 @@ package ch.tutteli.atrium.assertions -import ch.tutteli.atrium.assertions.builders.AssertionsOption -import ch.tutteli.atrium.assertions.builders.assertionBuilder import ch.tutteli.atrium.reporting.translating.Translatable /** @@ -15,11 +13,6 @@ interface AssertionGroup : Assertion { */ val description: Translatable - @Deprecated("Use description; will be removed with 1.0.0", ReplaceWith("description")) - val name - get() = description - - /** * The type of the group, e.g. [RootAssertionGroupType]. */ @@ -34,11 +27,6 @@ interface AssertionGroup : Assertion { */ val representation: Any - @Deprecated("Use representation; will be removed with 1.0.0", ReplaceWith("representation")) - val subject - get() = representation - - /** * The assertions of this group, which are defined for the subject represented by [representation]. */ @@ -50,112 +38,4 @@ interface AssertionGroup : Assertion { * @return `true` if all [assertions] hold; `false` otherwise. */ override fun holds() = assertions.all(Assertion::holds) - - @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") - object Builder { - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.root instead; will be removed with 1.0.0", - ReplaceWith( - "AssertImpl.builder.root", - "ch.tutteli.atrium.domain.builders.AssertImpl", - "ch.tutteli.atrium.assertions.builders.root" - ) - ) - val root = BasicAssertionGroupBuilder(RootAssertionGroupType) - - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.list instead; will be removed with 1.0.0", - ReplaceWith("AssertImpl.builder.list", "ch.tutteli.atrium.domain.builders.AssertImpl") - ) - val list = BasicAssertionGroupBuilder(DefaultListAssertionGroupType) - - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.feature instead; will be removed with 1.0.0", - ReplaceWith("AssertImpl.builder.feature", "ch.tutteli.atrium.domain.builders.AssertImpl") - ) - val feature = BasicAssertionGroupBuilder(DefaultFeatureAssertionGroupType) - - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.summary instead; will be removed with 1.0.0", - ReplaceWith("AssertImpl.builder.summary", "ch.tutteli.atrium.domain.builders.AssertImpl") - ) - val summary = BasicAssertionGroupBuilder(DefaultSummaryAssertionGroupType) - - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.explanatoryGroup instead; will be removed with 1.0.0", - ReplaceWith("AssertImpl.builder.explanatoryGroup", "ch.tutteli.atrium.domain.builders.AssertImpl") - ) - val explanatory = ExplanatoryAssertionGroupOption() - - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.invisible instead; will be removed with 1.0.0", - ReplaceWith( - "AssertImpl.builder.invisibleGroup", - "ch.tutteli.atrium.domain.builders.AssertImpl", - "ch.tutteli.atrium.assertions.builders.invisibleGroup" - ) - ) - val invisible = EmptyNameAndSubjectAssertionGroupBuilder(InvisibleAssertionGroupType) - - @Suppress("DEPRECATION") - @Deprecated( - "Use AssertImpl.builder.customType instead", - ReplaceWith( - "AssertImpl.builder.customType(groupType)", - "ch.tutteli.atrium.domain.builders.AssertImpl" - ) - ) - fun withType(groupType: AssertionGroupType) = BasicAssertionGroupBuilder(groupType) - - @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") - class BasicAssertionGroupBuilder(private val groupType: AssertionGroupType) { - fun create(name: Translatable, subject: Any, assertion: Assertion): AssertionGroup = - assertionBuilder.customType(groupType) - .withDescriptionAndRepresentation(name, subject) - .withAssertion(assertion) - .build() - - fun create(name: Translatable, subject: Any, assertions: List): AssertionGroup = - assertionBuilder.customType(groupType) - .withDescriptionAndRepresentation(name, subject) - .withAssertions(assertions) - .build() - } - - @Suppress("DEPRECATION") - @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") - class ExplanatoryAssertionGroupOption { - val withDefault = ExplanatoryAssertionGroupBuilder(DefaultExplanatoryAssertionGroupType) - val withWarning = ExplanatoryAssertionGroupBuilder(WarningAssertionGroupType) - fun withType(groupType: ExplanatoryAssertionGroupType) = ExplanatoryAssertionGroupBuilder(groupType) - } - - @Suppress("DEPRECATION") - @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") - class ExplanatoryAssertionGroupBuilder(private val groupType: ExplanatoryAssertionGroupType) { - fun create(assertion: Assertion): ExplanatoryAssertionGroup = create(assertion) - - fun create(assertions: List): ExplanatoryAssertionGroup = - ExplanatoryAssertionGroup(groupType, assertions, holds = true) - } - - @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") - class EmptyNameAndSubjectAssertionGroupBuilder(private val groupType: AssertionGroupType) { - fun create(assertion: Assertion): AssertionGroup = - AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType) - .withAssertion(assertion) - .build() - - fun create(assertions: List): AssertionGroup = - AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType) - .withAssertions(assertions) - .build() - } - } } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicAssertionGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicAssertionGroup.kt index 3d23b55af..9b43af8b4 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicAssertionGroup.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicAssertionGroup.kt @@ -12,16 +12,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable * @param representation The representation of the subject for which the [assertions] are defined. * @param assertions The assertions of this group, which are defined for the subject represented by [representation]. */ -@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0") -data class BasicAssertionGroup -@Deprecated( - "Use `AssertImpl.builder.customType` instead, will be made `internal` with 1.0.0", - ReplaceWith( - "AssertImpl.builder.customType(type).withAssertions(description, representation, assertions).build()", - "ch.tutteli.atrium.domain.builders.AssertImpl" - ) -) -constructor( +internal data class BasicAssertionGroup( override val type: AssertionGroupType, override val description: Translatable, override val representation: Any, diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicDescriptiveAssertion.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicDescriptiveAssertion.kt index 99f7dbee1..f1f212ddd 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicDescriptiveAssertion.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicDescriptiveAssertion.kt @@ -10,41 +10,13 @@ import ch.tutteli.atrium.reporting.translating.Translatable * @param representation The [BasicDescriptiveAssertion.representation]. * @param test Lazily determines whether [BasicDescriptiveAssertion.holds]. */ -@Deprecated("Use DescriptiveAssertion, do not rely on this specific type, will be made internal with 1.0.0") -class BasicDescriptiveAssertion -@Deprecated( - "Use `assertionBuilder.descriptive` instead, will be made `internal` with 1.0.0", - ReplaceWith( - "assertionBuilder.descriptive.withAssertions(description, representation, test)", - "ch.tutteli.atrium.assertions.builders.assertionBuilder" - ) -) -constructor( + +internal class BasicDescriptiveAssertion( override val description: Translatable, override val representation: Any, private val test: () -> Boolean ) : DescriptiveAssertion { - /** - * Constructor overload with an eager [BasicDescriptiveAssertion.holds]. - * - * If the calculation for [holds] is expensive, then you might want to use the other overload with a lazy test. - * - * @param description The [BasicDescriptiveAssertion.description]. - * @param representation The [BasicDescriptiveAssertion.representation]. - * @param holds Determines whether [BasicDescriptiveAssertion.holds] or not - */ - @Suppress("DEPRECATION" /* TODO remove with 0.16.0 */) - @Deprecated( - "Use `AssertImpl.builder.descriptive` instead, will be made `internal` with 1.0.0", - ReplaceWith( - "AssertImpl.builder.descriptive.withAssertions(description, representation, holds)", - "ch.tutteli.atrium.domain.builders.AssertImpl" - ) - ) - constructor(description: Translatable, representation: Any, holds: Boolean) - : this(description, representation, { holds }) - override fun holds() = test() /** diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicExplanatoryAssertion.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicExplanatoryAssertion.kt index 6ca83a0f9..d6e86b619 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicExplanatoryAssertion.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/BasicExplanatoryAssertion.kt @@ -3,15 +3,6 @@ package ch.tutteli.atrium.assertions /** * A default implementation for [ExplanatoryAssertion] -- an assertion which only wants to give an [explanation]. */ -@Deprecated("Use ExplanatoryAssertion, do not rely on this specific type, will be made internal with 1.0.0") -class BasicExplanatoryAssertion -@Deprecated( - "Use `AssertImpl.builder.explanatory` instead, will be made `internal` with 1.0.0", - ReplaceWith( - "AssertImpl.builder.explanatory.withAssertions(explanation)", - "ch.tutteli.atrium.domain.builders.AssertImpl" - ) -) -constructor(override val explanation: Any?) : ExplanatoryAssertion { +internal class BasicExplanatoryAssertion(override val explanation: Any?) : ExplanatoryAssertion { override fun toString() = explanation.toString() } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/DescriptiveAssertion.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/DescriptiveAssertion.kt index ef08f69ec..c23c97827 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/DescriptiveAssertion.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/DescriptiveAssertion.kt @@ -15,10 +15,6 @@ interface DescriptiveAssertion : Assertion { */ val representation: Any - @Deprecated("Use representation; will be removed with 1.0.0", ReplaceWith("representation")) - val expected - get() = representation - /** * The complementary description to the [representation] result such as `contains`, `is not` etc. */ diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/EmptyNameAndRepresentationAssertionGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/EmptyNameAndRepresentationAssertionGroup.kt index 1f85120c6..f6d41e4f3 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/EmptyNameAndRepresentationAssertionGroup.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/EmptyNameAndRepresentationAssertionGroup.kt @@ -11,10 +11,7 @@ import ch.tutteli.atrium.reporting.translating.Untranslatable * @param type The type of the group, e.g. [InvisibleAssertionGroupType]. * @param assertions The assertions of this group. */ -@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0") -open class EmptyNameAndRepresentationAssertionGroup -@Deprecated("Use AssertImpl.builder instead, will be made internal with 1.0.0") -constructor( +internal open class EmptyNameAndRepresentationAssertionGroup( override val type: AssertionGroupType, override val assertions: List ) : AssertionGroup { diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroup.kt index d67fcc982..acd9e481a 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroup.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/ExplanatoryAssertionGroup.kt @@ -11,9 +11,7 @@ import ch.tutteli.atrium.reporting.Reporter * @param explanatoryAssertions The [assertions] of this group which shall not be evaluated but are used in reporting * to explain something (rather than making assumptions). */ -@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) -@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0") -class ExplanatoryAssertionGroup internal constructor( +internal class ExplanatoryAssertionGroup( type: ExplanatoryAssertionGroupType, explanatoryAssertions: List, private val holds: Boolean diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroup.kt deleted file mode 100644 index e4e757fa5..000000000 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroup.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ch.tutteli.atrium.assertions - -/** - * Represents an [AssertionGroup] with a [DefaultIndentAssertionGroupType], which means the [assertions] shall be - * indented one extra level and [description] and [representation] shall be neglected (not reported to the output). - * - * @constructor Represents an [AssertionGroup] with a [DefaultIndentAssertionGroupType], which means the [assertions] shall - * be indented one extra level and [description] and [representation] shall be neglected (not reported to the output). - * @param assertions The assertions of this group. - */ -@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See AssertImpl.builder for different groups. Will be removed with 1.0.0") -class IndentAssertionGroup(assertions: List) : - EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, assertions) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroupType.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroupType.kt deleted file mode 100644 index 571c77189..000000000 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/IndentAssertionGroupType.kt +++ /dev/null @@ -1,16 +0,0 @@ -package ch.tutteli.atrium.assertions - -/** - * Represents the [AssertionGroupType] for [AssertionGroup]s whose [assertions][AssertionGroup.assertions] - * should be displayed with an extra indent. Such a group might have a [AssertionGroup.description] and - * [AssertionGroup.representation] (by accident) but should not be mentioned in reporting. - */ -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See other `AssertionGroupType`s. Will be removed with 1.0.0") -interface IndentAssertionGroupType : AssertionGroupType - -/** - * The [AssertionGroupType] for [AssertionGroup]s whose assertions should be displayed with an extra indent. - */ -@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See other `AssertionGroupType`s. Will be removed with 1.0.0") -object DefaultIndentAssertionGroupType : IndentAssertionGroupType diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/InvisibleAssertionGroup.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/InvisibleAssertionGroup.kt index 36def2ffc..543a99a09 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/InvisibleAssertionGroup.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/InvisibleAssertionGroup.kt @@ -3,11 +3,8 @@ package ch.tutteli.atrium.assertions /** * Represents an [AssertionGroup] with an [InvisibleAssertionGroupType], which means the grouping should be * invisible in reporting. - * - * @constructor Use [AssertionGroup.Builder.invisible] to create an [InvisibleAssertionGroup]. + *l * @param assertions The assertions of this group. */ -@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) -@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0") -class InvisibleAssertionGroup internal constructor(assertions: List) : +internal class InvisibleAssertionGroup(assertions: List) : EmptyNameAndRepresentationAssertionGroup(InvisibleAssertionGroupType, assertions) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/evalOnce.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/evalOnce.kt index 1264ddc7a..41e834ee2 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/evalOnce.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/evalOnce.kt @@ -6,6 +6,8 @@ package ch.tutteli.atrium.core * * @return The result of evaluating this function (calling it). */ +//TODO remove with 0.17.0 +@Deprecated("Will be removed with 0.17.0 without replacement") fun (() -> T).evalOnce(): () -> T { val v by lazy { this() } return { v } diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatter.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatter.kt deleted file mode 100644 index 9d6ea30dd..000000000 --- a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatter.kt +++ /dev/null @@ -1,45 +0,0 @@ -@file:Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) - -package ch.tutteli.atrium.core.robstoll.lib.reporting - -import ch.tutteli.atrium.assertions.AssertionGroup -import ch.tutteli.atrium.assertions.BulletPointIdentifier -import ch.tutteli.atrium.assertions.IndentAssertionGroupType -import ch.tutteli.atrium.reporting.AssertionFormatter -import ch.tutteli.atrium.reporting.AssertionFormatterController -import ch.tutteli.atrium.reporting.AssertionFormatterParameterObject -import kotlin.reflect.KClass - -/** - * Represents an [AssertionFormatter] which formats [AssertionGroup]s with an [IndentAssertionGroupType] or rather - * creates a child-[AssertionFormatterParameterObject] which proposes to use the bullet point defined - * for [IndentAssertionGroupType] for the [AssertionGroup.assertions]. - * - * It does not include a group header in its result or in other words, skips the first part of formatting an - * [AssertionGroup] as defined in [AssertionFormatter.formatGroup]. - * - * Its usage is intended for text output (e.g. to the console). - * - * @constructor Represents an [AssertionFormatter] which formats [AssertionGroup]s with an [IndentAssertionGroupType] - * or rather creates a child-[AssertionFormatterParameterObject] which proposes to use the bullet point - * defined for [IndentAssertionGroupType] for the [AssertionGroup.assertions]. - * @param bulletPoints The formatter uses the bullet point defined for [IndentAssertionGroupType] - * (`" ⋄ "` if absent) as prefix of the child-[AssertionFormatterParameterObject]. - * @param assertionFormatterController The controller to which this formatter gives back the control - * when it comes to format children of an [AssertionGroup]. - */ -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). Will be removed with 1.0.0") -class TextIndentAssertionGroupFormatter( - bulletPoints: Map, String>, - assertionFormatterController: AssertionFormatterController -) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter( - IndentAssertionGroupType::class, - assertionFormatterController -) { - private val bulletPoint = bulletPoints[IndentAssertionGroupType::class] ?: " ⋄ " - - override fun formatGroupHeaderAndGetChildParameterObject( - assertionGroup: AssertionGroup, - parameterObject: AssertionFormatterParameterObject - ): AssertionFormatterParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint) -} diff --git a/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt b/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt index 670218465..36d18ae1b 100644 --- a/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt +++ b/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt @@ -111,10 +111,6 @@ abstract class CoreFactoryCommonImpl : CoreFactoryCommon { assertionFormatterFacade.register { TextExplanatoryAssertionGroupFormatter(bulletPoints, it) } - assertionFormatterFacade.register { - @Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) - TextIndentAssertionGroupFormatter(bulletPoints, it) - } assertionFormatterFacade.register { TextSummaryAssertionGroupFormatter(bulletPoints, it, textAssertionPairFormatter) } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt deleted file mode 100644 index 66769b301..000000000 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt +++ /dev/null @@ -1,22 +0,0 @@ -@file:Suppress("DEPRECATION" /* TODO remove this suppression with 1.0.0 */) - -package ch.tutteli.atrium.specs.reporting - -import ch.tutteli.atrium.assertions.BulletPointIdentifier -import ch.tutteli.atrium.assertions.DefaultIndentAssertionGroupType -import ch.tutteli.atrium.assertions.EmptyNameAndRepresentationAssertionGroup -import ch.tutteli.atrium.assertions.IndentAssertionGroupType -import ch.tutteli.atrium.reporting.AssertionFormatter -import ch.tutteli.atrium.reporting.AssertionFormatterController -import kotlin.reflect.KClass - -abstract class TextIndentAssertionGroupFormatterSpec( - testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, - describePrefix: String = "[Atrium] " -) : TextIndentBasedAssertionGroupFormatterSpec( - testeeFactory, - IndentAssertionGroupType::class, - object : IndentAssertionGroupType {}, - { EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, it) }, - describePrefix -) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt index eb4621b78..250bd1982 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt @@ -19,8 +19,6 @@ class AsciiBulletPointReporterFactory : ReporterFactory { RootAssertionGroupType::class to "* ", ListAssertionGroupType::class to "- ", FeatureAssertionGroupType::class to "=> ", - @Suppress("DEPRECATION" /* TODO remove together with entry with 1.0.0 */) - IndentAssertionGroupType::class to "| ", PrefixFeatureAssertionGroupHeader::class to ">> ", PrefixSuccessfulSummaryAssertion::class to "(/) ", PrefixFailingSummaryAssertion::class to "(x) ", diff --git a/misc/tools/bc-tests/build.gradle.kts b/misc/tools/bc-tests/build.gradle.kts index 319ba4651..444b2600a 100644 --- a/misc/tools/bc-tests/build.gradle.kts +++ b/misc/tools/bc-tests/build.gradle.kts @@ -2,6 +2,7 @@ // you need to specify the environment variable BC in order that this project (as well as the subprojects) // are included -> alternatively, you can remove the `if` in settings.gradle.kts (search for System.getenv("BC")) +// import ch.tutteli.niok.* import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent @@ -496,6 +497,7 @@ fun Project.rewriteFile(filePath: String, f: (String) -> String) { val file = file(filePath) file.writeText(f(file.readText())) } +// // ----------------------------------------------------------------------------------- // Known source backward compatibility breaks: @@ -528,9 +530,17 @@ listOf("0.14.0", "0.15.0").forEach { version -> it.replaceFirst("import ch.tutteli.atrium.domain.builders.ExpectImpl", "") } + rewriteFile("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt") { + it.replaceFirst( + " @Suppress(\"DEPRECATION\" /* TODO remove together with entry with 1.0.0 */)\n" + + " IndentAssertionGroupType::class to \"| \",", "" + ) + } + // deleted AssertionPlant and co. in 0.16.0, hence specs don't make sense any more (it's a bc on core level not API) file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/checking/").deleteRecursively() file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/creating/").deleteRecursively() + file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt").delete() } } From 4aa0600789f92c8fe18e9fb601e1a5d155663ac9 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 9 Jan 2021 23:00:09 +0100 Subject: [PATCH 2/3] fix settings.gradle.kts bundle smoke test was no longer included add a check if directory exists in custom include (we had this in tutteli-gradle plugin, had definitely some merit) --- .../build.gradle | 10 ---- .../src/test/kotlin/custom/SmokeSpec.kt | 50 ------------------- .../src/test/kotlin/module-info.java | 10 ---- settings.gradle.kts | 8 ++- 4 files changed, 6 insertions(+), 72 deletions(-) delete mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle delete mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt delete mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle deleted file mode 100644 index 07db9d74a..000000000 --- a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -description = "Represents a JDK >= 9 smoke test for atrium-infix-en_GB with jdk8 extension" - -sourceCompatibility = JavaVersion.current() -targetCompatibility = JavaVersion.current() - -dependencies { - //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead - testImplementation prefixedProject('infix-en_GB-jvm') - testImplementation prefixedProject('api-infix-en_GB-jdk8-jvm') -} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt deleted file mode 100644 index a00b8780a..000000000 --- a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt +++ /dev/null @@ -1,50 +0,0 @@ -package custom - -import ch.tutteli.atrium.api.infix.en_GB.jdk8.notTo -import ch.tutteli.atrium.api.infix.en_GB.exist -import ch.tutteli.atrium.api.infix.en_GB.toBe -import ch.tutteli.atrium.api.verbs.assert -import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.builders.ExpectImpl -import ch.tutteli.atrium.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic -import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe -import java.nio.file.Paths - -object SmokeSpec : Spek({ - test("see if `toBe` can be used") { - assert(1) toBe 1 - } - - test("see if `Path.existsNot` can be used") { - assert(Paths.get("nonExisting")) notTo exist - } - - test("see if own assertion function without i18n can be used") { - assert(2) tobe even - } - - test("see if own assertion function with i18n can be used") { - assert(4) isMultipleOf 2 - } -}) - -@Suppress("ClassName") -object even - -infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = - createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } - -infix fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) - -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java deleted file mode 100644 index 0ff4f7a4d..000000000 --- a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java +++ /dev/null @@ -1,10 +0,0 @@ -module ch.tutteli.atrium.infix.en_GB.jdk8.smoke { - // test dependencies are usually defined in build.gradle via --patch-module but that's quite cumbersome and I did - // not get it running in 10 minutes so I am using this, the effect should be the same, the kotlin compiler checks if - // I am using symbols from packages I do not require etc. - - requires ch.tutteli.atrium.infix.en_GB; - requires ch.tutteli.atrium.api.infix.en_GB.jdk8; - requires kotlin.stdlib; - requires spek.dsl.jvm; -} diff --git a/settings.gradle.kts b/settings.gradle.kts index a6de8b584..029125dc4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -80,7 +80,7 @@ fun Settings_gradle.includeBundleAndApisWithExtensionsAndSmokeTest(vararg apiNam includeKotlinJvmJs("bundles/$apiName", "atrium-$apiName") if (JavaVersion.current() >= JavaVersion.VERSION_1_9) { include("bundles/$apiName/", "atrium-$apiName-smoke-test") - includeKotlinJvmJs("bundles/$apiName/extensions/kotlin_1_3", "atrium-$apiName-smoke-test-kotlin_1_3") + include("bundles/$apiName/extensions", "atrium-$apiName-smoke-test-kotlin_1_3") } includeKotlinJvmJsWithExtensions("apis/$apiName", "atrium-api-$apiName") } @@ -98,6 +98,10 @@ fun Settings_gradle.includeKotlinJvmJsWithExtensions(subPath: String, module: St } fun Settings_gradle.include(subPath: String, projectName: String) { + val dir = file("${rootProject.projectDir}/$subPath/$projectName") + if(!dir.exists()){ + throw GradleException("cannot include project $projectName as its projectDir $dir does not exist") + } include(projectName) - project(":$projectName").projectDir = file("${rootProject.projectDir}/$subPath/$projectName") + project(":$projectName").projectDir = dir } From 5474d2fca34022128f6a7179647a6f28db7d7383 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 10 Jan 2021 20:36:52 +0100 Subject: [PATCH 3/3] deprecate SubjectProvider & Expect.maybeSubject, remove AsertionHolder moreover: - adjust SmokeTests use _logicAppend instead of addAssertion and impl function --- .../api/fluent/en_GB/expectExtensions.kt | 12 ++++-- .../api/infix/en_GB/expectExtensions.kt | 12 ++++-- .../src/test/kotlin/SmokeTest.kt | 12 +++--- .../src/test/kotlin/custom/SmokeSpec.kt | 12 +++--- .../src/test/kotlin/custom/SmokeSpec.kt | 12 +++--- .../src/test/kotlin/SmokeTest.kt | 13 ++++--- .../src/test/kotlin/custom/SmokeSpec.kt | 13 ++++--- .../src/test/kotlin/custom/SmokeSpec.kt | 12 +++--- .../assertions/builders/AssertionBuilder.kt | 37 +++++++++++-------- .../assertions/builders/SubjectBasedOption.kt | 5 +-- .../assertions/builders/common/HoldsStep.kt | 6 ++- .../builders/common/impl/HoldsStepImpl.kt | 3 +- .../atrium/assertions/builders/descriptive.kt | 6 ++- .../builders/descriptiveWithFailureHint.kt | 13 ++++--- .../builders/impl/descriptive/defaultImpls.kt | 3 +- .../atrium/creating/AssertionContainer.kt | 12 ++++-- .../atrium/creating/AssertionHolder.kt | 23 ------------ .../atrium/creating/DelegatingExpect.kt | 10 ++--- .../ch/tutteli/atrium/creating/Expect.kt | 30 +++++++++++++-- .../tutteli/atrium/creating/FeatureExpect.kt | 5 +-- .../atrium/creating/SubjectProvider.kt | 22 ++++++++--- .../creating/impl/DelegatingExpectImpl.kt | 7 ++-- .../atrium/reporting/ObjectFormatter.kt | 4 +- .../InOrderOnlyGroupedAssertionCreator.kt | 9 +++-- .../impl/InOrderOnlyValuesAssertionCreator.kt | 3 +- .../impl/DefaultSubjectChanger.kt | 3 +- .../atrium/logic/utils/MapArgumentsSpec.kt | 2 +- .../DescriptionTypeTransformationAssertion.kt | 3 +- .../DescriptionTypeTransformationAssertion.kt | 3 +- 29 files changed, 166 insertions(+), 141 deletions(-) delete mode 100644 core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionHolder.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt index 27f64faa3..dcd054b88 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt @@ -17,7 +17,8 @@ annotation class ExperimentalWithOptions * Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject * instead of the representation that has been defined so far (which defaults to the subject itself). * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. * * @return An [Expect] for the current subject of the assertion. */ @@ -35,7 +36,8 @@ fun RootExpect.withRepresentation(textRepresentation: String): Expect * If your text does not include the current subject, then we recommend to use the other overload which expects * a `String` and does the wrapping for you. * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. * * @return An [Expect] for the current subject of the assertion. */ @@ -68,7 +70,8 @@ fun RootExpect.withOptions(options: ExpectOptions): Expect = * Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject * instead of the representation that has been defined so far (which defaults to the subject itself). * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. * * @return An [Expect] for the current subject of the assertion. */ @@ -88,7 +91,8 @@ fun FeatureExpect.withRepresentation(textRepresentation: String): E * If your text does not include the current subject, then we recommend to use the other overload which expects * a `String` and does the wrapping for you. * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. * * @return An [Expect] for the current subject of the assertion. */ diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt index 870097f6d..ce5efd46f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt @@ -17,7 +17,8 @@ annotation class ExperimentalWithOptions * Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject * instead of the representation that has been defined so far (which defaults to the subject itself). * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. */ @ExperimentalWithOptions infix fun RootExpect.withRepresentation(textRepresentation: String): Expect = @@ -33,7 +34,8 @@ infix fun RootExpect.withRepresentation(textRepresentation: String): Expe * If your text does not include the current subject, then we recommend to use the other overload which expects * a `String` and does the wrapping for you. * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. */ @ExperimentalWithOptions infix fun RootExpect.withRepresentation(representationProvider: (T) -> Any): Expect = @@ -60,7 +62,8 @@ infix fun RootExpect.withOptions(options: ExpectOptions): Expect = * Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject * instead of the representation that has been defined so far (which defaults to the subject itself). * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. * * @return An [Expect] for the current subject of the assertion. */ @@ -80,7 +83,8 @@ infix fun FeatureExpect.withRepresentation(textRepresentation: Stri * If your text does not include the current subject, then we recommend to use the other overload which expects * a `String` and does the wrapping for you. * - * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]), + * then the previous representation is used. * * @return An [Expect] for the current subject of the assertion. */ diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt b/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt index cbaec46c5..5de731885 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt @@ -7,8 +7,10 @@ import ch.tutteli.atrium.api.verbs.assert import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logicAppend +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionAnyAssertion.TO_BE @@ -107,12 +109,10 @@ class SmokeTest { fun Expect.isEven() = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 } -fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) +fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } -private fun _isMultipleOf(expect: Expect, base: Int): Assertion = - assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } +private fun AssertionContainer.isMultipleOf(base: Int): Assertion = + createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt index fb369e6c6..557992a3f 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt @@ -5,8 +5,10 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.assert import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logicAppend +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic @@ -34,12 +36,10 @@ object SmokeSpec : Spek({ fun Expect.isEven() = createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } -fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) +fun Expect.isMultipleOf(base: Int) = _logicAppend { isMultipleOf(base) } -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } +private fun AssertionContainer.isMultipleOf(base: Int): Assertion = + createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt index 2a054096c..1f69efc91 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt @@ -9,8 +9,10 @@ import ch.tutteli.atrium.api.fluent.en_GB.kotlin_1_3.isSuccess import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logicAppend +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic @@ -37,12 +39,10 @@ object SmokeSpec : Spek({ fun Expect.isEven(): Expect = createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } -fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) +fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } +private fun AssertionContainer.isMultipleOf(base: Int): Assertion = + createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt b/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt index 77f06f1b3..3d76772b0 100644 --- a/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt +++ b/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt @@ -1,8 +1,10 @@ import ch.tutteli.atrium.api.infix.en_GB.* import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logicAppend +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic.IS @@ -55,13 +57,12 @@ object even infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 } -infix fun Expect.isMultipleOf(base: Int): Expect = addAssertion(isMultipleOf(this, base)) +infix fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } -private fun isMultipleOf(expect: Expect, base: Int): Assertion = - assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } +private fun AssertionContainer.isMultipleOf(base: Int): Assertion = + createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") } + diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt index 4d85ffdf7..f368a89c8 100644 --- a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt @@ -3,8 +3,10 @@ package custom import ch.tutteli.atrium.api.infix.en_GB.toBe import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logicAppend +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic @@ -30,13 +32,12 @@ object even infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } -infix fun Expect.isMultipleOf(base: Int) = addAssertion(isMultipleOf(this, base)) +infix fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } -fun isMultipleOf(expect: Expect, base: Int): Assertion = - assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } +private fun AssertionContainer.isMultipleOf(base: Int): Assertion = + createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") } + diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt index b7612cd1b..943db7ae7 100644 --- a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt @@ -10,8 +10,10 @@ import ch.tutteli.atrium.api.infix.en_GB.success import ch.tutteli.atrium.api.infix.en_GB.toBe import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logicAppend +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic @@ -41,12 +43,10 @@ object even infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } -infix fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) +infix fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } +private fun AssertionContainer.isMultipleOf(base: Int): Assertion = + createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/AssertionBuilder.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/AssertionBuilder.kt index ad9924711..2e378e6c5 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/AssertionBuilder.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/AssertionBuilder.kt @@ -2,12 +2,10 @@ package ch.tutteli.atrium.assertions.builders import ch.tutteli.atrium.assertions.* import ch.tutteli.atrium.assertions.builders.impl.AssertionBuilderImpl -import ch.tutteli.atrium.core.None import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.ObjectFormatter -import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.Reporter +import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Untranslatable @@ -164,14 +162,19 @@ interface AssertionBuilder { * @param description The description of the assertion, e.g. `to Be`. * @param representation The representation of the expected outcome. * @param test The test which checks whether the assertion holds. - * - * @throws ch.tutteli.atrium.creating.PlantHasNoSubjectException in case [test] is called in a context where it - * is not safe to call it. For instance, if [test] is called within an explanatory assertion where it is - * possible that [Expect.maybeSubject] is [None]. */ - //TODO remove @throws with 1.0.0 + //TODO remove with 0.17.0 + @Suppress("DEPRECATION") + @Deprecated( + "Use _logic.createDescriptive instead; will be removed with 0.17.0", + ReplaceWith( + "container.createDescriptiveAssertion", + "ch.tutteli.atrium.logic._logic", + "ch.tutteli.atrium.logic.createDescriptiveAssertion" + ) + ) fun createDescriptive( - subjectProvider: SubjectProvider, + subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, description: String, representation: Any?, test: (T) -> Boolean @@ -197,14 +200,18 @@ interface AssertionBuilder { * @param description The description of the assertion, e.g. `to Be`. * @param representation The representation of the expected outcome. * @param test The test which checks whether the assertion holds. - * - * @throws ch.tutteli.atrium.creating.PlantHasNoSubjectException in case [test] is called in a context where it - * is not safe to call it. For instance, if [test] is called within an explanatory assertion where it is - * possible that [Expect.maybeSubject] is [None]. */ - //TODO remove @throws with 1.0.0 + //TODO remove with 0.17.0 + @Deprecated( + "Use extension AssertionContainer.createDescriptiveAssertion instead - e.g. _logic.createDescriptiveAssertion; will be removed with 0.17.0", + ReplaceWith( + "container.createDescriptiveAssertion", + "ch.tutteli.atrium.logic._logic", + "ch.tutteli.atrium.logic.createDescriptiveAssertion" + ) + ) fun createDescriptive( - subjectProvider: SubjectProvider, + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, description: Translatable, representation: Any?, test: (T) -> Boolean diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/SubjectBasedOption.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/SubjectBasedOption.kt index 4568c92b3..c4ed7e21d 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/SubjectBasedOption.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/SubjectBasedOption.kt @@ -1,7 +1,5 @@ package ch.tutteli.atrium.assertions.builders -import ch.tutteli.atrium.creating.SubjectProvider - /** * Contract for sub option steps which are based on a defined or absent subject of the assertion. */ @@ -40,8 +38,9 @@ interface SubjectBasedOption { } companion object { + @Suppress("DEPRECATION") operator fun > invoke( - subjectProvider: SubjectProvider, + subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, subStep: PO.() -> Pair<() -> R, (T) -> R>, presentOptionFactory: () -> PO ): R { diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/HoldsStep.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/HoldsStep.kt index a7e73bf52..5eaf72daf 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/HoldsStep.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/HoldsStep.kt @@ -2,7 +2,6 @@ package ch.tutteli.atrium.assertions.builders.common import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.RepresentationOnlyAssertion -import ch.tutteli.atrium.creating.SubjectProvider /** * Step which allows to specify [RepresentationOnlyAssertion.holds]. @@ -35,5 +34,8 @@ interface HoldsStep { * @return `true` in case [SubjectProvider.maybeSubject] is None or the result of [test] passing the subject. */ //TODO move to logic and expect AssertionContainer with 0.16.0 - fun withTest(subjectProvider: SubjectProvider, test: (T) -> Boolean): R + fun withTest( + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + test: (T) -> Boolean + ): R } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/impl/HoldsStepImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/impl/HoldsStepImpl.kt index 5f22ef699..c96ce53bd 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/impl/HoldsStepImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/common/impl/HoldsStepImpl.kt @@ -2,7 +2,6 @@ package ch.tutteli.atrium.assertions.builders.common.impl import ch.tutteli.atrium.assertions.builders.common.HoldsStep import ch.tutteli.atrium.core.falseProvider -import ch.tutteli.atrium.creating.SubjectProvider internal abstract class HoldsStepImpl : HoldsStep { //TODO use falseProvider https://youtrack.jetbrains.com/issue/KT-27736 @@ -10,7 +9,7 @@ internal abstract class HoldsStepImpl : HoldsStep { //TODO use trueProvider https://youtrack.jetbrains.com/issue/KT-27736 override val holding: R = withTest { true } - override fun withTest(subjectProvider: SubjectProvider, test: (T) -> Boolean): R = withTest { + override fun withTest(@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, test: (T) -> Boolean): R = withTest { subjectProvider.maybeSubject.fold(falseProvider, test) } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptive.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptive.kt index 509a47401..96583ebda 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptive.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptive.kt @@ -5,7 +5,6 @@ import ch.tutteli.atrium.assertions.DescriptiveAssertion import ch.tutteli.atrium.assertions.builders.impl.descriptive.DescriptionOptionImpl import ch.tutteli.atrium.assertions.builders.impl.descriptive.FinalStepImpl import ch.tutteli.atrium.assertions.builders.impl.descriptive.HoldsOptionImpl -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Untranslatable @@ -43,7 +42,10 @@ interface Descriptive { * ``` */ //TODO move to logic and expect AssertionContainer with 0.16.0 - fun withTest(subjectProvider: SubjectProvider, test: (T) -> Boolean): DescriptionOption + fun withTest( + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + test: (T) -> Boolean + ): DescriptionOption companion object { /** diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptiveWithFailureHint.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptiveWithFailureHint.kt index 335da58e3..551ee2fb3 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptiveWithFailureHint.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/descriptiveWithFailureHint.kt @@ -4,7 +4,6 @@ import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.AssertionGroup import ch.tutteli.atrium.assertions.DescriptiveAssertion import ch.tutteli.atrium.assertions.builders.impl.descriptiveWithFailureHint.* -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable @@ -35,7 +34,7 @@ fun Descriptive.DescriptionOption.withFailureHint( */ //TODO move to logic and expect AssertionContainer with 0.16.0 fun Descriptive.DescriptionOption.withFailureHintBasedOnDefinedSubject( - subjectProvider: SubjectProvider, + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, failureHintFactory: (T) -> Assertion ): Descriptive.DescriptionOption { return withFailureHintBasedOnSubject(subjectProvider) { @@ -58,7 +57,7 @@ fun Descriptive.DescriptionOption.withFailureHintBase * on the subject of the assertion. */ fun Descriptive.DescriptionOption.withFailureHintBasedOnSubject( - subjectProvider: SubjectProvider, + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, failureHintSubStep: DescriptiveAssertionWithFailureHint.FailureHintSubjectDefinedOption.() -> Pair<() -> Assertion, (T) -> Assertion> ): DescriptiveAssertionWithFailureHint.ShowOption = withFailureHint { SubjectBasedOption( @@ -116,14 +115,16 @@ interface DescriptiveAssertionWithFailureHint { /** * Defines that the failure hint shall be shown in any case as long as the subject is defined */ - fun showOnlyIfSubjectDefined(subjectProvider: SubjectProvider): Descriptive.DescriptionOption = + fun showOnlyIfSubjectDefined( + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider + ): Descriptive.DescriptionOption = showOnlyIf { subjectProvider.maybeSubject.isDefined() } /** * Defines that the failure hint shall be shown if the subject is defined and the given [predicate] holds for it */ fun showBasedOnDefinedSubjectOnlyIf( - subjectProvider: SubjectProvider, + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, predicate: (T) -> Boolean ): Descriptive.DescriptionOption = showBasedOnSubjectOnlyIf(subjectProvider) { ifDefined { predicate(it) } ifAbsent { false } } @@ -136,7 +137,7 @@ interface DescriptiveAssertionWithFailureHint { * of the assertion. */ fun showBasedOnSubjectOnlyIf( - subjectProvider: SubjectProvider, + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, showSubStep: ShowSubjectDefinedOption.() -> Pair<() -> Boolean, (T) -> Boolean> ): Descriptive.DescriptionOption = showOnlyIf { SubjectBasedOption(subjectProvider, showSubStep, ShowSubjectDefinedOption.Companion::create) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/descriptive/defaultImpls.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/descriptive/defaultImpls.kt index 4bab58e79..4be50dd76 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/descriptive/defaultImpls.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/assertions/builders/impl/descriptive/defaultImpls.kt @@ -3,7 +3,6 @@ package ch.tutteli.atrium.assertions.builders.impl.descriptive import ch.tutteli.atrium.assertions.DescriptiveAssertion import ch.tutteli.atrium.assertions.builders.Descriptive import ch.tutteli.atrium.core.falseProvider -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable @@ -22,7 +21,7 @@ internal object HoldsOptionImpl : Descriptive.HoldsOption { Descriptive.DescriptionOption.create(test, Descriptive.FinalStep.Companion::create) override fun withTest( - subjectProvider: SubjectProvider, + @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, test: (T) -> Boolean ): Descriptive.DescriptionOption = withTest { subjectProvider.maybeSubject.fold(falseProvider, test) 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 2e43d7132..b05bec664 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 @@ -2,7 +2,9 @@ package ch.tutteli.atrium.creating import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.core.ExperimentalNewExpectTypes +import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.Option +import ch.tutteli.atrium.core.Some import kotlin.reflect.KClass /** @@ -11,13 +13,15 @@ import kotlin.reflect.KClass * In contrast to assertion function defined for [Expect] which usually return [Expect], functions defined for * [AssertionContainer] return [Assertion] so that they can be appended to whatever we want. * - * Note, do not use [SubjectProvider] as this interface is only temporary and will most likely be removed without - * further notice. + * Note, do not use [SubjectProvider] as this interface will be removed with 0.17.0. * * @param T The type of the subject of the assertion. */ -//TODO 0.16.0 remove SubjectProvider -interface AssertionContainer : SubjectProvider { +interface AssertionContainer : @kotlin.Suppress("DEPRECATION") SubjectProvider { + /** + * Either [Some] wrapping the subject of an [Assertion] or [None] in case a previous subject transformation + * could not be carried out. + */ override val maybeSubject: Option /** diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionHolder.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionHolder.kt deleted file mode 100644 index 2c497cd53..000000000 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/AssertionHolder.kt +++ /dev/null @@ -1,23 +0,0 @@ -package ch.tutteli.atrium.creating - -import ch.tutteli.atrium.assertions.Assertion - -/** - * Represents a general interface which merely defines that assertions can be added to this type via the [addAssertion] - * method. - * - * Notice, this interface has its mere purpose to facilitate the transition from [Assert] to [Expect]. - * It might well be that we are going to remove it with 1.0.0 without previous notice. - * Hence, to be on the safe side, you should use [Expect] instead. - */ -interface AssertionHolder { - /** - * Adds the given [assertion] to this holder. - * - * @param assertion The assertion which will be added to this holder. - * - * @return This holder to support a fluent API. - * @throws AssertionError Might throw an [AssertionError] in case the [Assertion] does not hold. - */ - fun addAssertion(assertion: Assertion): AssertionHolder -} diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/DelegatingExpect.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/DelegatingExpect.kt index 345ef3f68..6b454953c 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/DelegatingExpect.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/DelegatingExpect.kt @@ -5,17 +5,13 @@ import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.creating.impl.DelegatingExpectImpl /** - * Represents an [Expect] which passes on appended assertions to a given [AssertionHolder]. - * - * Notice, that [AssertionHolder] has its mere purpose to facilitate the transition from [Assert] to [Expect]. - * It might well be that we are going to remove it with 1.0.0 without previous notice. - * Hence, to be on the safe side, you should use [Expect] instead. + * Represents an [Expect] which passes on appended assertions to a given [Expect]. */ interface DelegatingExpect : Expect { companion object { @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalNewExpectTypes::class) - operator fun invoke(assertionHolder: AssertionHolder, maybeSubject: Option): Expect = - DelegatingExpectImpl(assertionHolder, maybeSubject) + operator fun invoke(expect: AssertionContainer<*>, maybeSubject: Option): Expect = + DelegatingExpectImpl(expect, maybeSubject) } } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt index 1514a7781..0cdde18a3 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt @@ -3,6 +3,9 @@ package ch.tutteli.atrium.creating import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.DescriptiveAssertion import ch.tutteli.atrium.assertions.builders.assertionBuilder +import ch.tutteli.atrium.core.None +import ch.tutteli.atrium.core.Option +import ch.tutteli.atrium.core.Some import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Untranslatable @@ -22,18 +25,33 @@ annotation class ExpectMarker * * See https://github.com/robstoll/atrium-roadmap/wiki/Requirements#personas for more information about the personas. */ -interface ExpectInternal : Expect, AssertionContainer +interface ExpectInternal : Expect, AssertionContainer{ + //TODO remove with 0.17.0 no longer necessary once it only exist in AssertionContainer + /** + * Either [Some] wrapping the subject of an [Assertion] or [None] in case a previous subject change could not be + * carried out. + */ + override val maybeSubject: Option +} + /** * Represents the extension point for [Assertion] functions and sophisticated builders for subjects of type [T]. * - * Note, do not use [SubjectProvider] as this interface is only temporary and will most likely be removed without - * further notice. + * Note, do not use [SubjectProvider] as this interface is only temporary and will be removed with 0.17.0. * * @param T The type of the subject of the assertion. */ +@Suppress("DEPRECATION") @ExpectMarker -interface Expect : SubjectProvider { +interface Expect : @kotlin.Suppress("DEPRECATION") SubjectProvider { + + @Deprecated( + "use _logic.maybeSubject will be removed with 0.17.0", + ReplaceWith("this._logic.maybeSubject", "ch.tutteli.atrium.logic._logic") + ) + override val maybeSubject: Option + get() = TODO("Not yet implemented") /** * Adds the assertions created by the [assertionCreator] lambda to this container and @@ -47,6 +65,7 @@ interface Expect : SubjectProvider { * * @return An [Expect] for the current subject of the assertion. */ + //TODO 0.16.0 move to AssertionContainer and deprecate fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect /** @@ -56,6 +75,7 @@ interface Expect : SubjectProvider { * * @return An [Expect] for the current subject of the assertion. */ + //TODO 0.16.0 move to AssertionContainer and deprecate override fun addAssertion(assertion: Assertion): Expect @@ -69,6 +89,7 @@ interface Expect : SubjectProvider { * * @return An [Expect] for the current subject of the assertion. */ + //TODO 0.16.0 move to AssertionContainer and deprecate fun createAndAddAssertion(description: String, expected: Any?, test: (T) -> Boolean): Expect = createAndAddAssertion(Untranslatable(description), expected, test) @@ -82,6 +103,7 @@ interface Expect : SubjectProvider { * * @return An [Expect] for the current subject of the assertion. */ + //TODO 0.16.0 move to AssertionContainer and deprecate fun createAndAddAssertion(description: Translatable, expected: Any?, test: (T) -> Boolean): Expect = addAssertion(assertionBuilder.createDescriptive(this, description, expected, test)) } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpect.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpect.kt index eccbff726..076d69ff8 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpect.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpect.kt @@ -8,10 +8,7 @@ import ch.tutteli.atrium.reporting.BUG_REPORT_URL import ch.tutteli.atrium.reporting.translating.Translatable /** - * Represents an [Expect] which results due to a change of the [Expect.maybeSubject] to a feature of the subject. - * - * A change can for instance be a feature extraction such as `expect(listOf(1)).get(0)` - * but also just a feature assertion such as `expect(listOf(1)).feature { f(it::size) }` + * Represents an [Expect] which results due to a feature extraction from he subject of the expectation. */ interface FeatureExpect : Expect { diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/SubjectProvider.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/SubjectProvider.kt index 6102af1a6..315df53a0 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/SubjectProvider.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/SubjectProvider.kt @@ -5,15 +5,16 @@ import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.core.Some -//TODO remove with 0.16.0 +//TODO remove with 0.17.0 /** * Provides the subject of an [Assertion]. * - * Notice, this interface has its mere purpose to facilitate the transition from [Assert] to [Expect]. - * It might well be that we are going to remove it with 1.0.0 without previous notice. - * Hence, to be on the safe side, you should use [Expect] instead. + * Notice, this interface had its mere purpose to facilitate the transition from `Assert` to [Expect] -- `Assert` was + * removed in 0.16.0 and thus this interface will be removed with 0.17.0. */ -interface SubjectProvider : AssertionHolder { +@Suppress("DEPRECATION") +@Deprecated("Will be removed with 0.17.0 without replacement, switch to Expect or AssertionContainer") +interface SubjectProvider { /** @@ -21,4 +22,15 @@ interface SubjectProvider : AssertionHolder { * carried out. */ val maybeSubject: Option + + /** + * Adds the given [assertion] to this holder. + * + * @param assertion The assertion which will be added to this holder. + * + * @return This holder to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] in case the [Assertion] does not hold. + */ + //TODO deprecate and move to AssertionContainer -> + fun addAssertion(assertion: Assertion): SubjectProvider } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/DelegatingExpectImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/DelegatingExpectImpl.kt index 8d0e27ecb..dfdf16351 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/DelegatingExpectImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/DelegatingExpectImpl.kt @@ -3,15 +3,16 @@ package ch.tutteli.atrium.creating.impl import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.core.ExperimentalNewExpectTypes import ch.tutteli.atrium.core.Option -import ch.tutteli.atrium.creating.AssertionHolder +import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.DelegatingExpect import ch.tutteli.atrium.creating.Expect @ExperimentalNewExpectTypes -internal class DelegatingExpectImpl(private val assertionHolder: AssertionHolder, maybeSubject: Option) : +internal class DelegatingExpectImpl(private val container: AssertionContainer<*>, maybeSubject: Option) : BaseExpectImpl(maybeSubject), DelegatingExpect { + override fun addAssertion(assertion: Assertion): Expect { - assertionHolder.addAssertion(assertion) + container.addAssertion(assertion) return this } } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/ObjectFormatter.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/ObjectFormatter.kt index 8d0d57689..c95026559 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/ObjectFormatter.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/ObjectFormatter.kt @@ -1,13 +1,11 @@ package ch.tutteli.atrium.reporting -import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.translating.Translatable /** * Represents a formatter for objects. * - * Typically it formats [AssertionPlant.subject][SubjectProvider.subject]s and expected values of [Assertion]s. + * Typically it formats the subject of the formulated expectation including the expected values. */ interface ObjectFormatter { diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyGroupedAssertionCreator.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyGroupedAssertionCreator.kt index ea5f6f1a8..de74cd107 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyGroupedAssertionCreator.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyGroupedAssertionCreator.kt @@ -1,6 +1,3 @@ -//TODO remove file with 1.0.0 -@file:Suppress("DEPRECATION") - package ch.tutteli.atrium.logic.creating.iterable.contains.creators.impl import ch.tutteli.atrium.core.Option @@ -31,7 +28,11 @@ abstract class InOrderOnlyGroupedAssertionCreator( if (group.size == 1) { _logic.addSingleEntryAssertion(currentIndex, group[0], DescriptionIterableAssertion.INDEX) } else { - _logic.addSublistAssertion(currentIndex, untilIndex, group, maybeSubject.getOrElse { emptyList() }) + _logic.addSublistAssertion( + currentIndex, + untilIndex, + group, + _logic.maybeSubject.getOrElse { emptyList() }) } index = untilIndex } diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyValuesAssertionCreator.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyValuesAssertionCreator.kt index fdd02441a..2b2fc1036 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyValuesAssertionCreator.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyValuesAssertionCreator.kt @@ -1,7 +1,6 @@ package ch.tutteli.atrium.logic.creating.iterable.contains.creators.impl import ch.tutteli.atrium.assertions.AssertionGroup -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour import ch.tutteli.atrium.logic.creating.typeutils.IterableLike import ch.tutteli.atrium.reporting.translating.Translatable @@ -10,7 +9,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable * Represents a creator of a sophisticated `contains` assertions for [Iterable] where exactly the expected entries * have to appear in the specified order and where an entry is identified by an expected object (equality comparison). * - * @param T The type of the [AssertionPlant.subject][SubjectProvider.subject] for which the `contains` assertion is be build. + * @param T The type of the subject of the expectation for which the `contains` assertion is be build. * * @constructor Represents a creator of a sophisticated `contains` assertions for [Iterable] where exactly the * expected entries have to appear in the specified order and where an entry is identified by an diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultSubjectChanger.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultSubjectChanger.kt index e5cd497ad..eb7a71296 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultSubjectChanger.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/DefaultSubjectChanger.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.core.trueProvider import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.DelegatingExpect import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic.creating.transformers.SubjectChanger import ch.tutteli.atrium.reporting.translating.Translatable @@ -35,7 +36,7 @@ class DefaultSubjectChanger : SubjectChanger { // we can transform if maybeSubject is None as we have to be in an explaining like context in such a case, // even if the transformation cannot be carried out val shallTransform = - container.maybeSubject.fold(trueProvider, { expect.maybeSubject.isDefined() }) + container.maybeSubject.fold(trueProvider, { expect._logic.maybeSubject.isDefined() }) val descriptiveAssertion = assertionBuilder.descriptive .withTest(expect) { diff --git a/logic/atrium-logic-common/src/test/kotlin/ch/tutteli/atrium/logic/utils/MapArgumentsSpec.kt b/logic/atrium-logic-common/src/test/kotlin/ch/tutteli/atrium/logic/utils/MapArgumentsSpec.kt index e813416d9..c03ff2679 100644 --- a/logic/atrium-logic-common/src/test/kotlin/ch/tutteli/atrium/logic/utils/MapArgumentsSpec.kt +++ b/logic/atrium-logic-common/src/test/kotlin/ch/tutteli/atrium/logic/utils/MapArgumentsSpec.kt @@ -49,7 +49,7 @@ object MapArgumentsSpec : Spek({ val (first, others) = it(null, "b", "c") expect(first).toBe(null) expect(others[0]).notToBeNull { - maybeSubject.map { assertionCreator -> + _logic.maybeSubject.map { assertionCreator -> _logic.changeSubject.unreported { "banana" }.assertionCreator() } } diff --git a/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt b/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt index 4f4db1301..d535a1c00 100644 --- a/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt +++ b/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt @@ -1,12 +1,11 @@ package ch.tutteli.atrium.translations import ch.tutteli.atrium.assertions.DescriptiveAssertion -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable /** * Contains the [DescriptiveAssertion.description]s of the assertion functions which postulate that a - * [AssertionPlant.subject][SubjectProvider.subject] of type `T` can be transformed (usually down-casting or unboxing) to `TSub`. + * subject of type `T` can be transformed (usually down-casting or unboxing) to `TSub`. */ @Suppress("DEPRECATION") @Deprecated("Use DescriptionAnyAssertion instead; will be removed with 1.0.0") diff --git a/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt b/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt index 24ec60a09..c02650a67 100644 --- a/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt +++ b/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionTypeTransformationAssertion.kt @@ -1,12 +1,11 @@ package ch.tutteli.atrium.translations import ch.tutteli.atrium.assertions.DescriptiveAssertion -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable /** * Contains the [DescriptiveAssertion.description]s of the assertion functions which postulate that a - * [AssertionPlant.subject][SubjectProvider.subject] of type `T` can be transformed (usually down-casting or unboxing) to `TSub`. + * subject of type `T` can be transformed (usually down-casting or unboxing) to `TSub`. */ @Suppress("DEPRECATION") @Deprecated("Use DescriptionAnyAssertion instead; will be removed with 1.0.0")