Merge pull request #776 from robstoll/cleanup-core

Cleanup core
This commit is contained in:
Robert Stoll
2021-01-10 21:01:23 +01:00
committed by GitHub
49 changed files with 192 additions and 502 deletions

View File

@@ -17,7 +17,8 @@ annotation class ExperimentalWithOptions
* Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject
* instead of the representation that has been defined so far (which defaults to the subject itself).
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*
* @return An [Expect] for the current subject of the assertion.
*/
@@ -35,7 +36,8 @@ fun <T> RootExpect<T>.withRepresentation(textRepresentation: String): Expect<T>
* If your text does not include the current subject, then we recommend to use the other overload which expects
* a `String` and does the wrapping for you.
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*
* @return An [Expect] for the current subject of the assertion.
*/
@@ -68,7 +70,8 @@ fun <T> RootExpect<T>.withOptions(options: ExpectOptions<T>): Expect<T> =
* Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject
* instead of the representation that has been defined so far (which defaults to the subject itself).
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*
* @return An [Expect] for the current subject of the assertion.
*/
@@ -88,7 +91,8 @@ fun <T, R> FeatureExpect<T, R>.withRepresentation(textRepresentation: String): E
* If your text does not include the current subject, then we recommend to use the other overload which expects
* a `String` and does the wrapping for you.
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*
* @return An [Expect] for the current subject of the assertion.
*/

View File

@@ -17,7 +17,8 @@ annotation class ExperimentalWithOptions
* Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject
* instead of the representation that has been defined so far (which defaults to the subject itself).
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*/
@ExperimentalWithOptions
infix fun <T> RootExpect<T>.withRepresentation(textRepresentation: String): Expect<T> =
@@ -33,7 +34,8 @@ infix fun <T> RootExpect<T>.withRepresentation(textRepresentation: String): Expe
* If your text does not include the current subject, then we recommend to use the other overload which expects
* a `String` and does the wrapping for you.
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*/
@ExperimentalWithOptions
infix fun <T> RootExpect<T>.withRepresentation(representationProvider: (T) -> Any): Expect<T> =
@@ -60,7 +62,8 @@ infix fun <T> RootExpect<T>.withOptions(options: ExpectOptions<T>): Expect<T> =
* Wraps the given [textRepresentation] into a [Text] and uses it as representation of the subject
* instead of the representation that has been defined so far (which defaults to the subject itself).
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*
* @return An [Expect] for the current subject of the assertion.
*/
@@ -80,7 +83,8 @@ infix fun <T, R> FeatureExpect<T, R>.withRepresentation(textRepresentation: Stri
* If your text does not include the current subject, then we recommend to use the other overload which expects
* a `String` and does the wrapping for you.
*
* In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used.
* In case the subject of the assertion is not defined (i.e. `_logic.maybeSubject` is [None]),
* then the previous representation is used.
*
* @return An [Expect] for the current subject of the assertion.
*/

View File

@@ -7,8 +7,10 @@ import ch.tutteli.atrium.api.verbs.assert
import ch.tutteli.atrium.api.verbs.assertThat
import ch.tutteli.atrium.api.verbs.expect
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.TO_BE
@@ -107,12 +109,10 @@ class SmokeTest {
fun Expect<Int>.isEven() = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 }
fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = addAssertion(_isMultipleOf(this, base))
fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = _logicAppend { isMultipleOf(base) }
private fun _isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
private fun AssertionContainer<Int>.isMultipleOf(base: Int): Assertion =
createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 }
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")

View File

@@ -5,8 +5,10 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe
import ch.tutteli.atrium.api.verbs.assert
import ch.tutteli.atrium.api.verbs.assertThat
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic
@@ -34,12 +36,10 @@ object SmokeSpec : Spek({
fun Expect<Int>.isEven() =
createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 }
fun Expect<Int>.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base))
fun Expect<Int>.isMultipleOf(base: Int) = _logicAppend { isMultipleOf(base) }
fun _isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
private fun AssertionContainer<Int>.isMultipleOf(base: Int): Assertion =
createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 }
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")

View File

@@ -9,8 +9,10 @@ import ch.tutteli.atrium.api.fluent.en_GB.kotlin_1_3.isSuccess
import ch.tutteli.atrium.api.fluent.en_GB.toBe
import ch.tutteli.atrium.api.verbs.expect
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic
@@ -37,12 +39,10 @@ object SmokeSpec : Spek({
fun Expect<Int>.isEven(): Expect<Int> =
createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 }
fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = addAssertion(_isMultipleOf(this, base))
fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = _logicAppend { isMultipleOf(base) }
fun _isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
private fun AssertionContainer<Int>.isMultipleOf(base: Int): Assertion =
createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 }
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")

View File

@@ -1,8 +1,10 @@
import ch.tutteli.atrium.api.infix.en_GB.*
import ch.tutteli.atrium.api.verbs.assertThat
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic.IS
@@ -55,13 +57,12 @@ object even
infix fun Expect<Int>.tobe(@Suppress("UNUSED_PARAMETER") even: even) =
createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 }
infix fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = addAssertion(isMultipleOf(this, base))
infix fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = _logicAppend { isMultipleOf(base) }
private fun isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
private fun AssertionContainer<Int>.isMultipleOf(base: Int): Assertion =
createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 }
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")
}

View File

@@ -3,8 +3,10 @@ package custom
import ch.tutteli.atrium.api.infix.en_GB.toBe
import ch.tutteli.atrium.api.verbs.assertThat
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic
@@ -30,13 +32,12 @@ object even
infix fun Expect<Int>.tobe(@Suppress("UNUSED_PARAMETER") even: even) =
createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 }
infix fun Expect<Int>.isMultipleOf(base: Int) = addAssertion(isMultipleOf(this, base))
infix fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = _logicAppend { isMultipleOf(base) }
fun isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
private fun AssertionContainer<Int>.isMultipleOf(base: Int): Assertion =
createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 }
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")
}

View File

@@ -1,10 +0,0 @@
description = "Represents a JDK >= 9 smoke test for atrium-infix-en_GB with jdk8 extension"
sourceCompatibility = JavaVersion.current()
targetCompatibility = JavaVersion.current()
dependencies {
//I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead
testImplementation prefixedProject('infix-en_GB-jvm')
testImplementation prefixedProject('api-infix-en_GB-jdk8-jvm')
}

