From 144d35c167406a779ac4c404fb07484b3f246aff Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 2 Apr 2021 23:04:12 +0200 Subject: [PATCH] replace SubjectProvider with Expect but do not yet remove we cannot yet remove it because we still have addAssertion on Expect and if we remove it, would also have one on AssertionContainer. Two different definitions which would not work together. This also means: - deprecate addAssertion/addAssertionsCreatedBy/createAndAddAssertion in Expect, add append... to AssertionContainer --- .github/workflows/build-ubuntu.yml | 2 +- .github/workflows/build-windows.yml | 2 +- README.md | 40 +++++++---- .../atrium/api/fluent/en_GB/anyAssertions.kt | 2 +- .../api/fluent/en_GB/arrayAssertions.kt | 20 +++--- .../api/fluent/en_GB/iterableAssertions.kt | 2 +- .../atrium/api/fluent/en_GB/mapAssertions.kt | 2 +- .../api/fluent/en_GB/sequenceAssertions.kt | 4 +- .../en_GB/IterableAnyExpectationsSpec.kt | 2 +- .../en_GB/IterableNoneExpectationsSpec.kt | 2 +- .../atrium/api/fluent/en_GB/fileAssertions.kt | 2 +- .../atrium/api/infix/en_GB/anyAssertions.kt | 2 +- .../atrium/api/infix/en_GB/arrayAssertions.kt | 20 +++--- .../api/infix/en_GB/iterableAssertions.kt | 2 +- .../atrium/api/infix/en_GB/mapAssertions.kt | 2 +- .../api/infix/en_GB/sequenceAssertions.kt | 4 +- .../atrium/api/infix/en_GB/fileAssertions.kt | 2 +- build.gradle | 2 +- .../src/test/kotlin/SmokeTest.kt | 9 ++- .../src/test/kotlin/custom/SmokeSpec.kt | 7 +- .../src/test/kotlin/custom/SmokeSpec.kt | 9 ++- .../src/test/kotlin/SmokeTest.kt | 10 ++- .../src/test/kotlin/custom/SmokeSpec.kt | 9 ++- .../src/test/kotlin/custom/SmokeSpec.kt | 9 ++- .../assertions/builders/AssertionBuilder.kt | 20 +++--- .../assertions/builders/SubjectBasedOption.kt | 8 ++- .../assertions/builders/common/HoldsStep.kt | 5 +- .../builders/common/impl/HoldsStepImpl.kt | 7 +- .../atrium/assertions/builders/descriptive.kt | 6 +- .../builders/descriptiveWithFailureHint.kt | 30 +++++---- .../builders/impl/descriptive/defaultImpls.kt | 7 +- .../atrium/creating/AssertionContainer.kt | 67 ++++++++++++++----- .../atrium/creating/CollectingExpect.kt | 20 ++++++ .../ch/tutteli/atrium/creating/Expect.kt | 36 +++++++--- .../atrium/creating/SubjectProvider.kt | 4 +- .../atrium/creating/impl/BaseExpectImpl.kt | 17 +++-- .../creating/impl/CollectingExpectImpl.kt | 12 +++- .../creating/impl/DelegatingExpectImpl.kt | 3 + .../atrium/creating/impl/FeatureExpectImpl.kt | 7 +- .../atrium/creating/impl/RootExpectImpl.kt | 6 +- .../DescriptiveWithBasedOnSubjectSpec.kt | 3 +- .../reporting/text/BulletPointProviderSpec.kt | 24 +++---- .../impl/InOrderOnlyBaseAssertionCreator.kt | 11 ++- .../impl/BaseTransformationExecutionStep.kt | 2 +- .../impl/DefaultSubjectChanger.kt | 11 ++- .../atrium/logic/impl/DefaultAnyAssertions.kt | 4 +- .../impl/DefaultFloatingPointAssertions.kt | 11 +-- .../kotlin/ch/tutteli/atrium/logic/logic.kt | 2 +- .../atrium/logic/logicCharSequenceContains.kt | 2 +- .../atrium/logic/logicIterableLikeContains.kt | 4 +- .../atrium/logic/logicMapLikeContains.kt | 2 +- .../kotlin/ch/tutteli/atrium/logic/utils.kt | 8 ++- .../ch/tutteli/atrium/logic/utilsCollect.kt | 2 + .../logic/impl/DefaultBigDecimalAssertions.kt | 5 +- .../logic/impl/DefaultPathAssertions.kt | 1 - .../tutteli/atrium/specs/SubjectLessSpec.kt | 4 +- ...enceContainsContainsNotExpectationsSpec.kt | 9 +-- .../translating/TranslatorIntSpec.kt | 27 +++++--- .../kotlin/readme/examples/Between2Spec.kt | 8 ++- .../main/kotlin/readme/examples/I18nSpec.kt | 18 +++-- .../examples/OwnExpectationFunctionsSpec.kt | 11 ++- .../kotlin/readme/examples/utils/expect.kt | 3 +- .../atriumVerbs.kt | 3 +- .../ch/tutteli/atrium/api.verbs/assert.kt | 2 +- .../ch/tutteli/atrium/api.verbs/assertThat.kt | 2 +- .../ch/tutteli/atrium/api.verbs/expect.kt | 2 +- 66 files changed, 403 insertions(+), 200 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 77ef903a8..6f9c192f7 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -20,7 +20,7 @@ jobs: - name: build run: ./gradlew build - # TODO 0.17.0 or 0.18.0 re-activate scala API + # TODO 0.18.0 re-activate scala API # - name: composite build atrium-scala2 # run: ./gradlew build # working-directory: misc/tools/atrium-scala2-test diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 87d5b9f38..fc558145c 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -47,7 +47,7 @@ jobs: run: ATRIUM_ANDROID_JAR="$PWD/android-jar-cache/android.jar" ./gradlew checkDexer shell: bash - # TODO 0.17.0 or 0.18.0 re-activate scala API + # TODO 0.18.0 re-activate scala API # - name: composite build atrium-scala2 # run: ./gradlew build # working-directory: misc\tools\atrium-scala2-test diff --git a/README.md b/README.md index 8e5e5365b..8a1f15bb4 100644 --- a/README.md +++ b/README.md @@ -2000,8 +2000,10 @@ This is kind of the simplest way of defining assertion functions. Following an e ```kotlin +import ch.tutteli.atrium.logic._logic + fun Expect.isMultipleOf(base: Int) = - createAndAddAssertion("is multiple of", base) { it % base == 0 } + _logic.createAndAppendAssertion("is multiple of", base) { it % base == 0 } ``` @@ -2012,7 +2014,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L39)[Output](#ex-own-boolean-1) +↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L44)[Output](#ex-own-boolean-1) ```text expected that subject: 12 (kotlin.Int <1234789>) @@ -2048,8 +2050,10 @@ Consider the following assertion function: ```kotlin +import ch.tutteli.atrium.logic._logic + fun Expect.isEven() = - createAndAddAssertion("is", Text("an even number")) { it % 2 == 0 } + _logic.createAndAppendAssertion("is", Text("an even number")) { it % 2 == 0 } ``` @@ -2062,7 +2066,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L50)[Output](#ex-own-boolean-2) +↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L57)[Output](#ex-own-boolean-2) ```text expected that subject: 13 (kotlin.Int <1234789>) @@ -2095,8 +2099,10 @@ if you want that both are evaluated: ```kotlin +import ch.tutteli.atrium.logic._logic + fun Expect.isBetween(lowerBoundInclusive: T, upperBoundExclusive: T) = - addAssertionsCreatedBy { + _logic.appendAssertionsCreatedBy { isGreaterThanOrEqual(lowerBoundInclusive) isLessThan(upperBoundExclusive) } @@ -2161,7 +2167,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L67)[Output](#ex-own-compose-3) +↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L74)[Output](#ex-own-compose-3) ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) @@ -2195,7 +2201,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L82)[Output](#ex-own-compose-4) +↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L89)[Output](#ex-own-compose-4) ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) @@ -2237,7 +2243,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L92)[Output](#ex-own-compose-5) +↑ [Example](https://github.com/robstoll/atrium/tree/master/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt#L99)[Output](#ex-own-compose-5) ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) @@ -2458,8 +2464,13 @@ we do no longer use a `String` but a proper `Translatable`. ```kotlin -fun Expect.isMultipleOf(base: Int): Expect = - createAndAddAssertion(DescriptionIntAssertion.IS_MULTIPLE_OF, base) { it % base == 0 } +import ch.tutteli.atrium.logic.* + +fun Expect.isMultipleOf(base: Int): Expect = _logic.run { + appendAssertion( + createDescriptiveAssertion(DescriptionIntAssertion.IS_MULTIPLE_OF, base) { it % base == 0 } + ) +} enum class DescriptionIntAssertion(override val value: String) : StringBasedTranslatable { IS_MULTIPLE_OF("is multiple of") @@ -2505,8 +2516,13 @@ as second example: ```kotlin -fun Expect.isEven(): Expect = - createAndAddAssertion(DescriptionBasic.IS, DescriptionIntAssertions.EVEN) { it % 2 == 0 } +import ch.tutteli.atrium.logic.* + +fun Expect.isEven(): Expect = _logic.run { + appendAssertion( + createDescriptiveAssertion(DescriptionBasic.IS, DescriptionIntAssertions.EVEN) { it % 2 == 0 } + ) +} enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { EVEN("an even number") diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt index 3c414d984..92154113e 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt @@ -193,7 +193,7 @@ inline val Expect.and: Expect get() = this * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.deprecated.AnyAssertionSamples.and */ infix fun Expect.and(assertionCreator: Expect.() -> Unit): Expect = - addAssertionsCreatedBy(assertionCreator) + _logic.appendAssertionsCreatedBy(assertionCreator) /** * Expects that the subject of `this` expectation is not (equal to) [expected] and [otherValues]. diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt index a91a6d0f3..d4d5f2d49 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt @@ -34,7 +34,7 @@ fun Expect>.asList(): Expect> = * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.deprecated.ArrayAssertionSamples.asList */ fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Expects that the subject of `this` expectation holds all assertions the given [assertionCreator] creates for @@ -51,7 +51,7 @@ fun Expect>.asList(assertionCreator: Expect>.() -> Unit): E */ @JvmName("asListEOut") fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Turns `Expect` into `Expect>`. @@ -84,7 +84,7 @@ fun Expect.asList(): Expect> = */ @JvmName("byteArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -118,7 +118,7 @@ fun Expect.asList(): Expect> = */ @JvmName("charArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -152,7 +152,7 @@ fun Expect.asList(): Expect> = */ @JvmName("shortArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -186,7 +186,7 @@ fun Expect.asList(): Expect> = */ @JvmName("intArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -220,7 +220,7 @@ fun Expect.asList(): Expect> = */ @JvmName("longArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -254,7 +254,7 @@ fun Expect.asList(): Expect> = */ @JvmName("floatArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -288,7 +288,7 @@ fun Expect.asList(): Expect> = */ @JvmName("doubleArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -321,4 +321,4 @@ fun Expect.asList(): Expect> = */ @JvmName("boolArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt index 0e30b073e..3cc4e78f2 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt @@ -337,4 +337,4 @@ fun > Expect.asList(): Expect> = _logic.changeSubj * @since 0.14.0 */ fun > Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt index b7801b456..56e578bbd 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt @@ -236,7 +236,7 @@ fun > Expect.asEntries(): Expect> */ fun > Expect.asEntries( assertionCreator: Expect>>.() -> Unit -): Expect = apply { asEntries().addAssertionsCreatedBy(assertionCreator) } +): Expect = apply { asEntries()._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Expects that the subject of `this` expectation (a [Map]) is an empty [Map]. diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt index df28efca3..dae8baf0b 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt @@ -25,7 +25,7 @@ fun > Expect.asIterable(): Expect> = * @return an [Expect] for the subject of `this` expectation. */ fun > Expect.asIterable(assertionCreator: Expect>.() -> Unit): Expect = - apply { asIterable().addAssertionsCreatedBy(assertionCreator) } + apply { asIterable()._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Turns `Expect>` into `Expect`. @@ -51,4 +51,4 @@ fun > Expect.asList(): Expect> = _logic.changeSubj * @since 0.14.0 */ fun > Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList().addAssertionsCreatedBy(assertionCreator) } + apply { asList()._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt index d1419d96b..ccf0a6c0a 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt @@ -27,7 +27,7 @@ class IterableAnyExpectationsSpec : Spek({ "[Atrium][Builder] " ) - // TODO 0.17.0 #722 this will differ once we don't implement the same behaviour for contains and none + // TODO 0.19.0 #722 this will differ once we don't implement the same behaviour for contains and none // that's fine and we can simply remove this test here object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec( shortcutDescription to C::containsEntryShortcut, diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt index b4fde3183..37ccb8d1c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt @@ -17,7 +17,7 @@ class IterableNoneExpectationsSpec : Spek({ "[Atrium][Predicate] " ) - // TODO 0.17.0 #722 this will differ once we don't implement the same behaviour for contains and none + // TODO 0.19.0 #722 this will differ once we don't implement the same behaviour for contains and none // that's fine and we can simply remove this test here object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableNoneExpectationsSpec( functionDescription to C::containsNotFun, diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fileAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fileAssertions.kt index 4a17eed18..020dddd2f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fileAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fileAssertions.kt @@ -36,4 +36,4 @@ fun Expect.asPath(): Expect = * @since 0.9.0 */ fun Expect.asPath(assertionCreator: Expect.() -> Unit): Expect = - apply { asPath().addAssertionsCreatedBy(assertionCreator) } + apply { asPath()._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt index f90263a85..b9eabca96 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt @@ -194,7 +194,7 @@ inline infix fun Expect.and(@Suppress("UNUSED_PARAMETER") o: o): Expect Expect.and(assertionCreator: Expect.() -> Unit): Expect = - addAssertionsCreatedBy(assertionCreator) + _logic.appendAssertionsCreatedBy(assertionCreator) /** * Inline property referring actually to `this` and allows to write infix assertions within an assertion group block diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt index 5565530b6..08cf186fe 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt @@ -34,7 +34,7 @@ infix fun Expect>.asList(@Suppress("UNUSED_PARAMETER") o: o * @since 0.12.0 */ infix fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Expects that the subject of `this` expectation holds all assertions the given [assertionCreator] creates for @@ -51,7 +51,7 @@ infix fun Expect>.asList(assertionCreator: Expect>.() -> Un */ @JvmName("asListEOut") infix fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Turns `Expect` into `Expect>`. @@ -84,7 +84,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -118,7 +118,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -152,7 +152,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect< */ @JvmName("shortArrAsList") infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -186,7 +186,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect
  • .asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -220,7 +220,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -254,7 +254,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect< */ @JvmName("floatArrAsList") infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -288,7 +288,7 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect */ @JvmName("doubleArrAsList") infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** @@ -322,4 +322,4 @@ infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expec */ @JvmName("boolArrAsList") infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt index 8efada6c6..6eee6d1eb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt @@ -385,4 +385,4 @@ infix fun > Expect.asList( * @since 0.14.0 */ infix fun > Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index 454617956..552d17516 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -292,7 +292,7 @@ infix fun > Expect.asEntries( */ infix fun > Expect.asEntries( assertionCreator: Expect>>.() -> Unit -): Expect = apply { asEntries(o).addAssertionsCreatedBy(assertionCreator) } +): Expect = apply { asEntries(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Expects that the subject of `this` expectation (a [Map]) is an empty [Map]. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt index b989727c9..06919ddb0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt @@ -26,7 +26,7 @@ infix fun > Expect.asIterable( * @return an [Expect] for the subject of `this` expectation. */ infix fun > Expect.asIterable(assertionCreator: Expect>.() -> Unit): Expect = - apply { asIterable(o).addAssertionsCreatedBy(assertionCreator) } + apply { asIterable(o)._logic.appendAssertionsCreatedBy(assertionCreator) } /** * Turns `Expect>` into `Expect`. @@ -54,4 +54,4 @@ infix fun > Expect.asList( * @since 0.14.0 */ infix fun > Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = - apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + apply { asList(o)._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fileAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fileAssertions.kt index 58833c508..8f3ad5b5b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fileAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fileAssertions.kt @@ -36,4 +36,4 @@ infix fun Expect.asPath(@Suppress("UNUSED_PARAMETER") o: o): Expec * @since 0.12.0 */ infix fun Expect.asPath(assertionCreator: Expect.() -> Unit): Expect = - apply { asPath(o).addAssertionsCreatedBy(assertionCreator) } + apply { asPath(o)._logic.appendAssertionsCreatedBy(assertionCreator) } diff --git a/build.gradle b/build.gradle index 6431be3c3..655738ae4 100644 --- a/build.gradle +++ b/build.gradle @@ -334,7 +334,7 @@ def createJsTestTask(String... subprojectNames) { from compileKotlin2Js.destinationDir prefixedProject('verbs-internal-js').afterEvaluate { - // TODO 0.17.0 or 0.18.0, check if still required with the new Kotlin MPP plugin + // TODO 0.18.0, check if still required with the new Kotlin MPP plugin configurations.testRuntimeClasspath.allDependencies.withType(ProjectDependency).each { dependsOn(it.dependencyProject.assemble) } 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 2806a5390..aa74ec175 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 @@ -9,6 +9,7 @@ import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic._logicAppend import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text @@ -26,6 +27,7 @@ class SmokeTest { @Test fun assertionFunctionWithoutI18nCanBeUsed() { assertThat(2).isEven() + assertThat(1).isOdd() } @Test @@ -106,8 +108,11 @@ class SmokeTest { } } -//TODO 0.17.0 also add test case for using the string overload once we have createAndAppend -fun Expect.isEven() = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 } +fun Expect.isEven() = + _logic.createAndAppendAssertion("is", Text("an even number")) { it % 2 == 0 } + +fun Expect.isOdd() = + _logic.appendAssertion(_logic.createDescriptiveAssertion(IS, Text("an odd number")) { it % 2 == 1 }) fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } 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 557992a3f..d7dd7d31f 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 @@ -7,6 +7,7 @@ import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic._logicAppend import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text @@ -26,6 +27,7 @@ object SmokeSpec : Spek({ test("see if own assertion function without i18n can be used") { assertThat(2).isEven() + assertThat(1).isOdd() } test("see if own assertion function with i18n can be used") { @@ -34,7 +36,10 @@ object SmokeSpec : Spek({ }) fun Expect.isEven() = - createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } + _logic.createAndAppendAssertion("is", Text("an even number")) { it % 2 == 0 } + +fun Expect.isOdd() = + _logic.appendAssertion(_logic.createDescriptiveAssertion(DescriptionBasic.IS, Text("an odd number")) { it % 2 == 1 }) fun Expect.isMultipleOf(base: Int) = _logicAppend { isMultipleOf(base) } 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 1f69efc91..2b61e733f 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 @@ -11,6 +11,7 @@ import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic._logicAppend import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text @@ -29,6 +30,7 @@ object SmokeSpec : Spek({ test("see if own assertion function without i18n can be used") { expect(2).isEven() + expect(1).isOdd() } test("see if own assertion function with i18n can be used") { @@ -36,8 +38,11 @@ object SmokeSpec : Spek({ } }) -fun Expect.isEven(): Expect = - createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } +fun Expect.isEven() = + _logic.createAndAppendAssertion("is", Text("an even number")) { it % 2 == 0 } + +fun Expect.isOdd() = + _logic.appendAssertion(_logic.createDescriptiveAssertion(DescriptionBasic.IS, Text("an odd number")) { it % 2 == 1 }) fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } 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 772f6aedc..5adadc943 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 @@ -3,6 +3,7 @@ import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic._logicAppend import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text @@ -20,6 +21,7 @@ class SmokeTest { @Test fun assertionFunctionWithoutI18nCanBeUsed() { assertThat(2) tobe even + assertThat(1) tobe odd } @Test @@ -53,10 +55,14 @@ class SmokeTest { @Suppress("ClassName") object even +@Suppress("ClassName") +object odd -//TODO 0.17.0 also add test case for using the string overload once we have createAndAppend infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = - createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 } + _logic.appendAssertion(_logic.createDescriptiveAssertion(IS, Text("an even number")) { it % 2 == 0 }) + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") odd: odd) = + _logic.appendAssertion(_logic.createDescriptiveAssertion(IS, Text("an odd number")) { it % 2 == 1}) infix fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } 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 f368a89c8..9beb777a2 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 @@ -5,6 +5,7 @@ import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic._logicAppend import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text @@ -19,6 +20,7 @@ object SmokeSpec : Spek({ test("see if own assertion function without i18n can be used") { assertThat(2) tobe even + assertThat(1) tobe odd } test("see if own assertion function with i18n can be used") { @@ -28,9 +30,14 @@ object SmokeSpec : Spek({ @Suppress("ClassName") object even +@Suppress("ClassName") +object odd infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = - createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } + _logic.appendAssertion(_logic.createDescriptiveAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 }) + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") odd: odd) = + _logic.appendAssertion(_logic.createDescriptiveAssertion(DescriptionBasic.IS, Text("an odd number")) { it % 2 == 1 }) infix fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } 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 943db7ae7..b56860b67 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 @@ -12,6 +12,7 @@ import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic._logicAppend import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.reporting.Text @@ -30,6 +31,7 @@ object SmokeSpec : Spek({ test("see if own assertion function without i18n can be used") { expect(2) tobe even + expect(1) tobe odd } test("see if own assertion function with i18n can be used") { @@ -39,9 +41,14 @@ object SmokeSpec : Spek({ @Suppress("ClassName") object even +@Suppress("ClassName") +object odd infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = - createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 } + _logic.appendAssertion(_logic.createDescriptiveAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 }) + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") odd: odd) = + _logic.appendAssertion(_logic.createDescriptiveAssertion(DescriptionBasic.IS, Text("an odd number")) { it % 2 == 1 }) infix fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } 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 2e378e6c5..8d3e99dd4 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 @@ -163,22 +163,22 @@ interface AssertionBuilder { * @param representation The representation of the expected outcome. * @param test The test which checks whether the assertion holds. */ - //TODO remove with 0.17.0 + //TODO remove with 0.18.0 @Suppress("DEPRECATION") @Deprecated( - "Use _logic.createDescriptive instead; will be removed with 0.17.0", + "Use _logic.createDescriptive instead; will be removed with 0.18.0", ReplaceWith( - "container.createDescriptiveAssertion", + "container.createDescriptiveAssertion(expect, description, represetnation, test)", "ch.tutteli.atrium.logic._logic", "ch.tutteli.atrium.logic.createDescriptiveAssertion" ) ) fun createDescriptive( - subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, description: String, representation: Any?, test: (T) -> Boolean - ): DescriptiveAssertion = createDescriptive(subjectProvider, Untranslatable(description), representation, test) + ): DescriptiveAssertion = createDescriptive(expect, Untranslatable(description), representation, test) /** * Creates a [DescriptiveAssertion] based on the [description], [representation] and [test] as well as the @@ -201,23 +201,23 @@ interface AssertionBuilder { * @param representation The representation of the expected outcome. * @param test The test which checks whether the assertion holds. */ - //TODO remove with 0.17.0 + //TODO remove with 0.18.0 @Deprecated( - "Use extension AssertionContainer.createDescriptiveAssertion instead - e.g. _logic.createDescriptiveAssertion; will be removed with 0.17.0", + "Use extension AssertionContainer.createDescriptiveAssertion instead - e.g. _logic.createDescriptiveAssertion; will be removed with 0.18.0", ReplaceWith( - "container.createDescriptiveAssertion", + "container.createDescriptiveAssertion(expect, description, represetantion, test)", "ch.tutteli.atrium.logic._logic", "ch.tutteli.atrium.logic.createDescriptiveAssertion" ) ) fun createDescriptive( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, description: Translatable, representation: Any?, test: (T) -> Boolean ): DescriptiveAssertion = descriptive - .withTest(subjectProvider, test) + .withTest(expect, test) .withDescriptionAndRepresentation(description, representation) .build() } 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 b9bb6cce7..daa935d86 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,5 +1,8 @@ package ch.tutteli.atrium.assertions.builders +import ch.tutteli.atrium.creating.AssertionContainer +import ch.tutteli.atrium.creating.Expect + /** * Contract for sub option steps which are based on a defined or absent subject of the expectation. */ @@ -40,12 +43,13 @@ interface SubjectBasedOption { companion object { @Suppress("DEPRECATION") operator fun > invoke( - subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, subStep: PO.() -> Pair<() -> R, (T) -> R>, presentOptionFactory: () -> PO ): R { val (ifAbsent, ifPresent) = presentOptionFactory().subStep() - return subjectProvider.maybeSubject.fold(ifAbsent, ifPresent) + @Suppress("UNCHECKED_CAST") + return (expect as AssertionContainer).maybeSubject.fold(ifAbsent, ifPresent) } } } 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 c6a806516..30a00354b 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,6 +2,7 @@ package ch.tutteli.atrium.assertions.builders.common import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.RepresentationOnlyAssertion +import ch.tutteli.atrium.creating.Expect /** * Step which allows to specify [RepresentationOnlyAssertion.holds]. @@ -34,9 +35,9 @@ interface HoldsStep { * @return `true` in case [SubjectProvider.maybeSubject] is None or the result of [test] passing the subject. */ //TODO if we introduce Record or something else as replacement for Assertion then not but if we keep Assertion - // then move to logic and expect AssertionContainer with 0.16.0 + // then move to logic and expect ProofContainer with 0.18.0 fun withTest( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, 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 c96ce53bd..1faaed775 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,6 +2,8 @@ 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.AssertionContainer +import ch.tutteli.atrium.creating.Expect internal abstract class HoldsStepImpl : HoldsStep { //TODO use falseProvider https://youtrack.jetbrains.com/issue/KT-27736 @@ -9,8 +11,9 @@ internal abstract class HoldsStepImpl : HoldsStep { //TODO use trueProvider https://youtrack.jetbrains.com/issue/KT-27736 override val holding: R = withTest { true } - override fun withTest(@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, test: (T) -> Boolean): R = withTest { - subjectProvider.maybeSubject.fold(falseProvider, test) + override fun withTest(expect: Expect, test: (T) -> Boolean): R = withTest { + @Suppress("UNCHECKED_CAST") + (expect as AssertionContainer).maybeSubject.fold(falseProvider, test) } final override fun withTest(test: () -> Boolean): R = createNextStep(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 4973ccdf5..a35021163 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,6 +5,7 @@ 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.Expect import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Untranslatable @@ -34,16 +35,15 @@ interface Descriptive { fun withTest(test: () -> Boolean): DescriptionOption /** - * Uses the given [test] as [DescriptiveAssertion.holds] based on the subject provided by [subjectProvider]. + * Uses the given [test] as [DescriptiveAssertion.holds] based on the subject provided by [expect]. * * Notice, this function might change its signature with 1.0.0 to something like * ``` * fun withTest(expect: Expect, test: (T) -> Boolean): DescriptionOption * ``` */ - //TODO 0.18.0: don't use SubjectProvider in the new ProofBuilder but ProofContainer instead fun withTest( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, test: (T) -> Boolean ): DescriptionOption 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 6122741ec..41d94acc7 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,6 +4,8 @@ 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.AssertionContainer +import ch.tutteli.atrium.creating.Expect 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 @@ -33,12 +35,12 @@ fun Descriptive.DescriptionOption.withFailureHint( * on the subject of the expectation. */ //TODO if we introduce Record or something else as replacement for Assertion then not but if we keep Assertion -// then move to logic and expect AssertionContainer with 0.16.0 +// then move to logic and expect ProofContainer with 0.18.0 fun Descriptive.DescriptionOption.withFailureHintBasedOnDefinedSubject( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, failureHintFactory: (T) -> Assertion ): Descriptive.DescriptionOption { - return withFailureHintBasedOnSubject(subjectProvider) { + return withFailureHintBasedOnSubject(expect) { ifDefined(failureHintFactory) .ifAbsent { assertionBuilder.explanatoryGroup @@ -46,7 +48,7 @@ fun Descriptive.DescriptionOption.withFailureHintBase .withExplanatoryAssertion(Text(SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG)) .build() } - }.showOnlyIfSubjectDefined(subjectProvider) + }.showOnlyIfSubjectDefined(expect) } /** @@ -54,15 +56,15 @@ fun Descriptive.DescriptionOption.withFailureHintBase * (which is based on the subject of the expectation) * which might be shown if the [Descriptive.DescriptionOption.test] fails. * - * You can use [withFailureHint] which does not expect a [subjectProvider] in case your [DescriptiveAssertion] is not based + * You can use [withFailureHint] which does not expect a [expect] in case your [DescriptiveAssertion] is not based * on the subject of the expectation. */ fun Descriptive.DescriptionOption.withFailureHintBasedOnSubject( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, failureHintSubStep: DescriptiveAssertionWithFailureHint.FailureHintSubjectDefinedOption.() -> Pair<() -> Assertion, (T) -> Assertion> ): DescriptiveAssertionWithFailureHint.ShowOption = withFailureHint { SubjectBasedOption( - subjectProvider, + expect, failureHintSubStep, DescriptiveAssertionWithFailureHint.FailureHintSubjectDefinedOption.Companion::create ) @@ -117,31 +119,31 @@ interface DescriptiveAssertionWithFailureHint { * Defines that the failure hint shall be shown in any case as long as the subject is defined */ fun showOnlyIfSubjectDefined( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider + expect: Expect ): Descriptive.DescriptionOption = - showOnlyIf { subjectProvider.maybeSubject.isDefined() } + showOnlyIf { (expect as AssertionContainer<*>).maybeSubject.isDefined() } /** * Defines that the failure hint shall be shown if the subject is defined and the given [predicate] holds for it */ fun showBasedOnDefinedSubjectOnlyIf( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, predicate: (T) -> Boolean ): Descriptive.DescriptionOption = - showBasedOnSubjectOnlyIf(subjectProvider) { ifDefined { predicate(it) } ifAbsent { false } } + showBasedOnSubjectOnlyIf(expect) { ifDefined { predicate(it) } ifAbsent { false } } /** * Defines that the failure hint shall only be shown based on a predicate influenced by the * subject of the expectation. * - * You can use the other overload without [subjectProvider] in case the predicate is not based on the subject + * You can use the other overload without [expect] in case the predicate is not based on the subject * of the assertion. */ fun showBasedOnSubjectOnlyIf( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, showSubStep: ShowSubjectDefinedOption.() -> Pair<() -> Boolean, (T) -> Boolean> ): Descriptive.DescriptionOption = showOnlyIf { - SubjectBasedOption(subjectProvider, showSubStep, ShowSubjectDefinedOption.Companion::create) + SubjectBasedOption(expect, showSubStep, ShowSubjectDefinedOption.Companion::create) } companion object { 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 4be50dd76..93e81514f 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,6 +3,8 @@ 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.AssertionContainer +import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable @@ -21,10 +23,11 @@ internal object HoldsOptionImpl : Descriptive.HoldsOption { Descriptive.DescriptionOption.create(test, Descriptive.FinalStep.Companion::create) override fun withTest( - @Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider, + expect: Expect, test: (T) -> Boolean ): Descriptive.DescriptionOption = withTest { - subjectProvider.maybeSubject.fold(falseProvider, test) + @Suppress("UNCHECKED_CAST") + (expect as AssertionContainer).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 ec54ad019..7227509f4 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 @@ -1,10 +1,13 @@ 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.ExperimentalNewExpectTypes import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.core.Some +import ch.tutteli.atrium.reporting.translating.Untranslatable import kotlin.reflect.KClass /** @@ -13,16 +16,15 @@ import kotlin.reflect.KClass * In contrast to expectation functions 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 will be removed with 0.17.0. - * * @param T The type of the subject of `this` expectation. */ -//TODO 0.17.0 introduce ProofContainer +//TODO 0.18.0 introduce ProofContainer 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. */ + //TODO 0.18.0 remove override once we no longer extend SubjectProvider override val maybeSubject: Option /** @@ -40,18 +42,49 @@ interface AssertionContainer : @kotlin.Suppress("DEPRECATION") SubjectProvide @ExperimentalComponentFactoryContainer val components: ComponentFactoryContainer -// /** -// * Appends the given [assertion] to this container and returns an [Expect] which includes it. -// * -// * Whether the returned [Expect] is the same as the initial one is up to the implementation (i.e. if a mutable -// * structure is used or an immutable). Atrium strives for an immutable data structure in the long run and will -// * little by little refactor the code accordingly. -// * -// * @param assertion The assertion which will be appended to this container. -// * -// * @return an [Expect] for the subject of `this` expectation. -// * -// * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately evaluated. -// */ -// fun append(assertion: Assertion): Expect + /** + * Appends the given [assertion] to this container and returns an [Expect] which includes it. + * + * Whether the returned [Expect] is the same as the initial one is up to the implementation (i.e. if a mutable + * structure is used or an immutable). Atrium strives for an immutable data structure in the long run and will + * little by little refactor the code accordingly. + * + * @param assertion The assertion which will be appended to this container. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately evaluated. + */ + fun appendAssertion(assertion: Assertion): Expect + + /** + * Appends the [Assertion]s the given [assertionCreator] creates to this container and + * returns an [Expect] which includes them. + * + * Whether the returned [Expect] is the same as the initial one is up to the implementation (i.e. if a mutable + * structure is used or an immutable). Atrium strives for an immutable data structure in the long run and will + * little by little refactor the code accordingly. + * + * @param assertionCreator The lambda which will create assertions. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately evaluated. + */ + fun appendAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect + + /** + * Creates a [DescriptiveAssertion] based on the given [description], [expected] and [test] + * and [appends][appendAssertion] it to the container. + * + * @param description The description of the assertion, e.g., `is less than`. + * @param expected The expected value, e.g., `5` + * @param test Indicates whether the assertion holds or fails. + * + * @return an [Expect] for the subject of `this` expectation. + */ + //TODO remove SUPPRESS with 0.18.0 + @Suppress("UNCHECKED_CAST", "DEPRECATION") + fun createAndAppendAssertion(description: String, expected: Any?, test: (T) -> Boolean): Expect = + appendAssertion(assertionBuilder.createDescriptive(this as Expect, Untranslatable(description),expected, test)) } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingExpect.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingExpect.kt index 5a2413d4d..35134cd04 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingExpect.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingExpect.kt @@ -21,8 +21,28 @@ interface CollectingExpect : Expect { */ fun getAssertions(): List + @Deprecated( + "use appendAssertionsCreatedBy; will be removed with 0.18.0", + ReplaceWith("this.appendAssertionsCreatedBy(assertionCreator)") + ) override fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): CollectingExpect + /** + * Appends the [Assertion]s the given [assertionCreator] creates to this container and + * returns an [Expect] which includes them. + * + * Whether the returned [Expect] is the same as the initial one is up to the implementation (i.e. if a mutable + * structure is used or an immutable). Atrium strives for an immutable data structure in the long run and will + * little by little refactor the code accordingly. + * + * @param assertionCreator The lambda which will create assertions. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately evaluated. + */ + fun appendAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): CollectingExpect + companion object { @Suppress( "DEPRECATION", 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 a768bb63c..cab93201e 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 @@ -25,8 +25,8 @@ annotation class ExpectMarker * * See https://github.com/robstoll/atrium-roadmap/wiki/Requirements#personas for more information about the personas. */ -interface ExpectInternal : Expect, AssertionContainer{ - //TODO remove with 0.17.0 no longer necessary once it only exist in AssertionContainer +interface ExpectInternal : Expect, AssertionContainer { + //TODO remove with 0.18.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. @@ -38,8 +38,6 @@ interface ExpectInternal : Expect, AssertionContainer{ /** * 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 be removed with 0.17.0. - * * @param T The type of the subject of `this` expectation. */ @Suppress("DEPRECATION") @@ -47,7 +45,7 @@ interface ExpectInternal : Expect, AssertionContainer{ interface Expect : @kotlin.Suppress("DEPRECATION") SubjectProvider { @Deprecated( - "use _logic.maybeSubject will be removed with 0.17.0", + "use _logic.maybeSubject; will be removed with 0.18.0", ReplaceWith("this._logic.maybeSubject", "ch.tutteli.atrium.logic._logic") ) override val maybeSubject: Option @@ -64,7 +62,10 @@ interface Expect : @kotlin.Suppress("DEPRECATION") SubjectProvider { * * @return an [Expect] for the subject of `this` expectation. */ - //TODO 0.17.0 move to ProofContainer and deprecate + @Deprecated( + "use _logic.appendAssertionsCreatedBy; will be removed with 0.18.0", + ReplaceWith("this._logic.appendAssertionsCreatedBy(assertionCreator)", "ch.tutteli.atrium.logic._logic") + ) fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect /** @@ -74,10 +75,12 @@ interface Expect : @kotlin.Suppress("DEPRECATION") SubjectProvider { * * @return an [Expect] for the subject of `this` expectation. */ - //TODO 0.17.0 move to ProofContainer and deprecate + @Deprecated( + "use _logic.appendAssertion; will be removed with 0.18.0", + ReplaceWith("this._logic.appendAssertion(assertion)", "ch.tutteli.atrium.logic._logic") + ) override fun addAssertion(assertion: Assertion): Expect - /** * Creates a [DescriptiveAssertion] based on the given [description], [expected] and [test] * and [adds][addAssertion] it to the container. @@ -88,7 +91,13 @@ interface Expect : @kotlin.Suppress("DEPRECATION") SubjectProvider { * * @return an [Expect] for the subject of `this` expectation. */ - //TODO 0.17.0 move to ProofContainer and deprecate + @Deprecated( + "use _logic.createAndAppendAssertion; will be removed with 0.18.0", + ReplaceWith( + "this._logic.createAndAppendAssertion(description, expected, test)", + "ch.tutteli.atrium.logic._logic" + ) + ) fun createAndAddAssertion(description: String, expected: Any?, test: (T) -> Boolean): Expect = createAndAddAssertion(Untranslatable(description), expected, test) @@ -102,7 +111,14 @@ interface Expect : @kotlin.Suppress("DEPRECATION") SubjectProvider { * * @return an [Expect] for the subject of `this` expectation. */ - //TODO 0.17.0 move to ProofContainer and deprecate + @Deprecated( + "use _logic.createAndAppendAssertion; will be removed with 0.18.0", + ReplaceWith( + "this._logic.appendAssertion(this._logic.createDescriptiveAssertion(description, expected, test))", + "ch.tutteli.atrium.logic._logic", + "ch.tutteli.atrium.logic.createDescriptiveAssertion" + ) + ) 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/SubjectProvider.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/SubjectProvider.kt index 315df53a0..8ca170402 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,7 +5,7 @@ import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.core.Some -//TODO remove with 0.17.0 +//TODO remove with 0.18.0 /** * Provides the subject of an [Assertion]. * @@ -13,7 +13,7 @@ import ch.tutteli.atrium.core.Some * removed in 0.16.0 and thus this interface will be removed with 0.17.0. */ @Suppress("DEPRECATION") -@Deprecated("Will be removed with 0.17.0 without replacement, switch to Expect or AssertionContainer") +@Deprecated("Will be removed with 0.18.0 without replacement, switch to Expect or AssertionContainer") interface SubjectProvider { diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt index 842770e33..be7232402 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/BaseExpectImpl.kt @@ -18,7 +18,7 @@ abstract class BaseExpectImpl( ) : ExpectInternal { - // TODO 0.17.0 not every expect should have an own implFactories but only the root, + // TODO 0.18.0 not every expect should have an own implFactories but only the root, // maybe also FeatureExpect but surely not DelegatingExpect or CollectingExpect private val implFactories: MutableMap, (() -> Nothing) -> () -> Any> = mutableMapOf() @@ -36,23 +36,28 @@ abstract class BaseExpectImpl( implFactories[kClass] = implFactory } - //TODO 0.17.0 move to RootExpectOptions? + //TODO 0.18.0 move to RootExpectOptions? inline fun withImplFactory(noinline implFactory: (oldFactory: () -> I) -> () -> I) { registerImpl(I::class, implFactory) } - override fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect { + //TODO remove with 0.18.0 + override fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect = + appendAssertionsCreatedBy(assertionCreator) + + override fun appendAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect { val assertions = CollectingExpect(maybeSubject, components) - .addAssertionsCreatedBy(assertionCreator) + .appendAssertionsCreatedBy(assertionCreator) .getAssertions() return addAssertions(assertions) } + protected fun addAssertions(assertions: List): Expect { return when (assertions.size) { 0 -> this - 1 -> addAssertion(assertions.first()) - else -> addAssertion(assertionBuilder.invisibleGroup.withAssertions(assertions).build()) + 1 -> appendAssertion(assertions.first()) + else -> appendAssertion(assertionBuilder.invisibleGroup.withAssertions(assertions).build()) } } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/CollectingExpectImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/CollectingExpectImpl.kt index a1d93456d..e2f164503 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/CollectingExpectImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/CollectingExpectImpl.kt @@ -16,10 +16,15 @@ internal class CollectingExpectImpl( override fun getAssertions(): List = assertions.toList() - override fun addAssertion(assertion: Assertion): Expect = + override fun addAssertion(assertion: Assertion): Expect = appendAssertion(assertion) + + override fun appendAssertion(assertion: Assertion): Expect = apply { assertions.add(assertion) } - override fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): CollectingExpect { + override fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): CollectingExpect = + appendAssertionsCreatedBy(assertionCreator) + + override fun appendAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): CollectingExpect { // in case we run into performance problems, the code below is certainly not ideal val allAssertions = mutableListOf() allAssertions.addAll(getAssertions()) @@ -51,7 +56,8 @@ internal class CollectingExpectImpl( .build() ) } - allAssertions.forEach { addAssertion(it) } + allAssertions.forEach { appendAssertion(it) } return this } + } 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 5eefa284e..9affd2193 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 @@ -14,5 +14,8 @@ internal class DelegatingExpectImpl(private val container: AssertionContainer get() = container.components override fun addAssertion(assertion: Assertion): Expect = + appendAssertion(assertion) + + override fun appendAssertion(assertion: Assertion): Expect = apply { container.addAssertion(assertion) } } diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/FeatureExpectImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/FeatureExpectImpl.kt index bf1a5c3f3..ee29e3b17 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/FeatureExpectImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/FeatureExpectImpl.kt @@ -57,7 +57,10 @@ internal class FeatureExpectImpl( get() = (previousExpect as AssertionContainer<*>).components - override fun addAssertion(assertion: Assertion): Expect { + override fun addAssertion(assertion: Assertion): Expect = + appendAssertion(assertion) + + override fun appendAssertion(assertion: Assertion): Expect { assertions.add(assertion) //Would be nice if we don't have to add it immediately to the previousExpect but only: //if (!assertion.holds()) { @@ -73,7 +76,7 @@ internal class FeatureExpectImpl( // //However, for this to work we would need to know when no more assertion is defined. This would be possible //for CollectingExpectImpl - previousExpect.addAssertion( + (previousExpect as AssertionContainer<*>).appendAssertion( assertionBuilder.feature .withDescriptionAndRepresentation(description, representation) .withAssertions(ArrayList(assertions)) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/RootExpectImpl.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/RootExpectImpl.kt index 3210bf72f..4fded7ec4 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/RootExpectImpl.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/impl/RootExpectImpl.kt @@ -54,7 +54,10 @@ internal class RootExpectImpl( */ private val assertions: MutableList = mutableListOf() - override fun addAssertion(assertion: Assertion): Expect { + override fun addAssertion(assertion: Assertion): Expect = + appendAssertion(assertion) + + override fun appendAssertion(assertion: Assertion): Expect { assertions.add(assertion) if (!assertion.holds()) { val assertionGroup = assertionBuilder.root @@ -71,4 +74,5 @@ internal class RootExpectImpl( return this } + } diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/assertions/builders/DescriptiveWithBasedOnSubjectSpec.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/assertions/builders/DescriptiveWithBasedOnSubjectSpec.kt index 995348d09..3212c7eb3 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/assertions/builders/DescriptiveWithBasedOnSubjectSpec.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/assertions/builders/DescriptiveWithBasedOnSubjectSpec.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.assertions.builders import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.core.falseProvider import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic.utils.expectLambda import ch.tutteli.atrium.specs.SubjectLessSpec import org.spekframework.spek2.Spek @@ -10,7 +11,7 @@ import org.spekframework.spek2.Spek class DescriptiveWithBasedOnSubjectSpec : Spek({ fun addDescriptive(f: (Expect, Descriptive.HoldsOption) -> Assertion) = expectLambda { - addAssertion(f(this, assertionBuilder.descriptive)) + _logic.appendAssertion(f(this, assertionBuilder.descriptive)) } include(object : SubjectLessSpec("", diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/text/BulletPointProviderSpec.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/text/BulletPointProviderSpec.kt index d95776bf4..a3196d9d4 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/text/BulletPointProviderSpec.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/text/BulletPointProviderSpec.kt @@ -33,13 +33,13 @@ class BulletPointProviderSpec : Spek({ expectWitNewBulletPoint(p, "a") toBe "b" }), ListAssertionGroupType::class to ("- " to { p -> - expectWitNewBulletPoint(p, "a").addAssertionsCreatedBy { - addAssertion( + expectWitNewBulletPoint(p, "a")._logic.appendAssertionsCreatedBy(fun Expect.() { + _logic.appendAssertion( assertionBuilder.list .withDescriptionAndEmptyRepresentation("hello") .withAssertion(_logic.toBe("b")).build() ) - } + }) }), FeatureAssertionGroupType::class to (">> " to { p -> expectWitNewBulletPoint(p, "a") feature { f("m", it.length) } toBe 2 @@ -54,37 +54,37 @@ class BulletPointProviderSpec : Spek({ expectWitNewBulletPoint(p, listOf(1)) containsExactly 2 }), ExplanatoryAssertionGroupType::class to (">> " to { p -> - expectWitNewBulletPoint(p, "a").addAssertionsCreatedBy { - addAssertion( + expectWitNewBulletPoint(p, "a")._logic.appendAssertionsCreatedBy(fun Expect.() { + _logic.appendAssertion( assertionBuilder.explanatoryGroup .withDefaultType .withAssertion(_logic.toBe("b")) .failing .build() ) - } + }) }), WarningAssertionGroupType::class to ("(!) " to { p -> - expectWitNewBulletPoint(p, "a").addAssertionsCreatedBy { - addAssertion( + expectWitNewBulletPoint(p, "a")._logic.appendAssertionsCreatedBy(fun Expect.() { + _logic.appendAssertion( assertionBuilder.explanatoryGroup .withWarningType .withAssertion(_logic.toBe("b")) .failing .build() ) - } + }) }), InformationAssertionGroupType::class to ("(i) " to { p -> - expectWitNewBulletPoint(p, "a").addAssertionsCreatedBy { - addAssertion( + expectWitNewBulletPoint(p, "a")._logic.appendAssertionsCreatedBy(fun Expect.() { + _logic.appendAssertion( assertionBuilder.explanatoryGroup .withInformationType(false) .withAssertion(_logic.toBe("b")) .failing .build() ) - } + }) }) ) diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyBaseAssertionCreator.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyBaseAssertionCreator.kt index f733a3b0c..1e72338a2 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyBaseAssertionCreator.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/creators/impl/InOrderOnlyBaseAssertionCreator.kt @@ -46,7 +46,14 @@ abstract class InOrderOnlyBaseAssertionCreator( { emptyList() } ) if (list.size > index) { - addAssertion(createAdditionalElementsAssertion(container, index, list, remainingList.iterator())) + _logic.appendAssertion( + createAdditionalElementsAssertion( + container, + index, + list, + remainingList.iterator() + ) + ) } } val description = searchBehaviour.decorateDescription(DescriptionIterableAssertion.CONTAINS) @@ -74,7 +81,7 @@ abstract class InOrderOnlyBaseAssertionCreator( itr: Iterator ): Assertion { return container.collectBasedOnSubject(Some(iterableAsList)) { - addAssertion(LazyThreadUnsafeAssertionGroup { + _logic.appendAssertion(LazyThreadUnsafeAssertionGroup { val additionalEntries = itr.mapRemainingWithCounter { counter, it -> val description = TranslatableWithArgs( DescriptionIterableAssertion.ELEMENT_WITH_INDEX, diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/BaseTransformationExecutionStep.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/BaseTransformationExecutionStep.kt index 42b9a1be0..64d986e6f 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/BaseTransformationExecutionStep.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/transformers/impl/BaseTransformationExecutionStep.kt @@ -37,7 +37,7 @@ abstract class BaseTransformationExecutionStep>( * @return an [Expect] for the subject of this expectation. */ final override fun collectAndAppend(assertionCreator: Expect.() -> Unit): Expect = - container.toExpect().addAssertion(collect(assertionCreator)) + container.appendAssertion(collect(assertionCreator)) /** * Finishes the transformation process by collecting the assertions the given [assertionCreator] creates 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 eb7a71296..9d8cbbb52 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 @@ -46,15 +46,14 @@ class DefaultSubjectChanger : SubjectChanger { .withDescriptionAndRepresentation(description, representation) .build() - if (shallTransform) { - expect.addAssertion(descriptiveAssertion) - maybeSubAssertions.fold({ /* nothing to do */ }) { assertionCreator -> - expect.addAssertionsCreatedBy(assertionCreator) + return if (shallTransform) { + val e = expect._logic.appendAssertion(descriptiveAssertion) + maybeSubAssertions.fold({ e }) { assertionCreator -> + expect._logic.appendAssertionsCreatedBy(assertionCreator) } } else { val assertion = failureHandler.createAssertion(container, descriptiveAssertion, maybeSubAssertions) - expect.addAssertion(assertion) + expect._logic.appendAssertion(assertion) } - return expect } } diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt index eb3fd5f47..be8c2ab02 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultAnyAssertions.kt @@ -36,7 +36,7 @@ class DefaultAnyAssertions : AnyAssertions { } else { val collectSubject = container.maybeSubject.flatMap { if (it != null) Some(it) else None } val assertion = container.collectBasedOnSubject(collectSubject) { - addAssertionsCreatedBy(assertionCreatorOrNull) + _logic.appendAssertionsCreatedBy(assertionCreatorOrNull) } //TODO 0.17.0 this is a pattern which occurs over and over again, maybe incorporate into collect? container.maybeSubject.fold( @@ -74,7 +74,7 @@ class DefaultAnyAssertions : AnyAssertions { override fun isNotIn(container: AssertionContainer, expected: Iterable): Assertion { val assertions = expected.map { value -> assertionBuilder.representationOnly - .withTest(container) { it != value } + .withTest(container.toExpect()) { it != value } .withRepresentation(value) .build() } diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultFloatingPointAssertions.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultFloatingPointAssertions.kt index 5e5590f2c..7aaf469b8 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultFloatingPointAssertions.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultFloatingPointAssertions.kt @@ -8,6 +8,8 @@ import ch.tutteli.atrium.core.polyfills.formatFloatingPointNumber import ch.tutteli.atrium.core.polyfills.fullName import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.logic.FloatingPointAssertions +import ch.tutteli.atrium.logic.createDescriptiveAssertion +import ch.tutteli.atrium.logic.toExpect import ch.tutteli.atrium.reporting.translating.TranslatableWithArgs import ch.tutteli.atrium.translations.DescriptionFloatingPointAssertion.* import kotlin.math.absoluteValue @@ -69,10 +71,11 @@ internal fun > toBeWithErrorTolerance( tolerance: T, absDiff: (T) -> T, explanatoryAssertionCreator: (T) -> List -): Assertion = assertionBuilder.descriptive - .withTest(container) { absDiff(it) <= tolerance } - .withFailureHintBasedOnDefinedSubject(container) { subject -> - //TODO that's not nice in case we use it in an Iterable contains assertion, for instance contains...entry { toBeWithErrorTolerance(x, 0.01) } +): Assertion = + assertionBuilder.descriptive + .withTest(container.toExpect()) { absDiff(it) <= tolerance } + .withFailureHintBasedOnDefinedSubject(container.toExpect()) { subject -> + //TODO 0.18.0 that's not nice in case we use it in an Iterable contains assertion, for instance contains...entry { toBeWithErrorTolerance(x, 0.01) } //we do not want to see the failure nor the exact check in the 'an entry which...' part //same problematic applies to feature assertions within an identification lambda // => yet explanatory assertion should always hold diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logic.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logic.kt index 9118b86e3..31328a36c 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logic.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logic.kt @@ -12,7 +12,7 @@ import ch.tutteli.atrium.creating.Expect * Use [_logic] for more sophisticated scenarios, like feature extraction. */ inline fun Expect._logicAppend(assertionCreator: AssertionContainer.() -> Assertion): Expect = - addAssertion(_logic.assertionCreator()) + _logic.run { appendAssertion(assertionCreator()) } /** * Entry point to the logic level of Atrium -- which is one level deeper than the API -- diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicCharSequenceContains.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicCharSequenceContains.kt index 03e883af3..10b9bc741 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicCharSequenceContains.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicCharSequenceContains.kt @@ -40,7 +40,7 @@ inline val inline fun CharSequenceContains.CheckerStep._logicAppend( factory: CharSequenceContains.CheckerStepLogic.() -> Assertion -): Expect = _logic.let { l -> l.entryPointStepLogic.container.toExpect().addAssertion(l.factory()) } +): Expect = _logic.let { l -> l.entryPointStepLogic.container.appendAssertion(l.factory()) } /** * Entry point to the logic level of Atrium -- which is one level deeper than the API -- diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicIterableLikeContains.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicIterableLikeContains.kt index 208b1226f..2e52731fd 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicIterableLikeContains.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicIterableLikeContains.kt @@ -18,7 +18,7 @@ import ch.tutteli.atrium.reporting.BUG_REPORT_URL inline fun IterableLikeContains.EntryPointStep._logicAppend( factory: IterableLikeContains.EntryPointStepLogic.() -> Assertion -): Expect = _logic.let { l -> l.container.toExpect().addAssertion(l.factory()) } +): Expect = _logic.let { l -> l.container.appendAssertion(l.factory()) } /** * Entry point to the logic level of Atrium -- which is one level deeper than the API -- @@ -52,7 +52,7 @@ inline val inline fun IterableLikeContains.CheckerStep._logicAppend( factory: IterableLikeContains.CheckerStepLogic.() -> Assertion -): Expect = _logic.let { l -> l.entryPointStepLogic.container.toExpect().addAssertion(l.factory()) } +): Expect = _logic.let { l -> l.entryPointStepLogic.container.appendAssertion(l.factory()) } /** * Entry point to the logic level of Atrium -- which is one level deeper than the API -- diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicMapLikeContains.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicMapLikeContains.kt index 143684b73..101ecd14f 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicMapLikeContains.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/logicMapLikeContains.kt @@ -15,7 +15,7 @@ import ch.tutteli.atrium.reporting.BUG_REPORT_URL inline fun MapLikeContains.EntryPointStep._logicAppend( factory: MapLikeContains.EntryPointStepLogic.() -> Assertion -): Expect = _logic.let { l -> l.container.toExpect().addAssertion(l.factory()) } +): Expect = _logic.let { l -> l.container.appendAssertion(l.factory()) } /** * Entry point to the logic level of Atrium -- which is one level deeper than the API -- diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utils.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utils.kt index c263ce84e..e01465a0b 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utils.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utils.kt @@ -10,7 +10,6 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.ExpectInternal import ch.tutteli.atrium.logic.creating.transformers.FeatureExtractorBuilder import ch.tutteli.atrium.logic.creating.transformers.SubjectChangerBuilder -import ch.tutteli.atrium.logic.creating.transformers.TransformationExecutionStep import ch.tutteli.atrium.reporting.BUG_REPORT_URL import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable @@ -25,24 +24,27 @@ import ch.tutteli.atrium.reporting.translating.Translatable * @param representation The representation of the expected outcome * @param test The test which checks whether the assertion holds */ +//TODO deprecate with 0.18.0 fun AssertionContainer.createDescriptiveAssertion( description: Translatable, representation: Any?, test: (T) -> Boolean ): Assertion = assertionBuilder.descriptive - .withTest(this, test) + .withTest(this.toExpect(), test) .withDescriptionAndRepresentation(description, representation) .build() /** * Entry point to use the [SubjectChangerBuilder] based on this [AssertionContainer]. */ +//TODO deprecate with 0.18.0 val AssertionContainer.changeSubject: SubjectChangerBuilder.KindStep get() = SubjectChangerBuilder(this) /** * Entry point to use the [FeatureExtractorBuilder] based on this [AssertionContainer]. */ +//TODO deprecate with 0.18.0 val AssertionContainer.extractFeature: FeatureExtractorBuilder.DescriptionStep get() = FeatureExtractorBuilder(this) @@ -52,6 +54,7 @@ val AssertionContainer.extractFeature: FeatureExtractorBuilder.Descriptio * logic level. */ //is not internal as it is used by extensions, however it is not made visible via module-info.java +//TODO deprecate with 0.18.0 and move toProofContainer to core fun Expect.toAssertionContainer(): AssertionContainer = when (this) { is ExpectInternal -> this @@ -61,6 +64,7 @@ fun Expect.toAssertionContainer(): AssertionContainer = /** * Casts this [AssertionContainer] back to an [Expect] so that you can use it in places where an [Expect] is used. */ +//TODO deprecate with 0.18.0 and move ProofContainer.toExpect to core fun AssertionContainer.toExpect(): Expect = when (this) { is ExpectInternal -> this diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utilsCollect.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utilsCollect.kt index 38f0a621e..549bf5094 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utilsCollect.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/utilsCollect.kt @@ -97,6 +97,8 @@ inline fun AssertionContainer<*>.collectForDifferentSubject( * * @return The collected assertions. */ +//TODO check if it makes more sense to stay on the logic level for assertionCreator +//TODO 0.18.0 deprecate and move to ProofContainer inline fun AssertionContainer<*>.collectBasedOnSubject( maybeSubject: Option, noinline assertionCreator: Expect.() -> Unit diff --git a/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt b/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt index 348bd5d1e..0d4ee11ab 100644 --- a/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt +++ b/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultBigDecimalAssertions.kt @@ -12,6 +12,7 @@ import ch.tutteli.atrium.assertions.builders.withFailureHint import ch.tutteli.atrium.creating.AssertionContainer import ch.tutteli.atrium.logic.BigDecimalAssertions import ch.tutteli.atrium.logic.createDescriptiveAssertion +import ch.tutteli.atrium.logic.toExpect import ch.tutteli.atrium.translations.DescriptionBigDecimalAssertion.* import java.math.BigDecimal @@ -35,7 +36,7 @@ class DefaultBigDecimalAssertions : BigDecimalAssertions { nameOfIsNumericallyEqualTo: String ): Assertion = assertionBuilder.descriptive - .withTest(container) { it == expected } + .withTest(container.toExpect()) { it == expected } .withFailureHint { assertionBuilder.explanatoryGroup .withInformationType(withIndent = true) @@ -45,7 +46,7 @@ class DefaultBigDecimalAssertions : BigDecimalAssertions { ) .build() } - .showBasedOnDefinedSubjectOnlyIf(container) { + .showBasedOnDefinedSubjectOnlyIf(container.toExpect()) { isNumericallyEqualTo(it, expected) } .withDescriptionAndRepresentation(IS_EQUAL_INCLUDING_SCALE, expected) diff --git a/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultPathAssertions.kt b/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultPathAssertions.kt index 592aa8c76..f225dceb5 100644 --- a/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultPathAssertions.kt +++ b/logic/atrium-logic-jvm/src/main/kotlin/ch/tutteli/atrium/logic/impl/DefaultPathAssertions.kt @@ -22,7 +22,6 @@ import ch.tutteli.atrium.reporting.Text import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.TranslatableWithArgs import ch.tutteli.atrium.translations.DescriptionBasic -import ch.tutteli.atrium.translations.DescriptionMapLikeAssertion import ch.tutteli.atrium.translations.DescriptionPathAssertion.* import ch.tutteli.niok.* import java.nio.charset.Charset diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SubjectLessSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SubjectLessSpec.kt index 1e5c928e4..19e7b6ec1 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SubjectLessSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SubjectLessSpec.kt @@ -39,7 +39,7 @@ abstract class SubjectLessSpec( @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalNewExpectTypes::class, ExperimentalComponentFactoryContainer::class) - val container = RootExpectBuilder.forSubject(1.0) + val expect = RootExpectBuilder.forSubject(1.0) .withVerb("custom assertion verb") .withOptions { withComponent(AtriumErrorAdjuster::class) { _ -> NoOpAtriumErrorAdjuster } @@ -50,7 +50,7 @@ abstract class SubjectLessSpec( .withDefaultType .withAssertions(assertions) .build() - container.addAssertion(explanatoryGroup) + expect._logic.appendAssertion(explanatoryGroup) } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotExpectationsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotExpectationsSpec.kt index 73108b6f2..ba5c06311 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotExpectationsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotExpectationsSpec.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.specs.integration import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion.CONTAINS_NOT import org.spekframework.spek2.style.specification.Suite @@ -165,18 +166,18 @@ abstract class CharSequenceContainsContainsNotExpectationsSpec( val nameWithArrow = "${featureArrow}name" it("${contains.name} 'treboR' and 'llotS' - error message contains '$nameWithArrow' exactly once") { expect { - expect(person).addAssertionsCreatedBy { + expect(person)._logic.appendAssertionsCreatedBy(fun Expect.() { feature(Person::name).containsFun("treboR", "llotS") - } + }) }.toThrow { message { this.contains.exactly(1).value(nameWithArrow) } } } it("${containsNot.name} 'Robert' and 'Stoll' - error message contains '$nameWithArrow' exactly once") { expect { - expect(person).addAssertionsCreatedBy { + expect(person)._logic.appendAssertionsCreatedBy(fun Expect.() { feature(Person::name).containsNotFun("Robert", "Stoll") - } + }) }.toThrow { message { this.contains.exactly(1).value(nameWithArrow) } } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt index 440086302..1bbfab414 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt @@ -4,6 +4,8 @@ import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.core.ExperimentalNewExpectTypes import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer +import ch.tutteli.atrium.logic._logic +import ch.tutteli.atrium.logic.createDescriptiveAssertion import ch.tutteli.atrium.logic.creating.RootExpectBuilder import ch.tutteli.atrium.reporting.translating.Locale import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable @@ -188,13 +190,14 @@ abstract class TranslatorIntSpec( describe("translation for $testTranslatable.${TestTranslatable.DATE_KNOWN} (with a date as parameter) is provided for 'fr' and 'it'") { it("uses the translation form 'fr' but the primary Locale to format the date") { expect { - assertWithDeCh_Fr(1).createAndAddAssertion( + val assertwithdechFr = assertWithDeCh_Fr(1) + assertwithdechFr._logic.appendAssertion(assertwithdechFr._logic.createDescriptiveAssertion( TranslatableWithArgs( TestTranslatable.DATE_KNOWN, firstOfFeb2017, firstOfFeb2017 ), 1 - ) { false } + ) { false }) }.toThrow { messageContains("02/01/17 était Mittwoch!!") } } } @@ -202,12 +205,13 @@ abstract class TranslatorIntSpec( describe("translation for $testTranslatable.${TestTranslatable.DATE_UNKNOWN} (with a date as parameter) is provided for 'it' but not for 'fr'") { it("uses default translation but the primary Locale to format the date") { expect { - assertWithDeCh_Fr(1).createAndAddAssertion( + val assertwithdechFr = assertWithDeCh_Fr(1) + assertwithdechFr._logic.appendAssertion(assertwithdechFr._logic.createDescriptiveAssertion( TranslatableWithArgs( TestTranslatable.DATE_UNKNOWN, firstOfFeb2017 ), 1 - ) { false } + ) { false }) }.toThrow { messageContains("only Mittwoch") } } } @@ -221,12 +225,13 @@ abstract class TranslatorIntSpec( + "and the translation from 'ch' for $descriptionAnyAssertion.$toBe" ) { expect { - assertWithDeCh_Fr(1).createAndAddAssertion( + val assertwithdechFr = assertWithDeCh_Fr(1) + assertwithdechFr._logic.appendAssertion(assertwithdechFr._logic.createDescriptiveAssertion( TranslatableWithArgs( TestTranslatable.PLACEHOLDER, toBe ), 1 - ) { false } + ) { false }) }.toThrow { messageContains("Caractère de remplacement ist") } } } @@ -245,13 +250,14 @@ abstract class TranslatorIntSpec( describe("translation for $testTranslatable.${TestTranslatable.DATE_KNOWN} (with a date as parameter) is provided for 'fr' and 'it'") { it("uses the translation form 'fr' but the primary Locale to format the date") { expect { - assertWithDeCh_FrCh_ItCh(1).createAndAddAssertion( + val assertwithdechFrchItch = assertWithDeCh_FrCh_ItCh(1) + assertwithdechFrchItch._logic.appendAssertion(assertwithdechFrchItch._logic.createDescriptiveAssertion( TranslatableWithArgs( TestTranslatable.DATE_KNOWN, firstOfFeb2017, firstOfFeb2017 ), 1 - ) { false } + ) { false }) }.toThrow { messageContains("02/01/17 était Mittwoch!!") } } } @@ -259,12 +265,13 @@ abstract class TranslatorIntSpec( describe("translation for $testTranslatable.${TestTranslatable.DATE_UNKNOWN} (with a date as parameter) is provided for 'it' but not for 'fr'") { it("uses 'it' but the primary Locale to format the date") { expect { - assertWithDeCh_FrCh_ItCh(1).createAndAddAssertion( + val assertwithdechFrchItch = assertWithDeCh_FrCh_ItCh(1) + assertwithdechFrchItch._logic.appendAssertion(assertwithdechFrchItch._logic.createDescriptiveAssertion( TranslatableWithArgs( TestTranslatable.DATE_UNKNOWN, firstOfFeb2017 ), 1 - ) { false } + ) { false }) }.toThrow { messageContains("solo Mittwoch!!") } } } diff --git a/misc/tools/readme-examples/src/main/kotlin/readme/examples/Between2Spec.kt b/misc/tools/readme-examples/src/main/kotlin/readme/examples/Between2Spec.kt index 48b4a514c..a03b0c494 100644 --- a/misc/tools/readme-examples/src/main/kotlin/readme/examples/Between2Spec.kt +++ b/misc/tools/readme-examples/src/main/kotlin/readme/examples/Between2Spec.kt @@ -6,6 +6,10 @@ import ch.tutteli.atrium.creating.Expect import org.spekframework.spek2.Spek import java.util.* +//snippet-own-compose-import-start +import ch.tutteli.atrium.logic._logic +//snippet-own-compose-import-end + /** * The tests and error message are written here and automatically placed into the README via generation. * The generation is done during the project built. To trigger it manually, you have to run: @@ -23,8 +27,10 @@ import java.util.* object Between2Spec : Spek({ test("code-own-compose-2") { + //snippet-own-compose-import-insert + fun Expect.isBetween(lowerBoundInclusive: T, upperBoundExclusive: T) = - addAssertionsCreatedBy { + _logic.appendAssertionsCreatedBy { isGreaterThanOrEqual(lowerBoundInclusive) isLessThan(upperBoundExclusive) } diff --git a/misc/tools/readme-examples/src/main/kotlin/readme/examples/I18nSpec.kt b/misc/tools/readme-examples/src/main/kotlin/readme/examples/I18nSpec.kt index 10bb2d03b..7a93cb7de 100644 --- a/misc/tools/readme-examples/src/main/kotlin/readme/examples/I18nSpec.kt +++ b/misc/tools/readme-examples/src/main/kotlin/readme/examples/I18nSpec.kt @@ -35,15 +35,25 @@ import org.spekframework.spek2.Spek object I18nSpec : Spek({ test("code-i18n-1") { - fun Expect.isMultipleOf(base: Int): Expect = - createAndAddAssertion(DescriptionIntAssertion.IS_MULTIPLE_OF, base) { it % base == 0 } + //snippet-import-logic-insert + + fun Expect.isMultipleOf(base: Int): Expect = _logic.run { + appendAssertion( + createDescriptiveAssertion(DescriptionIntAssertion.IS_MULTIPLE_OF, base) { it % base == 0 } + ) + } //snippet-DescriptionIntAssertion-insert } test("code-i18n-2") { - fun Expect.isEven(): Expect = - createAndAddAssertion(DescriptionBasic.IS, DescriptionIntAssertions.EVEN) { it % 2 == 0 } + //snippet-import-logic-insert + + fun Expect.isEven(): Expect = _logic.run { + appendAssertion( + createDescriptiveAssertion(DescriptionBasic.IS, DescriptionIntAssertions.EVEN) { it % 2 == 0 } + ) + } //snippet-DescriptionIntAssertions-insert } diff --git a/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt b/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt index b828c7b70..b55b7f15b 100644 --- a/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt +++ b/misc/tools/readme-examples/src/main/kotlin/readme/examples/OwnExpectationFunctionsSpec.kt @@ -4,6 +4,9 @@ package readme.examples //snippet-mapArguments-start import ch.tutteli.atrium.logic.utils.mapArguments //snippet-mapArguments-end +//snippet-own-boolean-import-start +import ch.tutteli.atrium.logic._logic +//snippet-own-boolean-import-end //@formatter:on import ch.tutteli.atrium.api.fluent.en_GB.* @@ -31,9 +34,11 @@ object OwnExpectationFunctionsSpec : Spek({ //snippet-own-boolean-1-start fun Expect.isMultipleOf(base: Int) = - createAndAddAssertion("is multiple of", base) { it % base == 0 } + _logic.createAndAppendAssertion("is multiple of", base) { it % base == 0 } //snippet-own-boolean-1-end test("code-own-boolean-1") { + //snippet-own-boolean-import-insert + //snippet-own-boolean-1-insert } test("ex-own-boolean-1") { @@ -42,9 +47,11 @@ object OwnExpectationFunctionsSpec : Spek({ //snippet-own-boolean-2-start fun Expect.isEven() = - createAndAddAssertion("is", Text("an even number")) { it % 2 == 0 } + _logic.createAndAppendAssertion("is", Text("an even number")) { it % 2 == 0 } //snippet-own-boolean-2-end test("code-own-boolean-2") { + //snippet-own-boolean-import-insert + //snippet-own-boolean-2-insert } test("ex-own-boolean-2") { diff --git a/misc/tools/readme-examples/src/main/kotlin/readme/examples/utils/expect.kt b/misc/tools/readme-examples/src/main/kotlin/readme/examples/utils/expect.kt index c6b1fff6f..5d67859ae 100644 --- a/misc/tools/readme-examples/src/main/kotlin/readme/examples/utils/expect.kt +++ b/misc/tools/readme-examples/src/main/kotlin/readme/examples/utils/expect.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.withOptions import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer import ch.tutteli.atrium.creating.build +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.reporting.text.TextObjectFormatter import ch.tutteli.atrium.reporting.text.impl.AbstractTextObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator @@ -16,7 +17,7 @@ fun expect(t: T): Expect = } fun expect(t: T, assertionCreator: Expect.() -> Unit): Expect = - expect(t).addAssertionsCreatedBy(assertionCreator) + expect(t)._logic.appendAssertionsCreatedBy(assertionCreator) class ReadmeObjectFormatter(translator: Translator) : AbstractTextObjectFormatter(translator) { diff --git a/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt b/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt index 6865fbf66..c4ba2d861 100644 --- a/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt +++ b/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.core.ExperimentalNewExpectTypes import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer import ch.tutteli.atrium.creating.RootExpect +import ch.tutteli.atrium.logic._logic import ch.tutteli.atrium.logic.creating.RootExpectBuilder import ch.tutteli.atrium.reporting.AtriumErrorAdjuster import ch.tutteli.atrium.reporting.erroradjusters.NoOpAtriumErrorAdjuster @@ -40,7 +41,7 @@ fun expect(subject: T): RootExpect = * @throws AssertionError in case an assertion does not hold. */ fun expect(subject: T, assertionCreator: Expect.() -> Unit): Expect = - expect(subject).addAssertionsCreatedBy(assertionCreator) + expect(subject)._logic.appendAssertionsCreatedBy(assertionCreator) /** * Defines the translation used for the assertion verbs used for internal purposes. diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt index 24b2d2b6f..d0e5ffdd4 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt @@ -33,7 +33,7 @@ fun assert(subject: T): RootExpect = * @throws AssertionError in case an assertion does not hold. */ fun assert(subject: T, assertionCreator: Expect.() -> Unit): Expect = - assert(subject).addAssertionsCreatedBy(assertionCreator) + assert(subject)._logic.appendAssertionsCreatedBy(assertionCreator) @Deprecated( "`assert` should not be nested, use `feature` instead.", diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt index bca64770e..f405bd457 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt @@ -33,7 +33,7 @@ fun assertThat(subject: T): RootExpect = * @throws AssertionError in case an assertion does not hold. */ fun assertThat(subject: T, assertionCreator: Expect.() -> Unit): Expect = - assertThat(subject).addAssertionsCreatedBy(assertionCreator) + assertThat(subject)._logic.appendAssertionsCreatedBy(assertionCreator) @Deprecated( "`assertThat` should not be nested, use `feature` instead.", diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt index a51b336e7..d99f6714f 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt @@ -33,7 +33,7 @@ fun expect(subject: T): RootExpect = * @throws AssertionError in case an assertion does not hold. */ fun expect(subject: T, assertionCreator: Expect.() -> Unit): Expect = - expect(subject).addAssertionsCreatedBy(assertionCreator) + expect(subject)._logic.appendAssertionsCreatedBy(assertionCreator) @Deprecated( "`expect` should not be nested, use `feature` instead.",