View File

@@ -1,50 +0,0 @@
package custom
import ch.tutteli.atrium.api.infix.en_GB.jdk8.notTo
import ch.tutteli.atrium.api.infix.en_GB.exist
import ch.tutteli.atrium.api.infix.en_GB.toBe
import ch.tutteli.atrium.api.verbs.assert
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import java.nio.file.Paths
object SmokeSpec : Spek({
test("see if `toBe` can be used") {
assert(1) toBe 1
}
test("see if `Path.existsNot` can be used") {
assert(Paths.get("nonExisting")) notTo exist
}
test("see if own assertion function without i18n can be used") {
assert(2) tobe even
}
test("see if own assertion function with i18n can be used") {
assert(4) isMultipleOf 2
}
})
@Suppress("ClassName")
object even
infix fun Expect<Int>.tobe(@Suppress("UNUSED_PARAMETER") even: even) =
createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 }
infix fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = addAssertion(_isMultipleOf(this, base))
fun _isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")
}

View File

@@ -1,10 +0,0 @@
module ch.tutteli.atrium.infix.en_GB.jdk8.smoke {
// test dependencies are usually defined in build.gradle via --patch-module but that's quite cumbersome and I did
// not get it running in 10 minutes so I am using this, the effect should be the same, the kotlin compiler checks if
// I am using symbols from packages I do not require etc.
requires ch.tutteli.atrium.infix.en_GB;
requires ch.tutteli.atrium.api.infix.en_GB.jdk8;
requires kotlin.stdlib;
requires spek.dsl.jvm;
}

View File

@@ -10,8 +10,10 @@ import ch.tutteli.atrium.api.infix.en_GB.success
import ch.tutteli.atrium.api.infix.en_GB.toBe
import ch.tutteli.atrium.api.verbs.expect
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic
@@ -41,12 +43,10 @@ object even
infix fun Expect<Int>.tobe(@Suppress("UNUSED_PARAMETER") even: even) =
createAndAddAssertion(DescriptionBasic.IS, Text("an even number")) { it % 2 == 0 }
infix fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = addAssertion(_isMultipleOf(this, base))
infix fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = _logicAppend { isMultipleOf(base) }
fun _isMultipleOf(expect: Expect<Int>, base: Int): Assertion =
assertionBuilder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
private fun AssertionContainer<Int>.isMultipleOf(base: Int): Assertion =
createDescriptiveAssertion(DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 }
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of")

View File

@@ -1,7 +1,5 @@
package ch.tutteli.atrium.assertions
import ch.tutteli.atrium.assertions.builders.AssertionsOption
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.reporting.translating.Translatable
/**
@@ -15,11 +13,6 @@ interface AssertionGroup : Assertion {
*/
val description: Translatable
@Deprecated("Use description; will be removed with 1.0.0", ReplaceWith("description"))
val name
get() = description
/**
* The type of the group, e.g. [RootAssertionGroupType].
*/
@@ -34,11 +27,6 @@ interface AssertionGroup : Assertion {
*/
val representation: Any
@Deprecated("Use representation; will be removed with 1.0.0", ReplaceWith("representation"))
val subject
get() = representation
/**
* The assertions of this group, which are defined for the subject represented by [representation].
*/
@@ -50,112 +38,4 @@ interface AssertionGroup : Assertion {
* @return `true` if all [assertions] hold; `false` otherwise.
*/
override fun holds() = assertions.all(Assertion::holds)
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
object Builder {
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.root instead; will be removed with 1.0.0",
ReplaceWith(
"AssertImpl.builder.root",
"ch.tutteli.atrium.domain.builders.AssertImpl",
"ch.tutteli.atrium.assertions.builders.root"
)
)
val root = BasicAssertionGroupBuilder(RootAssertionGroupType)
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.list instead; will be removed with 1.0.0",
ReplaceWith("AssertImpl.builder.list", "ch.tutteli.atrium.domain.builders.AssertImpl")
)
val list = BasicAssertionGroupBuilder(DefaultListAssertionGroupType)
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.feature instead; will be removed with 1.0.0",
ReplaceWith("AssertImpl.builder.feature", "ch.tutteli.atrium.domain.builders.AssertImpl")
)
val feature = BasicAssertionGroupBuilder(DefaultFeatureAssertionGroupType)
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.summary instead; will be removed with 1.0.0",
ReplaceWith("AssertImpl.builder.summary", "ch.tutteli.atrium.domain.builders.AssertImpl")
)
val summary = BasicAssertionGroupBuilder(DefaultSummaryAssertionGroupType)
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.explanatoryGroup instead; will be removed with 1.0.0",
ReplaceWith("AssertImpl.builder.explanatoryGroup", "ch.tutteli.atrium.domain.builders.AssertImpl")
)
val explanatory = ExplanatoryAssertionGroupOption()
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.invisible instead; will be removed with 1.0.0",
ReplaceWith(
"AssertImpl.builder.invisibleGroup",
"ch.tutteli.atrium.domain.builders.AssertImpl",
"ch.tutteli.atrium.assertions.builders.invisibleGroup"
)
)
val invisible = EmptyNameAndSubjectAssertionGroupBuilder(InvisibleAssertionGroupType)
@Suppress("DEPRECATION")
@Deprecated(
"Use AssertImpl.builder.customType instead",
ReplaceWith(
"AssertImpl.builder.customType(groupType)",
"ch.tutteli.atrium.domain.builders.AssertImpl"
)
)
fun withType(groupType: AssertionGroupType) = BasicAssertionGroupBuilder(groupType)
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class BasicAssertionGroupBuilder(private val groupType: AssertionGroupType) {
fun create(name: Translatable, subject: Any, assertion: Assertion): AssertionGroup =
assertionBuilder.customType(groupType)
.withDescriptionAndRepresentation(name, subject)
.withAssertion(assertion)
.build()
fun create(name: Translatable, subject: Any, assertions: List<Assertion>): AssertionGroup =
assertionBuilder.customType(groupType)
.withDescriptionAndRepresentation(name, subject)
.withAssertions(assertions)
.build()
}
@Suppress("DEPRECATION")
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class ExplanatoryAssertionGroupOption {
val withDefault = ExplanatoryAssertionGroupBuilder(DefaultExplanatoryAssertionGroupType)
val withWarning = ExplanatoryAssertionGroupBuilder(WarningAssertionGroupType)
fun withType(groupType: ExplanatoryAssertionGroupType) = ExplanatoryAssertionGroupBuilder(groupType)
}
@Suppress("DEPRECATION")
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class ExplanatoryAssertionGroupBuilder(private val groupType: ExplanatoryAssertionGroupType) {
fun create(assertion: Assertion): ExplanatoryAssertionGroup = create(assertion)
fun create(assertions: List<Assertion>): ExplanatoryAssertionGroup =
ExplanatoryAssertionGroup(groupType, assertions, holds = true)
}
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class EmptyNameAndSubjectAssertionGroupBuilder(private val groupType: AssertionGroupType) {
fun create(assertion: Assertion): AssertionGroup =
AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType)
.withAssertion(assertion)
.build()
fun create(assertions: List<Assertion>): AssertionGroup =
AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType)
.withAssertions(assertions)
.build()
}
}
}

View File

@@ -12,16 +12,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable
* @param representation The representation of the subject for which the [assertions] are defined.
* @param assertions The assertions of this group, which are defined for the subject represented by [representation].
*/
@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0")
data class BasicAssertionGroup
@Deprecated(
"Use `AssertImpl.builder.customType` instead, will be made `internal` with 1.0.0",
ReplaceWith(
"AssertImpl.builder.customType(type).withAssertions(description, representation, assertions).build()",
"ch.tutteli.atrium.domain.builders.AssertImpl"
)
)
constructor(
internal data class BasicAssertionGroup(
override val type: AssertionGroupType,
override val description: Translatable,
override val representation: Any,

View File

@@ -10,41 +10,13 @@ import ch.tutteli.atrium.reporting.translating.Translatable
* @param representation The [BasicDescriptiveAssertion.representation].
* @param test Lazily determines whether [BasicDescriptiveAssertion.holds].
*/
@Deprecated("Use DescriptiveAssertion, do not rely on this specific type, will be made internal with 1.0.0")
class BasicDescriptiveAssertion
@Deprecated(
"Use `assertionBuilder.descriptive` instead, will be made `internal` with 1.0.0",
ReplaceWith(
"assertionBuilder.descriptive.withAssertions(description, representation, test)",
"ch.tutteli.atrium.assertions.builders.assertionBuilder"
)
)
constructor(
internal class BasicDescriptiveAssertion(
override val description: Translatable,
override val representation: Any,
private val test: () -> Boolean
) : DescriptiveAssertion {
/**
* Constructor overload with an eager [BasicDescriptiveAssertion.holds].
*
* If the calculation for [holds] is expensive, then you might want to use the other overload with a lazy test.
*
* @param description The [BasicDescriptiveAssertion.description].
* @param representation The [BasicDescriptiveAssertion.representation].
* @param holds Determines whether [BasicDescriptiveAssertion.holds] or not
*/
@Suppress("DEPRECATION" /* TODO remove with 0.16.0 */)
@Deprecated(
"Use `AssertImpl.builder.descriptive` instead, will be made `internal` with 1.0.0",
ReplaceWith(
"AssertImpl.builder.descriptive.withAssertions(description, representation, holds)",
"ch.tutteli.atrium.domain.builders.AssertImpl"
)
)
constructor(description: Translatable, representation: Any, holds: Boolean)
: this(description, representation, { holds })
override fun holds() = test()
/**

View File

@@ -3,15 +3,6 @@ package ch.tutteli.atrium.assertions
/**
* A default implementation for [ExplanatoryAssertion] -- an assertion which only wants to give an [explanation].
*/
@Deprecated("Use ExplanatoryAssertion, do not rely on this specific type, will be made internal with 1.0.0")
class BasicExplanatoryAssertion
@Deprecated(
"Use `AssertImpl.builder.explanatory` instead, will be made `internal` with 1.0.0",
ReplaceWith(
"AssertImpl.builder.explanatory.withAssertions(explanation)",
"ch.tutteli.atrium.domain.builders.AssertImpl"
)
)
constructor(override val explanation: Any?) : ExplanatoryAssertion {
internal class BasicExplanatoryAssertion(override val explanation: Any?) : ExplanatoryAssertion {
override fun toString() = explanation.toString()
}

View File

@@ -15,10 +15,6 @@ interface DescriptiveAssertion : Assertion {
*/
val representation: Any
@Deprecated("Use representation; will be removed with 1.0.0", ReplaceWith("representation"))
val expected
get() = representation
/**
* The complementary description to the [representation] result such as `contains`, `is not` etc.
*/

View File

@@ -11,10 +11,7 @@ import ch.tutteli.atrium.reporting.translating.Untranslatable
* @param type The type of the group, e.g. [InvisibleAssertionGroupType].
* @param assertions The assertions of this group.
*/
@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0")
open class EmptyNameAndRepresentationAssertionGroup
@Deprecated("Use AssertImpl.builder instead, will be made internal with 1.0.0")
constructor(
internal open class EmptyNameAndRepresentationAssertionGroup(
override val type: AssertionGroupType,
override val assertions: List<Assertion>
) : AssertionGroup {

View File

@@ -11,9 +11,7 @@ import ch.tutteli.atrium.reporting.Reporter
* @param explanatoryAssertions The [assertions] of this group which shall not be evaluated but are used in reporting
* to explain something (rather than making assumptions).
*/
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0")
class ExplanatoryAssertionGroup internal constructor(
internal class ExplanatoryAssertionGroup(
type: ExplanatoryAssertionGroupType,
explanatoryAssertions: List<Assertion>,
private val holds: Boolean

View File

@@ -1,14 +0,0 @@
package ch.tutteli.atrium.assertions
/**
* Represents an [AssertionGroup] with a [DefaultIndentAssertionGroupType], which means the [assertions] shall be
* indented one extra level and [description] and [representation] shall be neglected (not reported to the output).
*
* @constructor Represents an [AssertionGroup] with a [DefaultIndentAssertionGroupType], which means the [assertions] shall
* be indented one extra level and [description] and [representation] shall be neglected (not reported to the output).
* @param assertions The assertions of this group.
*/
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See AssertImpl.builder for different groups. Will be removed with 1.0.0")
class IndentAssertionGroup(assertions: List<Assertion>) :
EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, assertions)

View File

@@ -1,16 +0,0 @@
package ch.tutteli.atrium.assertions
/**
* Represents the [AssertionGroupType] for [AssertionGroup]s whose [assertions][AssertionGroup.assertions]
* should be displayed with an extra indent. Such a group might have a [AssertionGroup.description] and
* [AssertionGroup.representation] (by accident) but should not be mentioned in reporting.
*/
@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See other `AssertionGroupType`s. Will be removed with 1.0.0")
interface IndentAssertionGroupType : AssertionGroupType
/**
* The [AssertionGroupType] for [AssertionGroup]s whose assertions should be displayed with an extra indent.
*/
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See other `AssertionGroupType`s. Will be removed with 1.0.0")
object DefaultIndentAssertionGroupType : IndentAssertionGroupType

View File

@@ -3,11 +3,8 @@ package ch.tutteli.atrium.assertions
/**
* Represents an [AssertionGroup] with an [InvisibleAssertionGroupType], which means the grouping should be
* invisible in reporting.
*
* @constructor Use [AssertionGroup.Builder.invisible] to create an [InvisibleAssertionGroup].
*l
* @param assertions The assertions of this group.
*/
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0")
class InvisibleAssertionGroup internal constructor(assertions: List<Assertion>) :
internal class InvisibleAssertionGroup(assertions: List<Assertion>) :
EmptyNameAndRepresentationAssertionGroup(InvisibleAssertionGroupType, assertions)

View File

@@ -2,12 +2,10 @@ package ch.tutteli.atrium.assertions.builders
import ch.tutteli.atrium.assertions.*
import ch.tutteli.atrium.assertions.builders.impl.AssertionBuilderImpl
import ch.tutteli.atrium.core.None
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.ObjectFormatter
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.Reporter
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.Translatable
import ch.tutteli.atrium.reporting.translating.Untranslatable
@@ -164,14 +162,19 @@ interface AssertionBuilder {
* @param description The description of the assertion, e.g. `to Be`.
* @param representation The representation of the expected outcome.
* @param test The test which checks whether the assertion holds.
*
* @throws ch.tutteli.atrium.creating.PlantHasNoSubjectException in case [test] is called in a context where it
* is not safe to call it. For instance, if [test] is called within an explanatory assertion where it is
* possible that [Expect.maybeSubject] is [None].
*/
//TODO remove @throws with 1.0.0
//TODO remove with 0.17.0
@Suppress("DEPRECATION")
@Deprecated(
"Use _logic.createDescriptive instead; will be removed with 0.17.0",
ReplaceWith(
"container.createDescriptiveAssertion",
"ch.tutteli.atrium.logic._logic",
"ch.tutteli.atrium.logic.createDescriptiveAssertion"
)
)
fun <T> createDescriptive(
subjectProvider: SubjectProvider<T>,
subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
description: String,
representation: Any?,
test: (T) -> Boolean
@@ -197,14 +200,18 @@ interface AssertionBuilder {
* @param description The description of the assertion, e.g. `to Be`.
* @param representation The representation of the expected outcome.
* @param test The test which checks whether the assertion holds.
*
* @throws ch.tutteli.atrium.creating.PlantHasNoSubjectException in case [test] is called in a context where it
* is not safe to call it. For instance, if [test] is called within an explanatory assertion where it is
* possible that [Expect.maybeSubject] is [None].
*/
//TODO remove @throws with 1.0.0
//TODO remove with 0.17.0
@Deprecated(
"Use extension AssertionContainer.createDescriptiveAssertion instead - e.g. _logic.createDescriptiveAssertion; will be removed with 0.17.0",
ReplaceWith(
"container.createDescriptiveAssertion",
"ch.tutteli.atrium.logic._logic",
"ch.tutteli.atrium.logic.createDescriptiveAssertion"
)
)
fun <T> createDescriptive(
subjectProvider: SubjectProvider<T>,
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
description: Translatable,
representation: Any?,
test: (T) -> Boolean

View File

@@ -1,7 +1,5 @@
package ch.tutteli.atrium.assertions.builders
import ch.tutteli.atrium.creating.SubjectProvider
/**
* Contract for sub option steps which are based on a defined or absent subject of the assertion.
*/
@@ -40,8 +38,9 @@ interface SubjectBasedOption {
}
companion object {
@Suppress("DEPRECATION")
operator fun <T, R, PO : DefinedOption<T, R, *>> invoke(
subjectProvider: SubjectProvider<T>,
subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
subStep: PO.() -> Pair<() -> R, (T) -> R>,
presentOptionFactory: () -> PO
): R {

View File

@@ -2,7 +2,6 @@ package ch.tutteli.atrium.assertions.builders.common
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.RepresentationOnlyAssertion
import ch.tutteli.atrium.creating.SubjectProvider
/**
* Step which allows to specify [RepresentationOnlyAssertion.holds].
@@ -35,5 +34,8 @@ interface HoldsStep<R> {
* @return `true` in case [SubjectProvider.maybeSubject] is None or the result of [test] passing the subject.
*/
//TODO move to logic and expect AssertionContainer with 0.16.0
fun <T> withTest(subjectProvider: SubjectProvider<T>, test: (T) -> Boolean): R
fun <T> withTest(
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
test: (T) -> Boolean
): R
}

View File

@@ -2,7 +2,6 @@ package ch.tutteli.atrium.assertions.builders.common.impl
import ch.tutteli.atrium.assertions.builders.common.HoldsStep
import ch.tutteli.atrium.core.falseProvider
import ch.tutteli.atrium.creating.SubjectProvider
internal abstract class HoldsStepImpl<R> : HoldsStep<R> {
//TODO use falseProvider https://youtrack.jetbrains.com/issue/KT-27736
@@ -10,7 +9,7 @@ internal abstract class HoldsStepImpl<R> : HoldsStep<R> {
//TODO use trueProvider https://youtrack.jetbrains.com/issue/KT-27736
override val holding: R = withTest { true }
override fun <T> withTest(subjectProvider: SubjectProvider<T>, test: (T) -> Boolean): R = withTest {
override fun <T> withTest(@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>, test: (T) -> Boolean): R = withTest {
subjectProvider.maybeSubject.fold(falseProvider, test)
}

View File

@@ -5,7 +5,6 @@ import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.assertions.builders.impl.descriptive.DescriptionOptionImpl
import ch.tutteli.atrium.assertions.builders.impl.descriptive.FinalStepImpl
import ch.tutteli.atrium.assertions.builders.impl.descriptive.HoldsOptionImpl
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.Translatable
import ch.tutteli.atrium.reporting.translating.Untranslatable
@@ -43,7 +42,10 @@ interface Descriptive {
* ```
*/
//TODO move to logic and expect AssertionContainer with 0.16.0
fun <T> withTest(subjectProvider: SubjectProvider<T>, test: (T) -> Boolean): DescriptionOption<FinalStep>
fun <T> withTest(
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
test: (T) -> Boolean
): DescriptionOption<FinalStep>
companion object {
/**

View File

@@ -4,7 +4,6 @@ import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.assertions.builders.impl.descriptiveWithFailureHint.*
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.Translatable
@@ -35,7 +34,7 @@ fun Descriptive.DescriptionOption<Descriptive.FinalStep>.withFailureHint(
*/
//TODO move to logic and expect AssertionContainer with 0.16.0
fun <T> Descriptive.DescriptionOption<Descriptive.FinalStep>.withFailureHintBasedOnDefinedSubject(
subjectProvider: SubjectProvider<T>,
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
failureHintFactory: (T) -> Assertion
): Descriptive.DescriptionOption<DescriptiveAssertionWithFailureHint.FinalStep> {
return withFailureHintBasedOnSubject(subjectProvider) {
@@ -58,7 +57,7 @@ fun <T> Descriptive.DescriptionOption<Descriptive.FinalStep>.withFailureHintBase
* on the subject of the assertion.
*/
fun <T> Descriptive.DescriptionOption<Descriptive.FinalStep>.withFailureHintBasedOnSubject(
subjectProvider: SubjectProvider<T>,
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
failureHintSubStep: DescriptiveAssertionWithFailureHint.FailureHintSubjectDefinedOption<T>.() -> Pair<() -> Assertion, (T) -> Assertion>
): DescriptiveAssertionWithFailureHint.ShowOption = withFailureHint {
SubjectBasedOption(
@@ -116,14 +115,16 @@ interface DescriptiveAssertionWithFailureHint {
/**
* Defines that the failure hint shall be shown in any case as long as the subject is defined
*/
fun <T> showOnlyIfSubjectDefined(subjectProvider: SubjectProvider<T>): Descriptive.DescriptionOption<FinalStep> =
fun <T> showOnlyIfSubjectDefined(
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>
): Descriptive.DescriptionOption<FinalStep> =
showOnlyIf { subjectProvider.maybeSubject.isDefined() }
/**
* Defines that the failure hint shall be shown if the subject is defined and the given [predicate] holds for it
*/
fun <T> showBasedOnDefinedSubjectOnlyIf(
subjectProvider: SubjectProvider<T>,
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
predicate: (T) -> Boolean
): Descriptive.DescriptionOption<FinalStep> =
showBasedOnSubjectOnlyIf(subjectProvider) { ifDefined { predicate(it) } ifAbsent { false } }
@@ -136,7 +137,7 @@ interface DescriptiveAssertionWithFailureHint {
* of the assertion.
*/
fun <T> showBasedOnSubjectOnlyIf(
subjectProvider: SubjectProvider<T>,
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
showSubStep: ShowSubjectDefinedOption<T>.() -> Pair<() -> Boolean, (T) -> Boolean>
): Descriptive.DescriptionOption<FinalStep> = showOnlyIf {
SubjectBasedOption(subjectProvider, showSubStep, ShowSubjectDefinedOption.Companion::create)

View File

@@ -3,7 +3,6 @@ package ch.tutteli.atrium.assertions.builders.impl.descriptive
import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.assertions.builders.Descriptive
import ch.tutteli.atrium.core.falseProvider
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.Translatable
@@ -22,7 +21,7 @@ internal object HoldsOptionImpl : Descriptive.HoldsOption {
Descriptive.DescriptionOption.create(test, Descriptive.FinalStep.Companion::create)
override fun <T> withTest(
subjectProvider: SubjectProvider<T>,
@Suppress("DEPRECATION") subjectProvider: ch.tutteli.atrium.creating.SubjectProvider<T>,
test: (T) -> Boolean
): Descriptive.DescriptionOption<Descriptive.FinalStep> = withTest {
subjectProvider.maybeSubject.fold(falseProvider, test)

View File

@@ -6,6 +6,8 @@ package ch.tutteli.atrium.core
*
* @return The result of evaluating this function (calling it).
*/
//TODO remove with 0.17.0
@Deprecated("Will be removed with 0.17.0 without replacement")
fun <T> (() -> T).evalOnce(): () -> T {
val v by lazy { this() }
return { v }

View File

@@ -2,7 +2,9 @@ package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
import ch.tutteli.atrium.core.None
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.core.Some
import kotlin.reflect.KClass
/**
@@ -11,13 +13,15 @@ import kotlin.reflect.KClass
* In contrast to assertion function defined for [Expect] which usually return [Expect], functions defined for
* [AssertionContainer] return [Assertion] so that they can be appended to whatever we want.
*
* Note, do not use [SubjectProvider] as this interface is only temporary and will most likely be removed without
* further notice.
* Note, do not use [SubjectProvider] as this interface will be removed with 0.17.0.
*
* @param T The type of the subject of the assertion.
*/
//TODO 0.16.0 remove SubjectProvider
interface AssertionContainer<T> : SubjectProvider<T> {
interface AssertionContainer<T> : @kotlin.Suppress("DEPRECATION") SubjectProvider<T> {
/**
* Either [Some] wrapping the subject of an [Assertion] or [None] in case a previous subject transformation
* could not be carried out.
*/
override val maybeSubject: Option<T>
/**

View File

@@ -1,23 +0,0 @@
package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion
/**
* Represents a general interface which merely defines that assertions can be added to this type via the [addAssertion]
* method.
*
* Notice, this interface has its mere purpose to facilitate the transition from [Assert] to [Expect].
* It might well be that we are going to remove it with 1.0.0 without previous notice.
* Hence, to be on the safe side, you should use [Expect] instead.
*/
interface AssertionHolder {
/**
* Adds the given [assertion] to this holder.
*
* @param assertion The assertion which will be added to this holder.
*
* @return This holder to support a fluent API.
* @throws AssertionError Might throw an [AssertionError] in case the [Assertion] does not hold.
*/
fun addAssertion(assertion: Assertion): AssertionHolder
}

View File

@@ -5,17 +5,13 @@ import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.creating.impl.DelegatingExpectImpl
/**
* Represents an [Expect] which passes on appended assertions to a given [AssertionHolder].
*
* Notice, that [AssertionHolder] has its mere purpose to facilitate the transition from [Assert] to [Expect].
* It might well be that we are going to remove it with 1.0.0 without previous notice.
* Hence, to be on the safe side, you should use [Expect] instead.
* Represents an [Expect] which passes on appended assertions to a given [Expect].
*/
interface DelegatingExpect<T> : Expect<T> {
companion object {
@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */)
@UseExperimental(ExperimentalNewExpectTypes::class)
operator fun <T> invoke(assertionHolder: AssertionHolder, maybeSubject: Option<T>): Expect<T> =
DelegatingExpectImpl(assertionHolder, maybeSubject)
operator fun <T> invoke(expect: AssertionContainer<*>, maybeSubject: Option<T>): Expect<T> =
DelegatingExpectImpl(expect, maybeSubject)
}
}

View File

@@ -3,6 +3,9 @@ package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.core.None
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.core.Some
import ch.tutteli.atrium.reporting.translating.Translatable
import ch.tutteli.atrium.reporting.translating.Untranslatable
@@ -22,18 +25,33 @@ annotation class ExpectMarker
*
* See https://github.com/robstoll/atrium-roadmap/wiki/Requirements#personas for more information about the personas.
*/
interface ExpectInternal<T> : Expect<T>, AssertionContainer<T>
interface ExpectInternal<T> : Expect<T>, AssertionContainer<T>{
//TODO remove with 0.17.0 no longer necessary once it only exist in AssertionContainer
/**
* Either [Some] wrapping the subject of an [Assertion] or [None] in case a previous subject change could not be
* carried out.
*/
override val maybeSubject: Option<T>
}
/**
* Represents the extension point for [Assertion] functions and sophisticated builders for subjects of type [T].
*
* Note, do not use [SubjectProvider] as this interface is only temporary and will most likely be removed without
* further notice.
* Note, do not use [SubjectProvider] as this interface is only temporary and will be removed with 0.17.0.
*
* @param T The type of the subject of the assertion.
*/
@Suppress("DEPRECATION")
@ExpectMarker
interface Expect<T> : SubjectProvider<T> {
interface Expect<T> : @kotlin.Suppress("DEPRECATION") SubjectProvider<T> {
@Deprecated(
"use _logic.maybeSubject will be removed with 0.17.0",
ReplaceWith("this._logic.maybeSubject", "ch.tutteli.atrium.logic._logic")
)
override val maybeSubject: Option<T>
get() = TODO("Not yet implemented")
/**
* Adds the assertions created by the [assertionCreator] lambda to this container and
@@ -47,6 +65,7 @@ interface Expect<T> : SubjectProvider<T> {
*
* @return An [Expect] for the current subject of the assertion.
*/
//TODO 0.16.0 move to AssertionContainer and deprecate
fun addAssertionsCreatedBy(assertionCreator: Expect<T>.() -> Unit): Expect<T>
/**
@@ -56,6 +75,7 @@ interface Expect<T> : SubjectProvider<T> {
*
* @return An [Expect] for the current subject of the assertion.
*/
//TODO 0.16.0 move to AssertionContainer and deprecate
override fun addAssertion(assertion: Assertion): Expect<T>
@@ -69,6 +89,7 @@ interface Expect<T> : SubjectProvider<T> {
*
* @return An [Expect] for the current subject of the assertion.
*/
//TODO 0.16.0 move to AssertionContainer and deprecate
fun createAndAddAssertion(description: String, expected: Any?, test: (T) -> Boolean): Expect<T> =
createAndAddAssertion(Untranslatable(description), expected, test)
@@ -82,6 +103,7 @@ interface Expect<T> : SubjectProvider<T> {
*
* @return An [Expect] for the current subject of the assertion.
*/
//TODO 0.16.0 move to AssertionContainer and deprecate
fun createAndAddAssertion(description: Translatable, expected: Any?, test: (T) -> Boolean): Expect<T> =
addAssertion(assertionBuilder.createDescriptive(this, description, expected, test))
}

View File

@@ -8,10 +8,7 @@ import ch.tutteli.atrium.reporting.BUG_REPORT_URL
import ch.tutteli.atrium.reporting.translating.Translatable
/**
* Represents an [Expect] which results due to a change of the [Expect.maybeSubject] to a feature of the subject.
*
* A change can for instance be a feature extraction such as `expect(listOf(1)).get(0)`
* but also just a feature assertion such as `expect(listOf(1)).feature { f(it::size) }`
* Represents an [Expect] which results due to a feature extraction from he subject of the expectation.
*/
interface FeatureExpect<T, R> : Expect<R> {

View File

@@ -5,15 +5,16 @@ import ch.tutteli.atrium.core.None
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.core.Some
//TODO remove with 0.16.0
//TODO remove with 0.17.0
/**
* Provides the subject of an [Assertion].
*
* Notice, this interface has its mere purpose to facilitate the transition from [Assert] to [Expect].
* It might well be that we are going to remove it with 1.0.0 without previous notice.
* Hence, to be on the safe side, you should use [Expect] instead.
* Notice, this interface had its mere purpose to facilitate the transition from `Assert` to [Expect] -- `Assert` was
* removed in 0.16.0 and thus this interface will be removed with 0.17.0.
*/
interface SubjectProvider<out T> : AssertionHolder {
@Suppress("DEPRECATION")
@Deprecated("Will be removed with 0.17.0 without replacement, switch to Expect or AssertionContainer")
interface SubjectProvider<out T> {
/**
@@ -21,4 +22,15 @@ interface SubjectProvider<out T> : AssertionHolder {
* carried out.
*/
val maybeSubject: Option<T>
/**
* Adds the given [assertion] to this holder.
*
* @param assertion The assertion which will be added to this holder.
*
* @return This holder to support a fluent API.
* @throws AssertionError Might throw an [AssertionError] in case the [Assertion] does not hold.
*/
//TODO deprecate and move to AssertionContainer ->
fun addAssertion(assertion: Assertion): SubjectProvider<T>
}

View File

@@ -3,15 +3,16 @@ package ch.tutteli.atrium.creating.impl
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.creating.AssertionHolder
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.DelegatingExpect
import ch.tutteli.atrium.creating.Expect
@ExperimentalNewExpectTypes
internal class DelegatingExpectImpl<T>(private val assertionHolder: AssertionHolder, maybeSubject: Option<T>) :
internal class DelegatingExpectImpl<T>(private val container: AssertionContainer<*>, maybeSubject: Option<T>) :
BaseExpectImpl<T>(maybeSubject), DelegatingExpect<T> {
override fun addAssertion(assertion: Assertion): Expect<T> {
assertionHolder.addAssertion(assertion)
container.addAssertion(assertion)
return this
}
}

View File

@@ -1,13 +1,11 @@
package ch.tutteli.atrium.reporting
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.translating.Translatable
/**
* Represents a formatter for objects.
*
* Typically it formats [AssertionPlant.subject][SubjectProvider.subject]s and expected values of [Assertion]s.
* Typically it formats the subject of the formulated expectation including the expected values.
*/
interface ObjectFormatter {

View File

@@ -1,45 +0,0 @@
@file:Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
package ch.tutteli.atrium.core.robstoll.lib.reporting
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.BulletPointIdentifier
import ch.tutteli.atrium.assertions.IndentAssertionGroupType
import ch.tutteli.atrium.reporting.AssertionFormatter
import ch.tutteli.atrium.reporting.AssertionFormatterController
import ch.tutteli.atrium.reporting.AssertionFormatterParameterObject
import kotlin.reflect.KClass
/**
* Represents an [AssertionFormatter] which formats [AssertionGroup]s with an [IndentAssertionGroupType] or rather
* creates a child-[AssertionFormatterParameterObject] which proposes to use the bullet point defined
* for [IndentAssertionGroupType] for the [AssertionGroup.assertions].
*
* It does not include a group header in its result or in other words, skips the first part of formatting an
* [AssertionGroup] as defined in [AssertionFormatter.formatGroup].
*
* Its usage is intended for text output (e.g. to the console).
*
* @constructor Represents an [AssertionFormatter] which formats [AssertionGroup]s with an [IndentAssertionGroupType]
* or rather creates a child-[AssertionFormatterParameterObject] which proposes to use the bullet point
* defined for [IndentAssertionGroupType] for the [AssertionGroup.assertions].
* @param bulletPoints The formatter uses the bullet point defined for [IndentAssertionGroupType]
* (`" ⋄ "` if absent) as prefix of the child-[AssertionFormatterParameterObject].
* @param assertionFormatterController The controller to which this formatter gives back the control
* when it comes to format children of an [AssertionGroup].
*/
@Deprecated("So far indentation was achieved by grouping (which is the solution to go). Will be removed with 1.0.0")
class TextIndentAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<IndentAssertionGroupType>(
IndentAssertionGroupType::class,
assertionFormatterController
) {
private val bulletPoint = bulletPoints[IndentAssertionGroupType::class] ?: ""
override fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint)
}

View File

@@ -111,10 +111,6 @@ abstract class CoreFactoryCommonImpl : CoreFactoryCommon {
assertionFormatterFacade.register {
TextExplanatoryAssertionGroupFormatter(bulletPoints, it)
}
assertionFormatterFacade.register {
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
TextIndentAssertionGroupFormatter(bulletPoints, it)
}
assertionFormatterFacade.register {
TextSummaryAssertionGroupFormatter(bulletPoints, it, textAssertionPairFormatter)
}

View File

@@ -1,6 +1,3 @@
//TODO remove file with 1.0.0
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.logic.creating.iterable.contains.creators.impl
import ch.tutteli.atrium.core.Option
@@ -31,7 +28,11 @@ abstract class InOrderOnlyGroupedAssertionCreator<E, T : IterableLike, SC>(
if (group.size == 1) {
_logic.addSingleEntryAssertion(currentIndex, group[0], DescriptionIterableAssertion.INDEX)
} else {
_logic.addSublistAssertion(currentIndex, untilIndex, group, maybeSubject.getOrElse { emptyList() })
_logic.addSublistAssertion(
currentIndex,
untilIndex,
group,
_logic.maybeSubject.getOrElse { emptyList() })
}
index = untilIndex
}

View File

@@ -1,7 +1,6 @@
package ch.tutteli.atrium.logic.creating.iterable.contains.creators.impl
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike
import ch.tutteli.atrium.reporting.translating.Translatable
@@ -10,7 +9,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable
* Represents a creator of a sophisticated `contains` assertions for [Iterable] where exactly the expected entries
* have to appear in the specified order and where an entry is identified by an expected object (equality comparison).
*
* @param T The type of the [AssertionPlant.subject][SubjectProvider.subject] for which the `contains` assertion is be build.
* @param T The type of the subject of the expectation for which the `contains` assertion is be build.
*
* @constructor Represents a creator of a sophisticated `contains` assertions for [Iterable] where exactly the
* expected entries have to appear in the specified order and where an entry is identified by an

View File

@@ -6,6 +6,7 @@ import ch.tutteli.atrium.core.trueProvider
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.DelegatingExpect
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logic
import ch.tutteli.atrium.logic.creating.transformers.SubjectChanger
import ch.tutteli.atrium.reporting.translating.Translatable
@@ -35,7 +36,7 @@ class DefaultSubjectChanger : SubjectChanger {
// we can transform if maybeSubject is None as we have to be in an explaining like context in such a case,
// even if the transformation cannot be carried out
val shallTransform =
container.maybeSubject.fold(trueProvider, { expect.maybeSubject.isDefined() })
container.maybeSubject.fold(trueProvider, { expect._logic.maybeSubject.isDefined() })
val descriptiveAssertion = assertionBuilder.descriptive
.withTest(expect) {

View File

@@ -49,7 +49,7 @@ object MapArgumentsSpec : Spek({
val (first, others) = it(null, "b", "c")
expect(first).toBe(null)
expect(others[0]).notToBeNull {
maybeSubject.map { assertionCreator ->
_logic.maybeSubject.map { assertionCreator ->
_logic.changeSubject.unreported { "banana" }.assertionCreator()
}
}

View File

@@ -1,22 +0,0 @@
@file:Suppress("DEPRECATION" /* TODO remove this suppression with 1.0.0 */)
package ch.tutteli.atrium.specs.reporting
import ch.tutteli.atrium.assertions.BulletPointIdentifier
import ch.tutteli.atrium.assertions.DefaultIndentAssertionGroupType
import ch.tutteli.atrium.assertions.EmptyNameAndRepresentationAssertionGroup
import ch.tutteli.atrium.assertions.IndentAssertionGroupType
import ch.tutteli.atrium.reporting.AssertionFormatter
import ch.tutteli.atrium.reporting.AssertionFormatterController
import kotlin.reflect.KClass
abstract class TextIndentAssertionGroupFormatterSpec(
testeeFactory: (Map<KClass<out BulletPointIdentifier>, String>, AssertionFormatterController) -> AssertionFormatter,
describePrefix: String = "[Atrium] "
) : TextIndentBasedAssertionGroupFormatterSpec<IndentAssertionGroupType>(
testeeFactory,
IndentAssertionGroupType::class,
object : IndentAssertionGroupType {},
{ EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, it) },
describePrefix
)

View File

@@ -19,8 +19,6 @@ class AsciiBulletPointReporterFactory : ReporterFactory {
RootAssertionGroupType::class to "* ",
ListAssertionGroupType::class to "- ",
FeatureAssertionGroupType::class to "=> ",
@Suppress("DEPRECATION" /* TODO remove together with entry with 1.0.0 */)
IndentAssertionGroupType::class to "| ",
PrefixFeatureAssertionGroupHeader::class to ">> ",
PrefixSuccessfulSummaryAssertion::class to "(/) ",
PrefixFailingSummaryAssertion::class to "(x) ",

View File

@@ -2,6 +2,7 @@
// you need to specify the environment variable BC in order that this project (as well as the subprojects)
// are included -> alternatively, you can remove the `if` in settings.gradle.kts (search for System.getenv("BC"))
//<editor-fold desc="setup">
import ch.tutteli.niok.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
@@ -496,6 +497,7 @@ fun Project.rewriteFile(filePath: String, f: (String) -> String) {
val file = file(filePath)
file.writeText(f(file.readText()))
}
//</editor-fold>
// -----------------------------------------------------------------------------------
// Known source backward compatibility breaks:
@@ -528,9 +530,17 @@ listOf("0.14.0", "0.15.0").forEach { version ->
it.replaceFirst("import ch.tutteli.atrium.domain.builders.ExpectImpl", "")
}
rewriteFile("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt") {
it.replaceFirst(
" @Suppress(\"DEPRECATION\" /* TODO remove together with entry with 1.0.0 */)\n" +
" IndentAssertionGroupType::class to \"| \",", ""
)
}
// deleted AssertionPlant and co. in 0.16.0, hence specs don't make sense any more (it's a bc on core level not API)
file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/checking/").deleteRecursively()
file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/creating/").deleteRecursively()
file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt").delete()
}
}

View File

@@ -80,7 +80,7 @@ fun Settings_gradle.includeBundleAndApisWithExtensionsAndSmokeTest(vararg apiNam
includeKotlinJvmJs("bundles/$apiName", "atrium-$apiName")
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
include("bundles/$apiName/", "atrium-$apiName-smoke-test")
includeKotlinJvmJs("bundles/$apiName/extensions/kotlin_1_3", "atrium-$apiName-smoke-test-kotlin_1_3")
include("bundles/$apiName/extensions", "atrium-$apiName-smoke-test-kotlin_1_3")
}
includeKotlinJvmJsWithExtensions("apis/$apiName", "atrium-api-$apiName")
}
@@ -98,6 +98,10 @@ fun Settings_gradle.includeKotlinJvmJsWithExtensions(subPath: String, module: St
}
fun Settings_gradle.include(subPath: String, projectName: String) {
val dir = file("${rootProject.projectDir}/$subPath/$projectName")
if(!dir.exists()){
throw GradleException("cannot include project $projectName as its projectDir $dir does not exist")
}
include(projectName)
project(":$projectName").projectDir = file("${rootProject.projectDir}/$subPath/$projectName")
project(":$projectName").projectDir = dir
}

View File

@@ -1,12 +1,11 @@
package ch.tutteli.atrium.translations
import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
/**
* Contains the [DescriptiveAssertion.description]s of the assertion functions which postulate that a
* [AssertionPlant.subject][SubjectProvider.subject] of type `T` can be transformed (usually down-casting or unboxing) to `TSub`.
* subject of type `T` can be transformed (usually down-casting or unboxing) to `TSub`.
*/
@Suppress("DEPRECATION")
@Deprecated("Use DescriptionAnyAssertion instead; will be removed with 1.0.0")

View File

@@ -1,12 +1,11 @@
package ch.tutteli.atrium.translations
import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.creating.SubjectProvider
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
/**
* Contains the [DescriptiveAssertion.description]s of the assertion functions which postulate that a
* [AssertionPlant.subject][SubjectProvider.subject] of type `T` can be transformed (usually down-casting or unboxing) to `TSub`.
* subject of type `T` can be transformed (usually down-casting or unboxing) to `TSub`.
*/
@Suppress("DEPRECATION")
@Deprecated("Use DescriptionAnyAssertion instead; will be removed with 1.0.0")