kotlin.code.style.official, reformat newer code

no need to reformat deprecated functionality
This commit is contained in:
Robert Stoll
2019-08-29 11:37:11 +02:00
parent e0a76c889a
commit 60d938ffc0
223 changed files with 991 additions and 704 deletions

View File

@@ -1,7 +1,7 @@
description = 'A fluent assertion function API in en_GB with a focus on code completion for Android.' + description = 'A fluent assertion function API in en_GB with a focus on code completion for Android.' +
'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' + 'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' +
'in other words, the developer should be able to: ' + 'in other words, the developer should be able to: ' +
'start creating an assertion + code completion + . + code completion + . + and so on.' 'start creating an assertion + code completion + . + code completion + . + and so on.'
dependencies { dependencies {
api prefixedProject('domain-builders-android') api prefixedProject('domain-builders-android')

View File

@@ -79,7 +79,7 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({
aX: Array<out Any> aX: Array<out Any>
) = expect.contains.atLeast(atLeast).butAtMost(butAtMost).values(a, *aX) ) = expect.contains.atLeast(atLeast).butAtMost(butAtMost).values(a, *aX)
private val atLeastButAtMostIgnoringCaseDescr = { what: String, timesAtLeast: String, timesAtMost: String -> private val atLeastButAtMostIgnoringCaseDescr = { what: String, timesAtLeast: String, timesAtMost: String ->
"$contains $ignoringCase $what $atLeast $timesAtLeast $butAtMost $timesAtMost" "$contains $ignoringCase $what $atLeast $timesAtLeast $butAtMost $timesAtMost"
} }

View File

@@ -24,8 +24,12 @@ class CharSequenceContainsExactlyAssertionsSpec :
("$contains.$ignoringCase.$exactly" to Companion::containsExactlyIgnoringCase) ("$contains.$ignoringCase.$exactly" to Companion::containsExactlyIgnoringCase)
private fun containsExactlyIgnoringCase(expect: Expect<CharSequence>, exactly: Int, a: Any, aX: Array<out Any>) = private fun containsExactlyIgnoringCase(
expect.contains.ignoringCase.exactly(exactly).values(a, *aX) expect: Expect<CharSequence>,
exactly: Int,
a: Any,
aX: Array<out Any>
) = expect.contains.ignoringCase.exactly(exactly).values(a, *aX)
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot

View File

@@ -1,7 +1,5 @@
package ch.tutteli.atrium.api.fluent.en_GB package ch.tutteli.atrium.api.fluent.en_GB
class FeatureAssertionsBoundedReferenceAlternativeSpec : ch.tutteli.atrium.specs.integration.FeatureAssertionsSpec( class FeatureAssertionsBoundedReferenceAlternativeSpec : ch.tutteli.atrium.specs.integration.FeatureAssertionsSpec(
propertyImmediate, propertyImmediate,
propertyLazy, propertyLazy,
@@ -102,4 +100,3 @@ class FeatureAssertionsBoundedReferenceAlternativeSpec : ch.tutteli.atrium.specs
val f5EmptyAssertionCreator: F = { feature({ f5(it::return5, "a", 1, true, 1.2, 'b') }) {} } val f5EmptyAssertionCreator: F = { feature({ f5(it::return5, "a", 1, true, 1.2, 'b') }) {} }
} }
} }

View File

@@ -1,7 +1,7 @@
description = 'An assertion function API in en_GB with a focus on code completion for the JS platform.' + description = 'An assertion function API in en_GB with a focus on code completion for the JS platform.' +
'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' + 'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' +
'in other words, the developer should be able to: ' + 'in other words, the developer should be able to: ' +
'start creating an assertion + code completion + . + code completion + . + and so on.' 'start creating an assertion + code completion + . + code completion + . + and so on.'
dependencies { dependencies {
api prefixedProject('domain-builders-js') api prefixedProject('domain-builders-js')

View File

@@ -1,7 +1,7 @@
description = 'A fluent assertion function API in en_GB with a focus on code completion for the JVM platform.' + description = 'A fluent assertion function API in en_GB with a focus on code completion for the JVM platform.' +
'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' + 'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' +
'in other words, the developer should be able to: ' + 'in other words, the developer should be able to: ' +
'start creating an assertion + code completion + . + code completion + . + and so on.' 'start creating an assertion + code completion + . + code completion + . + and so on.'
ext.jacoco_additional = [ ext.jacoco_additional = [
prefixedProject('translations-en_GB-jvm'), prefixedProject('translations-en_GB-jvm'),

View File

@@ -20,5 +20,5 @@ import java.math.BigDecimal
* @return This assertion container to support a fluent API. * @return This assertion container to support a fluent API.
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
*/ */
fun <T: BigDecimal> Expect<T>.toBeWithErrorTolerance(expected: BigDecimal, tolerance: BigDecimal) fun <T : BigDecimal> Expect<T>.toBeWithErrorTolerance(expected: BigDecimal, tolerance: BigDecimal) =
= addAssertion(ExpectImpl.floatingPoint.toBeWithErrorTolerance(this, expected, tolerance)) addAssertion(ExpectImpl.floatingPoint.toBeWithErrorTolerance(this, expected, tolerance))

View File

@@ -1,7 +1,7 @@
description = 'A fluent assertion function API in en_GB with a focus on code completion for the JVM platform version >= 8.' + description = 'A fluent assertion function API in en_GB with a focus on code completion for the JVM platform version >= 8.' +
'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' + 'It provides a fluent API in en_GB which is designed to ease the usage of code completion or ' +
'in other words, the developer should be able to: ' + 'in other words, the developer should be able to: ' +
'start creating an assertion + code completion + . + code completion + . + and so on.' 'start creating an assertion + code completion + . + code completion + . + and so on.'
ext.jacoco_additional = [ ext.jacoco_additional = [
prefixedProject('domain-builders-jvm'), prefixedProject('domain-builders-jvm'),

View File

@@ -298,6 +298,7 @@ def createRegisterJsServicesTask(String projectName, String packageName, Functio
doLast { doLast {
services.write("""\ services.write("""\
@file:Suppress("DEPRECATION") @file:Suppress("DEPRECATION")
package $packageName package $packageName
import ch.tutteli.atrium.core.polyfills.registerService import ch.tutteli.atrium.core.polyfills.registerService

View File

@@ -4,7 +4,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe
import ch.tutteli.atrium.api.verbs.assertThat import ch.tutteli.atrium.api.verbs.assertThat
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.AssertImpl import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic import ch.tutteli.atrium.translations.DescriptionBasic
@@ -31,7 +31,9 @@ fun Expect<Int>.isEven() =
fun Expect<Int>.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) fun Expect<Int>.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base))
fun _isMultipleOf(assertionContainer: Expect<Int>, base: Int): Assertion = fun _isMultipleOf(assertionContainer: Expect<Int>, base: Int): Assertion =
AssertImpl.builder.createDescriptive(assertionContainer, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { it % base == 0 } ExpectImpl.builder.createDescriptive(assertionContainer, DescriptionIntAssertions.IS_MULTIPLE_OF, base) {
it % base == 0
}
enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
IS_MULTIPLE_OF("is multiple of") IS_MULTIPLE_OF("is multiple of")

View File

@@ -16,7 +16,8 @@ interface AssertionGroup : Assertion {
val description: Translatable val description: Translatable
@Deprecated("Use description; will be removed with 1.0.0", ReplaceWith("description")) @Deprecated("Use description; will be removed with 1.0.0", ReplaceWith("description"))
val name get() = description val name
get() = description
/** /**
@@ -34,7 +35,8 @@ interface AssertionGroup : Assertion {
val representation: Any val representation: Any
@Deprecated("Use representation; will be removed with 1.0.0", ReplaceWith("representation")) @Deprecated("Use representation; will be removed with 1.0.0", ReplaceWith("representation"))
val subject get() = representation val subject
get() = representation
/** /**
@@ -113,17 +115,17 @@ interface AssertionGroup : Assertion {
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class BasicAssertionGroupBuilder(private val groupType: AssertionGroupType) { class BasicAssertionGroupBuilder(private val groupType: AssertionGroupType) {
fun create(name: Translatable, subject: Any, assertion: Assertion): AssertionGroup fun create(name: Translatable, subject: Any, assertion: Assertion): AssertionGroup =
= assertionBuilder.customType(groupType) assertionBuilder.customType(groupType)
.withDescriptionAndRepresentation(name, subject) .withDescriptionAndRepresentation(name, subject)
.withAssertion(assertion) .withAssertion(assertion)
.build() .build()
fun create(name: Translatable, subject: Any, assertions: List<Assertion>): AssertionGroup fun create(name: Translatable, subject: Any, assertions: List<Assertion>): AssertionGroup =
= assertionBuilder.customType(groupType) assertionBuilder.customType(groupType)
.withDescriptionAndRepresentation(name, subject) .withDescriptionAndRepresentation(name, subject)
.withAssertions(assertions) .withAssertions(assertions)
.build() .build()
} }
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
@@ -137,22 +139,21 @@ interface AssertionGroup : Assertion {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class ExplanatoryAssertionGroupBuilder(private val groupType: ExplanatoryAssertionGroupType) { class ExplanatoryAssertionGroupBuilder(private val groupType: ExplanatoryAssertionGroupType) {
fun create(assertion: Assertion): ExplanatoryAssertionGroup fun create(assertion: Assertion): ExplanatoryAssertionGroup = create(assertion)
= create(assertion)
fun create(assertions: List<Assertion>): ExplanatoryAssertionGroup fun create(assertions: List<Assertion>): ExplanatoryAssertionGroup =
= ExplanatoryAssertionGroup(groupType, assertions) ExplanatoryAssertionGroup(groupType, assertions)
} }
@Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0") @Deprecated("Use AssertImpl.builder instead; will be removed with 1.0.0")
class EmptyNameAndSubjectAssertionGroupBuilder(private val groupType: AssertionGroupType) { class EmptyNameAndSubjectAssertionGroupBuilder(private val groupType: AssertionGroupType) {
fun create(assertion: Assertion): AssertionGroup fun create(assertion: Assertion): AssertionGroup =
= AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType) AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType)
.withAssertion(assertion) .withAssertion(assertion)
.build() .build()
fun create(assertions: List<Assertion>): AssertionGroup fun create(assertions: List<Assertion>): AssertionGroup =
= AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType) AssertionsOption.withDefaultFinalStepAndEmptyDescriptionAndRepresentation(groupType)
.withAssertions(assertions) .withAssertions(assertions)
.build() .build()
} }

View File

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

View File

@@ -10,5 +10,5 @@ package ch.tutteli.atrium.assertions
*/ */
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) @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") @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>) class IndentAssertionGroup(assertions: List<Assertion>) :
: EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, assertions) EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, assertions)

View File

@@ -9,5 +9,5 @@ package ch.tutteli.atrium.assertions
*/ */
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) @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") @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>) class InvisibleAssertionGroup internal constructor(assertions: List<Assertion>) :
: EmptyNameAndRepresentationAssertionGroup(InvisibleAssertionGroupType, assertions) EmptyNameAndRepresentationAssertionGroup(InvisibleAssertionGroupType, assertions)

View File

@@ -6,7 +6,7 @@ import ch.tutteli.atrium.assertions.Assertion
* Final step in the [AssertionBuilder] process, creates the desired [Assertion] of type [T]. * Final step in the [AssertionBuilder] process, creates the desired [Assertion] of type [T].
* @param T the type of the [Assertion]. * @param T the type of the [Assertion].
*/ */
interface AssertionBuilderFinalStep<T: Assertion> { interface AssertionBuilderFinalStep<T : Assertion> {
/** /**
* Creates and returns the new [Assertion] of type [T]. * Creates and returns the new [Assertion] of type [T].

View File

@@ -3,15 +3,15 @@ package ch.tutteli.atrium.assertions.builders
import ch.tutteli.atrium.assertions.AssertionGroup import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.AssertionGroupType import ch.tutteli.atrium.assertions.AssertionGroupType
import ch.tutteli.atrium.assertions.builders.impl.AssertionGroupDescriptionAndEmptyRepresentationOptionImpl import ch.tutteli.atrium.assertions.builders.impl.AssertionGroupDescriptionAndEmptyRepresentationOptionImpl
import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.Untranslatable
import ch.tutteli.atrium.reporting.RawString
/** /**
* Option step which allows to specify the [AssertionGroup.description] -- [RawString.EMPTY] is * Option step which allows to specify the [AssertionGroup.description] -- [RawString.EMPTY] is
* used as [AssertionGroup.representation]. * used as [AssertionGroup.representation].
*/ */
interface AssertionGroupDescriptionAndEmptyRepresentationOption<out T: AssertionGroupType, R> { interface AssertionGroupDescriptionAndEmptyRepresentationOption<out T : AssertionGroupType, R> {
/** /**
* The previously defined [AssertionGroup.type]. * The previously defined [AssertionGroup.type].
*/ */
@@ -35,9 +35,10 @@ interface AssertionGroupDescriptionAndEmptyRepresentationOption<out T: Assertion
* Factory method to create a [AssertionGroupDescriptionAndEmptyRepresentationOption] step in the building * Factory method to create a [AssertionGroupDescriptionAndEmptyRepresentationOption] step in the building
* process of an [AssertionGroup]. * process of an [AssertionGroup].
*/ */
fun <T: AssertionGroupType, R> create( fun <T : AssertionGroupType, R> create(
type: T, type: T,
factory: (T, Translatable, Any) -> R factory: (T, Translatable, Any) -> R
): AssertionGroupDescriptionAndEmptyRepresentationOption<T, R> = AssertionGroupDescriptionAndEmptyRepresentationOptionImpl(type, factory) ): AssertionGroupDescriptionAndEmptyRepresentationOption<T, R> =
AssertionGroupDescriptionAndEmptyRepresentationOptionImpl(type, factory)
} }
} }

View File

@@ -41,8 +41,8 @@ interface AssertionsOption<out T : AssertionGroupType, out R> {
/** /**
* Uses the given [assertion1], [assertion2] and [assertion3] as [AssertionGroup.assertions]. * Uses the given [assertion1], [assertion2] and [assertion3] as [AssertionGroup.assertions].
*/ */
fun withAssertions(assertion1: Assertion, assertion2: Assertion, assertion3: Assertion): R fun withAssertions(assertion1: Assertion, assertion2: Assertion, assertion3: Assertion): R =
= withAssertions(listOf(assertion1, assertion2, assertion3)) withAssertions(listOf(assertion1, assertion2, assertion3))
/** /**
* Uses the given [assertions] as [AssertionGroup.assertions]. * Uses the given [assertions] as [AssertionGroup.assertions].
@@ -82,8 +82,12 @@ interface AssertionsOption<out T : AssertionGroupType, out R> {
*/ */
fun <T : AssertionGroupType> withDefaultFinalStepAndEmptyDescriptionAndRepresentation( fun <T : AssertionGroupType> withDefaultFinalStepAndEmptyDescriptionAndRepresentation(
groupType: T groupType: T
): AssertionsOption<T, BasicAssertionGroupFinalStep> ): AssertionsOption<T, BasicAssertionGroupFinalStep> = AssertionsOptionImpl(
= AssertionsOptionImpl(groupType, Untranslatable.EMPTY, RawString.EMPTY, BasicAssertionGroupFinalStep.Companion::create) groupType,
Untranslatable.EMPTY,
RawString.EMPTY,
BasicAssertionGroupFinalStep.Companion::create
)
/** /**
* Returns a factory method which creates an [AssertionsOption] where [BasicAssertionGroupFinalStep] is used * Returns a factory method which creates an [AssertionsOption] where [BasicAssertionGroupFinalStep] is used
@@ -95,12 +99,13 @@ interface AssertionsOption<out T : AssertionGroupType, out R> {
/* that's fine because T is covariant and we do not need multiple function objects for the same functionality */ /* that's fine because T is covariant and we do not need multiple function objects for the same functionality */
"UNCHECKED_CAST" "UNCHECKED_CAST"
) )
val factory = factoryWithDefaultFinalStep as (T, Translatable, Any) -> AssertionsOption<T, BasicAssertionGroupFinalStep> val factory =
factoryWithDefaultFinalStep as (T, Translatable, Any) -> AssertionsOption<T, BasicAssertionGroupFinalStep>
return factory return factory
} }
private val factoryWithDefaultFinalStep: (AssertionGroupType, Translatable, Any) -> AssertionsOption<AssertionGroupType, BasicAssertionGroupFinalStep> private val factoryWithDefaultFinalStep: (AssertionGroupType, Translatable, Any) -> AssertionsOption<AssertionGroupType, BasicAssertionGroupFinalStep> =
= { t, d, r -> { t, d, r ->
AssertionsOptionImpl(t, d, r, BasicAssertionGroupFinalStep.Companion::create) AssertionsOptionImpl(t, d, r, BasicAssertionGroupFinalStep.Companion::create)
} }
} }

View File

@@ -42,6 +42,8 @@ interface BasicAssertionGroupFinalStep : AssertionBuilderFinalStep<AssertionGrou
description: Translatable, description: Translatable,
representation: Any, representation: Any,
assertions: List<Assertion> assertions: List<Assertion>
): BasicAssertionGroupFinalStep = BasicAssertionGroupFinalStepImpl(groupType, description, representation, assertions) ): BasicAssertionGroupFinalStep = BasicAssertionGroupFinalStepImpl(
groupType, description, representation, assertions
)
} }
} }

View File

@@ -69,8 +69,8 @@ interface Descriptive {
* Notice, if you want to use text (e.g. a [String]) as representation, * Notice, if you want to use text (e.g. a [String]) as representation,
* then wrap it into a [RawString] via [RawString.create] and pass the [RawString] instead. * then wrap it into a [RawString] via [RawString.create] and pass the [RawString] instead.
*/ */
fun withDescriptionAndRepresentation(description: String, representation: Any?): R fun withDescriptionAndRepresentation(description: String, representation: Any?): R =
= withDescriptionAndRepresentation(Untranslatable(description), representation) withDescriptionAndRepresentation(Untranslatable(description), representation)
/** /**
* Uses the given [description] as [DescriptiveAssertion.description] and [representation] * Uses the given [description] as [DescriptiveAssertion.description] and [representation]

View File

@@ -18,7 +18,7 @@ interface Explanatory {
/** /**
* Option step which allows to specify an [ExplanatoryAssertion.explanation]. * Option step which allows to specify an [ExplanatoryAssertion.explanation].
*/ */
interface ExplanationOption{ interface ExplanationOption {
/** /**
* Uses the given [translatable] together with the [arg] and optionally [otherArgs] to create an * Uses the given [translatable] together with the [arg] and optionally [otherArgs] to create an
@@ -27,14 +27,13 @@ interface Explanatory {
* It delegates to the overload which expects a single [Translatable]; see there for more details about * It delegates to the overload which expects a single [Translatable]; see there for more details about
* how the [Translatable] is used as [ExplanatoryAssertion.explanation]. * how the [Translatable] is used as [ExplanatoryAssertion.explanation].
*/ */
fun withExplanation(translatable: Translatable, arg: Any, vararg otherArgs: Any): FinalStep fun withExplanation(translatable: Translatable, arg: Any, vararg otherArgs: Any): FinalStep =
= withExplanation(TranslatableWithArgs(translatable, arg glue otherArgs)) withExplanation(TranslatableWithArgs(translatable, arg glue otherArgs))
/** /**
* Uses the given [description] as explanation. * Uses the given [description] as explanation.
*/ */
fun withExplanation(description: String): FinalStep fun withExplanation(description: String): FinalStep = withExplanation(Untranslatable(description))
= withExplanation(Untranslatable(description))
/** /**
* Uses the given [translatable] as explanation. * Uses the given [translatable] as explanation.
@@ -42,8 +41,7 @@ interface Explanatory {
* In detail, the given [translatable] is turned into a [RawString] so that an [ObjectFormatter] translates the * In detail, the given [translatable] is turned into a [RawString] so that an [ObjectFormatter] translates the
* given [translatable] and treats the result as raw string. * given [translatable] and treats the result as raw string.
*/ */
fun withExplanation(translatable: Translatable): FinalStep fun withExplanation(translatable: Translatable): FinalStep = withExplanation(RawString.create(translatable))
= withExplanation(RawString.create(translatable))
/** /**
* Uses the given [explanation] as [ExplanatoryAssertion.explanation]. * Uses the given [explanation] as [ExplanatoryAssertion.explanation].
@@ -51,19 +49,28 @@ interface Explanatory {
* Notice, if you want to use a text (e.g. a [String]) as explanation, * Notice, if you want to use a text (e.g. a [String]) as explanation,
* then wrap it into a [RawString] via [RawString.create] and pass the [RawString] instead. * then wrap it into a [RawString] via [RawString.create] and pass the [RawString] instead.
*/ */
fun withExplanation(explanation: Any?) : FinalStep fun withExplanation(explanation: Any?): FinalStep
@Deprecated("use withExplanation instead; will be removed with 1.0.0", ReplaceWith("this.withExplanation(translatable, arg, *otherArgs)")) @Deprecated(
fun withDescription(translatable: Translatable, arg: Any, vararg otherArgs: Any): FinalStep "use withExplanation instead; will be removed with 1.0.0",
= withExplanation(translatable, arg, *otherArgs) ReplaceWith("this.withExplanation(translatable, arg, *otherArgs)")
)
fun withDescription(translatable: Translatable, arg: Any, vararg otherArgs: Any): FinalStep =
withExplanation(translatable, arg, *otherArgs)
@Deprecated("use withExplanation instead; will be removed with 1.0.0", ReplaceWith("this.withExplanation(translatable)")) @Deprecated(
"use withExplanation instead; will be removed with 1.0.0",
ReplaceWith("this.withExplanation(translatable)")
)
fun withDescription(translatable: Translatable): FinalStep = withExplanation(translatable) fun withDescription(translatable: Translatable): FinalStep = withExplanation(translatable)
@Deprecated("use withExplanation instead; will be removed with 1.0.0", ReplaceWith("this.withExplanation(explanation)")) @Deprecated(
fun withDescription(explanation: Any?) : FinalStep = withExplanation(explanation) "use withExplanation instead; will be removed with 1.0.0",
ReplaceWith("this.withExplanation(explanation)")
)
fun withDescription(explanation: Any?): FinalStep = withExplanation(explanation)
companion object { companion object {
@@ -78,7 +85,7 @@ interface Explanatory {
/** /**
* Final step which creates an [ExplanatoryAssertion] based on the previously defined [explanation]. * Final step which creates an [ExplanatoryAssertion] based on the previously defined [explanation].
*/ */
interface FinalStep : AssertionBuilderFinalStep<ExplanatoryAssertion>{ interface FinalStep : AssertionBuilderFinalStep<ExplanatoryAssertion> {
/** /**
* The previously defined [ExplanatoryAssertion.explanation]. * The previously defined [ExplanatoryAssertion.explanation].
*/ */

View File

@@ -15,7 +15,7 @@ interface ExplanatoryGroup {
* Option step which allows to specify what [ExplanatoryAssertionGroupType] is used as [AssertionGroup.type]. * Option step which allows to specify what [ExplanatoryAssertionGroupType] is used as [AssertionGroup.type].
*/ */
@Suppress("DEPRECATION" /* TODO remove super-type with 1.0.0 */) @Suppress("DEPRECATION" /* TODO remove super-type with 1.0.0 */)
interface GroupTypeOption: ExplanatoryAssertionGroupTypeOption { interface GroupTypeOption : ExplanatoryAssertionGroupTypeOption {
/** /**
* Builder to create an [AssertionGroup] with a [DefaultExplanatoryAssertionGroupType]. * Builder to create an [AssertionGroup] with a [DefaultExplanatoryAssertionGroupType].
@@ -46,7 +46,7 @@ interface ExplanatoryGroup {
* defined [groupType] and the [explanatoryAssertions]. * defined [groupType] and the [explanatoryAssertions].
*/ */
@Suppress("DEPRECATION" /* TODO remove super-type with 1.0.0 */) @Suppress("DEPRECATION" /* TODO remove super-type with 1.0.0 */)
interface FinalStep: AssertionBuilderFinalStep<AssertionGroup>, ExplanatoryAssertionGroupFinalStep{ interface FinalStep : AssertionBuilderFinalStep<AssertionGroup>, ExplanatoryAssertionGroupFinalStep {
/** /**
* The previously defined [AssertionGroup.type]. * The previously defined [AssertionGroup.type].
*/ */
@@ -76,7 +76,7 @@ interface ExplanatoryGroup {
* *
* See [AssertionsOption.withAssertion] for details. * See [AssertionsOption.withAssertion] for details.
*/ */
@Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */ ) @Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */)
fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion( fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion(
translatable: Translatable translatable: Translatable
): ExplanatoryAssertionGroupFinalStep = withExplanatoryAssertion { it.withExplanation(translatable).build() } ): ExplanatoryAssertionGroupFinalStep = withExplanatoryAssertion { it.withExplanation(translatable).build() }
@@ -88,7 +88,7 @@ fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertion
* *
* See [AssertionsOption.withAssertion] for details. * See [AssertionsOption.withAssertion] for details.
*/ */
@Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */ ) @Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */)
fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion( fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion(
representation: Any? representation: Any?
): ExplanatoryAssertionGroupFinalStep = withExplanatoryAssertion { it.withExplanation(representation).build() } ): ExplanatoryAssertionGroupFinalStep = withExplanatoryAssertion { it.withExplanation(representation).build() }
@@ -100,8 +100,11 @@ fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertion
* *
* See [AssertionsOption.withAssertion] for details. * See [AssertionsOption.withAssertion] for details.
*/ */
@Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */ ) @Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */)
@Deprecated("use withExplanatoryAssertion instead; will be removed with 1.0.0", ReplaceWith("this.withExplanatoryAssertion(translatable, arg, *otherArgs)")) @Deprecated(
"use withExplanatoryAssertion instead; will be removed with 1.0.0",
ReplaceWith("this.withExplanatoryAssertion(translatable, arg, *otherArgs)")
)
fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertions( fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertions(
translatable: Translatable, translatable: Translatable,
arg: Any, arg: Any,
@@ -115,12 +118,13 @@ fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertion
* *
* See [AssertionsOption.withAssertion] for details. * See [AssertionsOption.withAssertion] for details.
*/ */
@Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */ ) @Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */)
fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion( fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion(
translatable: Translatable, translatable: Translatable,
arg: Any, arg: Any,
vararg otherArgs: Any vararg otherArgs: Any
): ExplanatoryAssertionGroupFinalStep = withExplanatoryAssertion { it.withExplanation(translatable, arg, *otherArgs).build() } ): ExplanatoryAssertionGroupFinalStep =
withExplanatoryAssertion { it.withExplanation(translatable, arg, *otherArgs).build() }
/** /**
@@ -129,7 +133,7 @@ fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertion
* *
* See [AssertionsOption.withAssertion] for details. * See [AssertionsOption.withAssertion] for details.
*/ */
@Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */ ) @Suppress("DEPRECATION" /* TODO exchange ExplanatoryAssertionGroupFinalStep with ExplanatoryGroup.FinalStep in 1.0.0 */)
inline fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion( inline fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAssertionGroupFinalStep>.withExplanatoryAssertion(
explanationStep: (Explanatory.ExplanationOption) -> Assertion explanationStep: (Explanatory.ExplanationOption) -> Assertion
): ExplanatoryAssertionGroupFinalStep = withAssertion(explanationStep(assertionBuilder.explanatory)) ): ExplanatoryAssertionGroupFinalStep = withAssertion(explanationStep(assertionBuilder.explanatory))
@@ -139,7 +143,10 @@ inline fun <T : ExplanatoryAssertionGroupType> AssertionsOption<T, ExplanatoryAs
* Option step which allows to specify what [ExplanatoryAssertionGroupType] is used as [AssertionGroup.type]. * Option step which allows to specify what [ExplanatoryAssertionGroupType] is used as [AssertionGroup.type].
*/ */
@Suppress("DEPRECATION" /* TODO remove whole interface with 1.0.0 */) @Suppress("DEPRECATION" /* TODO remove whole interface with 1.0.0 */)
@Deprecated("Use ExplanatoryGroup.GroupTypeOption instead; will be removed with 1.0.0", ReplaceWith("ExplanatoryGroup.GroupTypeOption")) @Deprecated(
"Use ExplanatoryGroup.GroupTypeOption instead; will be removed with 1.0.0",
ReplaceWith("ExplanatoryGroup.GroupTypeOption")
)
interface ExplanatoryAssertionGroupTypeOption { interface ExplanatoryAssertionGroupTypeOption {
/** /**
@@ -162,8 +169,11 @@ interface ExplanatoryAssertionGroupTypeOption {
* Final step which creates an [AssertionGroup] with an [ExplanatoryAssertionGroupType] based on the previously * Final step which creates an [AssertionGroup] with an [ExplanatoryAssertionGroupType] based on the previously
* defined [groupType] and the [explanatoryAssertions]. * defined [groupType] and the [explanatoryAssertions].
*/ */
@Deprecated("Use ExplanatoryGroup.FinalStep instead; will be removed with 1.0.0", ReplaceWith("ExplanatoryGroup.FinalStep")) @Deprecated(
interface ExplanatoryAssertionGroupFinalStep: AssertionBuilderFinalStep<AssertionGroup>{ "Use ExplanatoryGroup.FinalStep instead; will be removed with 1.0.0",
ReplaceWith("ExplanatoryGroup.FinalStep")
)
interface ExplanatoryAssertionGroupFinalStep : AssertionBuilderFinalStep<AssertionGroup> {
/** /**
* The previously defined [AssertionGroup.type]. * The previously defined [AssertionGroup.type].
*/ */

View File

@@ -5,28 +5,28 @@ import ch.tutteli.atrium.assertions.builders.*
internal object AssertionBuilderImpl : AssertionBuilder { internal object AssertionBuilderImpl : AssertionBuilder {
override val list: DefaultAssertionGroupBuilderOptions<ListAssertionGroupType> override val list: DefaultAssertionGroupBuilderOptions<ListAssertionGroupType> =
= createDescriptionAndRepresentationOption(DefaultListAssertionGroupType) createDescriptionAndRepresentationOption(DefaultListAssertionGroupType)
override val feature: DefaultAssertionGroupBuilderOptions<FeatureAssertionGroupType> override val feature: DefaultAssertionGroupBuilderOptions<FeatureAssertionGroupType> =
= createDescriptionAndRepresentationOption(DefaultFeatureAssertionGroupType) createDescriptionAndRepresentationOption(DefaultFeatureAssertionGroupType)
override val summary: AssertionGroupDescriptionAndEmptyRepresentationOption<SummaryAssertionGroupType, AssertionsOption<SummaryAssertionGroupType, BasicAssertionGroupFinalStep>> override val summary: AssertionGroupDescriptionAndEmptyRepresentationOption<SummaryAssertionGroupType, AssertionsOption<SummaryAssertionGroupType, BasicAssertionGroupFinalStep>> =
= AssertionGroupDescriptionAndEmptyRepresentationOption.create(DefaultSummaryAssertionGroupType, AssertionsOption.factoryWithDefaultFinalStep()) AssertionGroupDescriptionAndEmptyRepresentationOption.create(
DefaultSummaryAssertionGroupType,
AssertionsOption.factoryWithDefaultFinalStep()
)
override val explanatoryGroup: ExplanatoryGroup.GroupTypeOption override val explanatoryGroup: ExplanatoryGroup.GroupTypeOption = ExplanatoryGroup.GroupTypeOption.create()
= ExplanatoryGroup.GroupTypeOption.create()
override val descriptive: Descriptive.HoldsOption override val descriptive: Descriptive.HoldsOption = Descriptive.HoldsOption.create()
= Descriptive.HoldsOption.create()
override val explanatory: Explanatory.ExplanationOption override val explanatory: Explanatory.ExplanationOption = Explanatory.ExplanationOption.create()
= Explanatory.ExplanationOption.create()
override fun <T : AssertionGroupType> customType(groupType: T): DefaultAssertionGroupBuilderOptions<T> override fun <T : AssertionGroupType> customType(groupType: T): DefaultAssertionGroupBuilderOptions<T> =
= createDescriptionAndRepresentationOption(groupType) createDescriptionAndRepresentationOption(groupType)
private fun <T: AssertionGroupType> createDescriptionAndRepresentationOption(type: T): DefaultAssertionGroupBuilderOptions<T> private fun <T : AssertionGroupType> createDescriptionAndRepresentationOption(type: T): DefaultAssertionGroupBuilderOptions<T> =
= AssertionGroupDescriptionAndRepresentationOption.create(type, AssertionsOption.factoryWithDefaultFinalStep()) AssertionGroupDescriptionAndRepresentationOption.create(type, AssertionsOption.factoryWithDefaultFinalStep())
} }

View File

@@ -5,7 +5,7 @@ import ch.tutteli.atrium.assertions.builders.AssertionGroupDescriptionAndEmptyRe
import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
internal class AssertionGroupDescriptionAndEmptyRepresentationOptionImpl<out T: AssertionGroupType, R>( internal class AssertionGroupDescriptionAndEmptyRepresentationOptionImpl<out T : AssertionGroupType, R>(
override val groupType: T, override val groupType: T,
private val factory: (T, Translatable, Any) -> R private val factory: (T, Translatable, Any) -> R
) : AssertionGroupDescriptionAndEmptyRepresentationOption<T, R> { ) : AssertionGroupDescriptionAndEmptyRepresentationOption<T, R> {

View File

@@ -12,6 +12,6 @@ internal class AssertionsOptionImpl<out T : AssertionGroupType, R>(
private val factory: (T, Translatable, Any, List<Assertion>) -> R private val factory: (T, Translatable, Any, List<Assertion>) -> R
) : AssertionsOption<T, R> { ) : AssertionsOption<T, R> {
override fun withAssertions(assertions: List<Assertion>): R override fun withAssertions(assertions: List<Assertion>): R =
= factory(groupType, description, representation, assertions) factory(groupType, description, representation, assertions)
} }

View File

@@ -16,14 +16,14 @@ internal abstract class FixedClaimLikeAssertionGroupHoldsOptionImpl<T : Assertio
override val failing: AssertionGroupDescriptionAndRepresentationOption<T, AssertionsOption<T, R>> override val failing: AssertionGroupDescriptionAndRepresentationOption<T, AssertionsOption<T, R>>
get() = createDescriptionAndRepresentationOption(false) get() = createDescriptionAndRepresentationOption(false)
override fun withClaim(holds: Boolean): AssertionGroupDescriptionAndRepresentationOption<T, AssertionsOption<T, R>> override fun withClaim(holds: Boolean): AssertionGroupDescriptionAndRepresentationOption<T, AssertionsOption<T, R>> =
= createDescriptionAndRepresentationOption(holds) createDescriptionAndRepresentationOption(holds)
private fun createDescriptionAndRepresentationOption(holds: Boolean) private fun createDescriptionAndRepresentationOption(holds: Boolean) =
= AssertionGroupDescriptionAndRepresentationOption.create(groupType, createAssertionOptionWithHolds(holds)) AssertionGroupDescriptionAndRepresentationOption.create(groupType, createAssertionOptionWithHolds(holds))
private fun createAssertionOptionWithHolds(holds: Boolean): (T, Translatable, Any) -> AssertionsOption<T, R> private fun createAssertionOptionWithHolds(holds: Boolean): (T, Translatable, Any) -> AssertionsOption<T, R> =
= { t, d, r -> AssertionsOption.create(t, d, r, createFixedClaimLikeAssertionGroupFinalStep(holds)) } { t, d, r -> AssertionsOption.create(t, d, r, createFixedClaimLikeAssertionGroupFinalStep(holds)) }
protected abstract fun createFixedClaimLikeAssertionGroupFinalStep( protected abstract fun createFixedClaimLikeAssertionGroupFinalStep(
holds: Boolean holds: Boolean

View File

@@ -1,6 +1,6 @@
package ch.tutteli.atrium.assertions.builders.impl.descriptive package ch.tutteli.atrium.assertions.builders.impl.descriptive
import ch.tutteli.atrium.assertions.* import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.assertions.builders.Descriptive import ch.tutteli.atrium.assertions.builders.Descriptive
import ch.tutteli.atrium.core.trueProvider import ch.tutteli.atrium.core.trueProvider
import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.creating.SubjectProvider
@@ -46,6 +46,7 @@ internal class FinalStepImpl(
override val representation: Any override val representation: Any
) : Descriptive.FinalStep { ) : Descriptive.FinalStep {
@Suppress("DEPRECATION") @Suppress("DEPRECATION" /* TODO remove annotation with 1.0.0 */)
override fun build(): DescriptiveAssertion = BasicDescriptiveAssertion(description, representation, test) override fun build(): DescriptiveAssertion =
ch.tutteli.atrium.assertions.BasicDescriptiveAssertion(description, representation, test)
} }

View File

@@ -1,7 +1,5 @@
package ch.tutteli.atrium.assertions.builders.impl.explanatory package ch.tutteli.atrium.assertions.builders.impl.explanatory
import ch.tutteli.atrium.assertions.*
import ch.tutteli.atrium.assertions.ExplanatoryAssertion import ch.tutteli.atrium.assertions.ExplanatoryAssertion
import ch.tutteli.atrium.assertions.builders.Explanatory import ch.tutteli.atrium.assertions.builders.Explanatory
@@ -10,9 +8,8 @@ internal object ExplanationOptionImpl : Explanatory.ExplanationOption {
override fun withExplanation(explanation: Any?): Explanatory.FinalStep = Explanatory.FinalStep.create(explanation) override fun withExplanation(explanation: Any?): Explanatory.FinalStep = Explanatory.FinalStep.create(explanation)
} }
internal class FinalStepImpl(override val explanation: Any?) : Explanatory.FinalStep { internal class FinalStepImpl(override val explanation: Any?) : Explanatory.FinalStep {
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */ ) @Suppress("DEPRECATION" /* TODO remove annotation with 1.0.0 */)
override fun build(): ExplanatoryAssertion = BasicExplanatoryAssertion(explanation) override fun build(): ExplanatoryAssertion = ch.tutteli.atrium.assertions.BasicExplanatoryAssertion(explanation)
} }

View File

@@ -1,6 +1,8 @@
package ch.tutteli.atrium.assertions.builders.impl.fixedClaimGroup package ch.tutteli.atrium.assertions.builders.impl.fixedClaimGroup
import ch.tutteli.atrium.assertions.* import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.AssertionGroupType
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
internal data class FixedClaimAssertionGroup( internal data class FixedClaimAssertionGroup(

View File

@@ -1,6 +1,8 @@
package ch.tutteli.atrium.assertions.builders.impl.partiallyFixedClaimGroup package ch.tutteli.atrium.assertions.builders.impl.partiallyFixedClaimGroup
import ch.tutteli.atrium.assertions.* import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.AssertionGroupType
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
internal data class PartiallyFixedClaimAssertionGroup( internal data class PartiallyFixedClaimAssertionGroup(

View File

@@ -10,4 +10,7 @@ import ch.tutteli.atrium.checking.AssertionChecker
*/ */
@Suppress("unused" /* it's fine if we don't use AssertionBuilder */) @Suppress("unused" /* it's fine if we don't use AssertionBuilder */)
val AssertionBuilder.root: DefaultAssertionGroupBuilderOptions<RootAssertionGroupType> val AssertionBuilder.root: DefaultAssertionGroupBuilderOptions<RootAssertionGroupType>
get() = AssertionGroupDescriptionAndRepresentationOption.create(RootAssertionGroupType, AssertionsOption.factoryWithDefaultFinalStep()) get() = AssertionGroupDescriptionAndRepresentationOption.create(
RootAssertionGroupType,
AssertionsOption.factoryWithDefaultFinalStep()
)

View File

@@ -27,7 +27,7 @@ expect val KClass<*>.fullName: String
* @param obj The object from which this [KClass] was created of. * @param obj The object from which this [KClass] was created of.
* @return The full name of this [KClass]. * @return The full name of this [KClass].
*/ */
expect fun <T: Any> KClass<out T>.fullName(obj: T): String expect fun <T : Any> KClass<out T>.fullName(obj: T): String
/** /**
* Casts the given [any] to the type of the given [KClass]. * Casts the given [any] to the type of the given [KClass].

View File

@@ -31,8 +31,8 @@ interface AssertionPlant<out T : Any> : BaseAssertionPlant<T, AssertionPlant<T>>
fun addAssertionsCreatedBy(assertionCreator: AssertionPlant<T>.() -> Unit): AssertionPlant<T> fun addAssertionsCreatedBy(assertionCreator: AssertionPlant<T>.() -> Unit): AssertionPlant<T>
/** /**
* Creates a [DescriptiveAssertion] based on the given [description], [expected] and [test] and [adds][addAssertion] it * Creates a [DescriptiveAssertion] based on the given [description], [expected] and [test] and
* to the plant. * [adds][addAssertion] it to the plant.
* *
* @param description The description of the assertion, e.g., `is less than`. * @param description The description of the assertion, e.g., `is less than`.
* @param expected The expected value, e.g., `5` * @param expected The expected value, e.g., `5`
@@ -43,7 +43,7 @@ interface AssertionPlant<out T : Any> : BaseAssertionPlant<T, AssertionPlant<T>>
* @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately
* evaluated (see [ReportingAssertionPlant]). * evaluated (see [ReportingAssertionPlant]).
*/ */
fun createAndAddAssertion(description: Translatable, expected: Any, test: () -> Boolean): AssertionPlant<T> fun createAndAddAssertion(description: Translatable, expected: Any, test: () -> Boolean): AssertionPlant<T> =
= addAssertion(assertionBuilder.createDescriptive(description, expected, test)) addAssertion(assertionBuilder.createDescriptive(description, expected, test))
} }

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
/** /**

View File

@@ -1,8 +1,11 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.checking.AssertionChecker import ch.tutteli.atrium.checking.AssertionChecker
import ch.tutteli.atrium.core.evalOnce import ch.tutteli.atrium.core.evalOnce
import ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
/** /**

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -18,7 +18,7 @@ sealed class MaybeSubject<out T> {
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
@Deprecated("Use something like ch.tutteli.atrium.core.None instead; will be removed with 1.0.0") @Deprecated("Use something like ch.tutteli.atrium.core.None instead; will be removed with 1.0.0")
object Absent: MaybeSubject<Nothing>(){ object Absent : MaybeSubject<Nothing>() {
/** /**
* Throws a [PlantHasNoSubjectException]. * Throws a [PlantHasNoSubjectException].
* @throws PlantHasNoSubjectException if this method is called. * @throws PlantHasNoSubjectException if this method is called.
@@ -33,7 +33,7 @@ sealed class MaybeSubject<out T> {
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
@Deprecated("Use something like ch.tutteli.atrium.core.Some instead; will be removed with 1.0.0") @Deprecated("Use something like ch.tutteli.atrium.core.Some instead; will be removed with 1.0.0")
data class Present<T>(val subject: T): MaybeSubject<T>(){ data class Present<T>(val subject: T) : MaybeSubject<T>() {
/** /**
* Returns the [subject]. * Returns the [subject].
*/ */
@@ -42,7 +42,7 @@ sealed class MaybeSubject<out T> {
companion object { companion object {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
operator fun <T: Any> invoke(subject: T?) = operator fun <T : Any> invoke(subject: T?) =
if (subject == null) Absent if (subject == null) Absent
else Present(subject) else Present(subject)
} }

View File

@@ -7,11 +7,14 @@ import ch.tutteli.atrium.reporting.BUG_REPORT_URL
*/ */
@Deprecated("No longer required with Expect; will be removed with 1.0.0") @Deprecated("No longer required with Expect; will be removed with 1.0.0")
class PlantHasNoSubjectException class PlantHasNoSubjectException
@Deprecated("Use the constructor without argument; will be removed with 1.0.0", ReplaceWith("PlantHasNoSubjectException()")) @Deprecated(
constructor(message: String) : RuntimeException(message){ "Use the constructor without argument; will be removed with 1.0.0",
ReplaceWith("PlantHasNoSubjectException()")
)
constructor(message: String) : RuntimeException(message) {
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) @Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
constructor(): this( constructor() : this(
"subject is not available, you as user should not see this message.\n" + "subject is not available, you as user should not see this message.\n" +
"Please file a bug report (including stacktrace if possible): $BUG_REPORT_URL" "Please file a bug report (including stacktrace if possible): $BUG_REPORT_URL"
) )

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -1,9 +1,9 @@
package ch.tutteli.atrium.creating package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.None
import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.core.Some import ch.tutteli.atrium.core.Some
import ch.tutteli.atrium.core.None
/** /**
* Provides the subject of an [Assertion]. * Provides the subject of an [Assertion].
@@ -13,7 +13,7 @@ import ch.tutteli.atrium.core.None
* Hence, to be on the safe side, you should use [Expect] instead. * Hence, to be on the safe side, you should use [Expect] instead.
*/ */
interface SubjectProvider<out T> { interface SubjectProvider<out T> {
/** /**
* The subject of an [Assertion] -- deprecated, will be removed with 1.0.0. * The subject of an [Assertion] -- deprecated, will be removed with 1.0.0.
* *

View File

@@ -97,7 +97,11 @@ interface AssertionFormatter {
* It itself expects a [AssertionFormatterParameterObject] which is used for the child assertions and a function * It itself expects a [AssertionFormatterParameterObject] which is used for the child assertions and a function
* which formats the child [Assertion]s in the context of the given [assertionGroup]. * which formats the child [Assertion]s in the context of the given [assertionGroup].
*/ */
fun formatGroup(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject, formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit) fun formatGroup(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject,
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit
)
companion object { companion object {
val CALL_FORMAT_GROUP = "do not use `${AssertionFormatter::format.name}` for " + val CALL_FORMAT_GROUP = "do not use `${AssertionFormatter::format.name}` for " +

View File

@@ -2,8 +2,8 @@ package ch.tutteli.atrium.reporting
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.AssertionGroup import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.InvisibleAssertionGroupType
import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType
import ch.tutteli.atrium.assertions.InvisibleAssertionGroupType
import ch.tutteli.atrium.core.CoreFactory import ch.tutteli.atrium.core.CoreFactory
/** /**
@@ -52,8 +52,8 @@ interface AssertionFormatterController {
* *
* @return `true` if it is an explanatory assertion group; `false` otherwise. * @return `true` if it is an explanatory assertion group; `false` otherwise.
*/ */
fun isExplanatoryAssertionGroup(assertion: Assertion) fun isExplanatoryAssertionGroup(assertion: Assertion) =
= assertion is AssertionGroup && assertion.type is ExplanatoryAssertionGroupType assertion is AssertionGroup && assertion.type is ExplanatoryAssertionGroupType
companion object { companion object {
/** /**

View File

@@ -7,7 +7,7 @@ import ch.tutteli.atrium.core.CoreFactory
* Responsible to call an appropriate [AssertionFormatter] which supports [format]ing a given [Assertion]. * Responsible to call an appropriate [AssertionFormatter] which supports [format]ing a given [Assertion].
*/ */
interface AssertionFormatterFacade { interface AssertionFormatterFacade {
/** /**
* Formats the given [assertion] and appends the result to the given [sb]. * Formats the given [assertion] and appends the result to the given [sb].
* *

View File

@@ -54,8 +54,14 @@ class AssertionFormatterParameterObject private constructor(
* *
* @return The newly created [AssertionFormatterParameterObject]. * @return The newly created [AssertionFormatterParameterObject].
*/ */
fun createChildWithNewPrefixAndAdditionalIndent(newPrefix: String, additionalIndent: Int) fun createChildWithNewPrefixAndAdditionalIndent(newPrefix: String, additionalIndent: Int) =
= AssertionFormatterParameterObject(sb, newPrefix, indentLevel + prefix.length + additionalIndent, assertionFilter, numberOfDoNotFilterGroups) AssertionFormatterParameterObject(
sb,
newPrefix,
indentLevel + prefix.length + additionalIndent,
assertionFilter,
numberOfDoNotFilterGroups
)
/** /**
@@ -65,8 +71,8 @@ class AssertionFormatterParameterObject private constructor(
* *
* @return The newly created [AssertionFormatterParameterObject]. * @return The newly created [AssertionFormatterParameterObject].
*/ */
fun createForDoNotFilterAssertionGroup(): AssertionFormatterParameterObject fun createForDoNotFilterAssertionGroup(): AssertionFormatterParameterObject =
= AssertionFormatterParameterObject(sb, prefix, indentLevel, assertionFilter, numberOfDoNotFilterGroups + 1) AssertionFormatterParameterObject(sb, prefix, indentLevel, assertionFilter, numberOfDoNotFilterGroups + 1)
/** /**
* Indicates that the formatting process is currently not formatting the [Assertion]s (or any nested assertion) * Indicates that the formatting process is currently not formatting the [Assertion]s (or any nested assertion)
@@ -101,7 +107,7 @@ class AssertionFormatterParameterObject private constructor(
/** /**
* Appends spaces equal to [numberOfSpaces] to [sb]. * Appends spaces equal to [numberOfSpaces] to [sb].
*/ */
fun indent(numberOfSpaces: Int){ fun indent(numberOfSpaces: Int) {
for (i in 0 until numberOfSpaces) { for (i in 0 until numberOfSpaces) {
sb.append(' ') sb.append(' ')
} }

View File

@@ -18,7 +18,11 @@ interface AssertionPairFormatter {
* @param assertionGroup The [AssertionGroup] of which we want to format the header. * @param assertionGroup The [AssertionGroup] of which we want to format the header.
* @param newParameterObject The [AssertionFormatterParameterObject] used for the [AssertionGroup.assertions]. * @param newParameterObject The [AssertionFormatterParameterObject] used for the [AssertionGroup.assertions].
*/ */
fun formatGroupHeader(parameterObject: AssertionFormatterParameterObject, assertionGroup: AssertionGroup, newParameterObject: AssertionFormatterParameterObject) fun formatGroupHeader(
parameterObject: AssertionFormatterParameterObject,
assertionGroup: AssertionGroup,
newParameterObject: AssertionFormatterParameterObject
)
/** /**
* Formats the assertion pair consisting of the given [translatable] and the given [representation] * Formats the assertion pair consisting of the given [translatable] and the given [representation]

View File

@@ -1,7 +1,7 @@
package ch.tutteli.atrium.reporting package ch.tutteli.atrium.reporting
import ch.tutteli.atrium.reporting.translating.Untranslatable
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
import ch.tutteli.atrium.reporting.translating.Untranslatable
/** /**
* Refers to the bug tracker of Atrium. * Refers to the bug tracker of Atrium.
@@ -11,7 +11,8 @@ const val BUG_REPORT_URL = "https://github.com/robstoll/atrium/issues/new"
/** /**
* Can be used in places where an argument for reporting is expected which should never be shown to the user. * Can be used in places where an argument for reporting is expected which should never be shown to the user.
*/ */
const val SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG = "Should not be shown to the user; if you see this, please file a bug report at $BUG_REPORT_URL" const val SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG =
"Should not be shown to the user; if you see this, please file a bug report at $BUG_REPORT_URL"
/** /**
* Can be used in places where an argument of type [Translatable] is expected which should never be shown to the user. * Can be used in places where an argument of type [Translatable] is expected which should never be shown to the user.

View File

@@ -1,7 +1,7 @@
package ch.tutteli.atrium.reporting.translating package ch.tutteli.atrium.reporting.translating
import ch.tutteli.kbox.forElementAndForEachIn
import ch.tutteli.atrium.core.polyfills.format import ch.tutteli.atrium.core.polyfills.format
import ch.tutteli.kbox.forElementAndForEachIn
/** /**
* Represents a [Translator] which supports [TranslatableWithArgs]. * Represents a [Translator] which supports [TranslatableWithArgs].

View File

@@ -1,6 +1,7 @@
package ch.tutteli.atrium.reporting.translating package ch.tutteli.atrium.reporting.translating
import ch.tutteli.atrium.core.CoreFactory import ch.tutteli.atrium.core.CoreFactory
/** /**
* Responsible to decide in which order [Locale]s should be processed. * Responsible to decide in which order [Locale]s should be processed.
* *

View File

@@ -60,19 +60,17 @@ class TranslatableWithArgs constructor(val translatable: Translatable, val argum
companion object { companion object {
private fun createList(arg: Any): List<Any> private fun createList(arg: Any): List<Any> = ArrayList<Any>(1).apply {
= ArrayList<Any>(1).apply { add(arg)
add(arg) }
}
private fun createList(arg1: Any, arg2: Any): List<Any> private fun createList(arg1: Any, arg2: Any): List<Any> = ArrayList<Any>(2).apply {
= ArrayList<Any>(2).apply { add(arg1)
add(arg1) add(arg2)
add(arg2) }
}
private fun createList(arg1: Any, arg2: Any, otherArgs: Array<out Any>): List<Any> private fun createList(arg1: Any, arg2: Any, otherArgs: Array<out Any>): List<Any> =
= ArrayList<Any>(2 + otherArgs.size).apply { ArrayList<Any>(2 + otherArgs.size).apply {
add(arg1) add(arg1)
add(arg2) add(arg2)
addAll(otherArgs) addAll(otherArgs)

View File

@@ -1,7 +1,5 @@
package ch.tutteli.atrium.reporting.translating package ch.tutteli.atrium.reporting.translating
import ch.tutteli.atrium.core.polyfills.format
/** /**
* This translator does not translate but uses [Translatable.getDefault] instead * This translator does not translate but uses [Translatable.getDefault] instead
* and uses [getDefaultLocale] as [primaryLocale] if not defined differently via constructor parameter. * and uses [getDefaultLocale] as [primaryLocale] if not defined differently via constructor parameter.

View File

@@ -2,7 +2,7 @@ package ch.tutteli.atrium.core
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.checking.AssertionChecker import ch.tutteli.atrium.checking.AssertionChecker
import ch.tutteli.atrium.creating.* import ch.tutteli.atrium.creating.ReportingAssertionPlantNullable
import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.Reporter
import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Translatable
@@ -18,17 +18,17 @@ actual interface CoreFactory : CoreFactoryCommon {
* Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types. * Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types.
* *
* It creates a [newThrowingAssertionChecker] based on the given [reporter] for assertion checking, * It creates a [newThrowingAssertionChecker] based on the given [reporter] for assertion checking,
* uses [subjectProvider] as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as * uses [subjectProvider] as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects * Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once). * (the provider is most likely called more than once).
* *
* Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0. * Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0.
* *
* @param assertionVerb The assertion verb which will be used inter alia in reporting * @param assertionVerb The assertion verb which will be used inter alia in reporting
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]). * (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but * @param subjectProvider Used as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @param reporter The reporter which will be used for a [newThrowingAssertionChecker]. * @param reporter The reporter which will be used for a [newThrowingAssertionChecker].
* *
* *
@@ -55,19 +55,19 @@ actual interface CoreFactory : CoreFactoryCommon {
* Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types. * Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types.
* *
* It uses the given [assertionChecker] for assertion checking, uses [subjectProvider] as * It uses the given [assertionChecker] for assertion checking, uses [subjectProvider] as
* [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as * [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects * Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once). * (the provider is most likely called more than once).
* *
* Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0. * Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0.
* *
* @param assertionVerb The assertion verb which will be used inter alia in reporting * @param assertionVerb The assertion verb which will be used inter alia in reporting
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]). * (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but * @param subjectProvider Used as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @param assertionChecker The checker which will be used to check [Assertion]s. * @param assertionChecker The checker which will be used to check [Assertion]s.
* (see [AssertionPlantWithCommonFields.CommonFields.assertionChecker]). * (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionChecker]).
* *
* @return The newly created assertion plant. * @return The newly created assertion plant.
*/ */

View File

@@ -22,7 +22,7 @@ actual class AtriumError internal actual constructor(message: String) : Assertio
* *
* @return The newly created [AtriumError] * @return The newly created [AtriumError]
*/ */
actual fun create(message: String, atriumErrorAdjuster: AtriumErrorAdjuster): AtriumError actual fun create(message: String, atriumErrorAdjuster: AtriumErrorAdjuster): AtriumError =
= createAtriumError(message, atriumErrorAdjuster) createAtriumError(message, atriumErrorAdjuster)
} }
} }

View File

@@ -117,13 +117,13 @@ class KClassCastTest {
fun illegalCasts_functionTypes__throwsClassCastException() { fun illegalCasts_functionTypes__throwsClassCastException() {
//TODO should throw but does not, see https://youtrack.jetbrains.com/issue/KT-27846 //TODO should throw but does not, see https://youtrack.jetbrains.com/issue/KT-27846
// expect { // expect {
val f: () -> Int = { 1 } val f: () -> Int = { 1 }
f::class.cast({ "a" }) f::class.cast({ "a" })
// }.toThrow<ClassCastException> { messageContains("??? 1") } // }.toThrow<ClassCastException> { messageContains("??? 1") }
//TODO should throw but does not, see https://youtrack.jetbrains.com/issue/KT-27846 //TODO should throw but does not, see https://youtrack.jetbrains.com/issue/KT-27846
// expect{ // expect{
type<() -> Int>().cast({ "a " }) type<() -> Int>().cast({ "a " })
// }.toThrow<ClassCastException> { messageContains("??? 2") } // }.toThrow<ClassCastException> { messageContains("??? 2") }
expect { expect {

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /*TODO remove with 1.0.0 */) @file:Suppress("DEPRECATION" /*TODO remove with 1.0.0 */)
package ch.tutteli.atrium.core.polyfills package ch.tutteli.atrium.core.polyfills
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion

View File

@@ -2,7 +2,7 @@ package ch.tutteli.atrium.core
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.checking.AssertionChecker import ch.tutteli.atrium.checking.AssertionChecker
import ch.tutteli.atrium.creating.* import ch.tutteli.atrium.creating.ReportingAssertionPlantNullable
import ch.tutteli.atrium.reporting.AssertionFormatterFacade import ch.tutteli.atrium.reporting.AssertionFormatterFacade
import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.Reporter
@@ -44,17 +44,17 @@ actual interface CoreFactory : CoreFactoryCommon {
* Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types. * Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types.
* *
* It creates a [newThrowingAssertionChecker] based on the given [reporter] for assertion checking, * It creates a [newThrowingAssertionChecker] based on the given [reporter] for assertion checking,
* uses [subjectProvider] as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as * uses [subjectProvider] as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects * Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once). * (the provider is most likely called more than once).
* *
* Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0. * Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0.
* *
* @param assertionVerb The assertion verb which will be used inter alia in reporting * @param assertionVerb The assertion verb which will be used inter alia in reporting
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]). * (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but * @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @param reporter The reporter which will be used for a [newThrowingAssertionChecker]. * @param reporter The reporter which will be used for a [newThrowingAssertionChecker].
* *
* @return The newly created assertion plant. * @return The newly created assertion plant.
@@ -80,19 +80,19 @@ actual interface CoreFactory : CoreFactoryCommon {
* Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types. * Creates a [ReportingAssertionPlantNullable] which is the entry point for assertions about nullable types.
* *
* It uses the given [assertionChecker] for assertion checking, uses [subjectProvider] as * It uses the given [assertionChecker] for assertion checking, uses [subjectProvider] as
* [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as * [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects * Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once). * (the provider is most likely called more than once).
* *
* Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0. * Notice, this method will be moved to [CoreFactoryCommon] with 1.0.0.
* *
* @param assertionVerb The assertion verb which will be used inter alia in reporting * @param assertionVerb The assertion verb which will be used inter alia in reporting
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]). * (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but * @param subjectProvider Used as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider]. * also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @param assertionChecker The checker which will be used to check [Assertion]s. * @param assertionChecker The checker which will be used to check [Assertion]s.
* (see [AssertionPlantWithCommonFields.CommonFields.assertionChecker]). * (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionChecker]).
* *
* @return The newly created assertion plant. * @return The newly created assertion plant.
*/ */
@@ -112,6 +112,4 @@ actual interface CoreFactory : CoreFactoryCommon {
): ReportingAssertionPlantNullable<T> = newReportingPlantNullableFromCommon( ): ReportingAssertionPlantNullable<T> = newReportingPlantNullableFromCommon(
assertionVerb, subjectProvider, assertionChecker, nullRepresentation assertionVerb, subjectProvider, assertionChecker, nullRepresentation
) )
} }

View File

@@ -5,10 +5,9 @@ import ch.tutteli.kbox.blankToNull
@Suppress("DeprecatedCallableAddReplaceWith") @Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("Only here to ease migration, use Atrium's Locale directly; will be removed with 1.0.0") @Deprecated("Only here to ease migration, use Atrium's Locale directly; will be removed with 1.0.0")
fun java.util.Locale.toAtriumLocale(): Locale fun java.util.Locale.toAtriumLocale(): Locale = ch.tutteli.atrium.reporting.translating.Locale(
= ch.tutteli.atrium.reporting.translating.Locale( language,
language, script.blankToNull(),
script.blankToNull(), country.blankToNull(),
country.blankToNull(), variant.blankToNull()
variant.blankToNull() )
)

View File

@@ -2,7 +2,6 @@ package ch.tutteli.atrium.core.polyfills
import ch.tutteli.atrium.reporting.translating.Locale import ch.tutteli.atrium.reporting.translating.Locale
import ch.tutteli.atrium.reporting.translating.toJavaLocale import ch.tutteli.atrium.reporting.translating.toJavaLocale
import kotlin.String
actual fun String.format(locale: Locale, arg: Any, vararg otherArgs: Any): String { actual fun String.format(locale: Locale, arg: Any, vararg otherArgs: Any): String {
return java.lang.String.format(locale.toJavaLocale(), this, arg, *otherArgs) return java.lang.String.format(locale.toJavaLocale(), this, arg, *otherArgs)

View File

@@ -18,7 +18,7 @@ actual class AtriumError internal actual constructor(message: String) : Assertio
* * Creates an [AtriumError] and adjusts it with the given [atriumErrorAdjuster] before it is returned * * Creates an [AtriumError] and adjusts it with the given [atriumErrorAdjuster] before it is returned
* (adjusting might filter the [stackTrace]). * (adjusting might filter the [stackTrace]).
*/ */
actual fun create(message: String, atriumErrorAdjuster: AtriumErrorAdjuster): AtriumError actual fun create(message: String, atriumErrorAdjuster: AtriumErrorAdjuster): AtriumError =
= createAtriumError(message, atriumErrorAdjuster) createAtriumError(message, atriumErrorAdjuster)
} }
} }

View File

@@ -1,7 +1,7 @@
description = 'Contains the bits and pieces behind robstoll\'s <rstoll@tutteli.ch> implementation ' + description = 'Contains the bits and pieces behind robstoll\'s <rstoll@tutteli.ch> implementation ' +
'of Atrium for Android. You should only depend on this module if you are ' + 'of Atrium for Android. You should only depend on this module if you are ' +
'providing an implementation as well and want to reuse certain artifacts. If you are a consumer of ' + 'providing an implementation as well and want to reuse certain artifacts. If you are a consumer of ' +
'Atrium, then you should depend on atrium-core-robstoll instead.' 'Atrium, then you should depend on atrium-core-robstoll instead.'
dependencies { dependencies {
compile prefixedProject('core-api-android') compile prefixedProject('core-api-android')

View File

@@ -42,10 +42,11 @@ class FeatureAssertionChecker(private val originalAssertionHolder: AssertionHold
* @throws AssertionError Might throw an [AssertionError] in case one of the given [assertions] does not hold. * @throws AssertionError Might throw an [AssertionError] in case one of the given [assertions] does not hold.
*/ */
override fun check(assertionVerb: Translatable, representation: Any?, assertions: List<Assertion>) { override fun check(assertionVerb: Translatable, representation: Any?, assertions: List<Assertion>) {
originalAssertionHolder.addAssertion(assertionBuilder.feature originalAssertionHolder.addAssertion(
.withDescriptionAndRepresentation(assertionVerb, representation) assertionBuilder.feature
.withAssertions(ArrayList(assertions)) .withDescriptionAndRepresentation(assertionVerb, representation)
.build() .withAssertions(ArrayList(assertions))
.build()
) )
} }
} }

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.core.robstoll.lib.creating package ch.tutteli.atrium.core.robstoll.lib.creating
import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.assertions.Assertion
@@ -14,7 +15,7 @@ abstract class MutableListBasedAssertionPlant<out T : Any?, out A : BaseAssertio
@Deprecated( @Deprecated(
"Do not access subject as it might break reporting. In contexts where it is safe to access the subject, it is passed by parameter." "Do not access subject as it might break reporting. In contexts where it is safe to access the subject, it is passed by parameter."
) )
final override val subject : T by lazy { subjectProvider() } final override val subject: T by lazy { subjectProvider() }
/** /**
* The instance itself but typed as [A] which is the type used for the fluent style API. * The instance itself but typed as [A] which is the type used for the fluent style API.

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */) @file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.core.robstoll.lib.creating package ch.tutteli.atrium.core.robstoll.lib.creating
import ch.tutteli.atrium.creating.AssertionPlant import ch.tutteli.atrium.creating.AssertionPlant

View File

@@ -17,9 +17,9 @@ import ch.tutteli.atrium.reporting.AssertionFormatterParameterObject
class AssertionFormatterControllerBasedFacade(private val assertionFormatterController: AssertionFormatterController) : class AssertionFormatterControllerBasedFacade(private val assertionFormatterController: AssertionFormatterController) :
AssertionFormatterFacade { AssertionFormatterFacade {
override fun format(assertion: Assertion, sb: StringBuilder, assertionFilter: (Assertion) -> Boolean) override fun format(assertion: Assertion, sb: StringBuilder, assertionFilter: (Assertion) -> Boolean) =
= assertionFormatterController.format(assertion, AssertionFormatterParameterObject.new(sb, assertionFilter)) assertionFormatterController.format(assertion, AssertionFormatterParameterObject.new(sb, assertionFilter))
override fun register(assertionFormatterFactory: (AssertionFormatterController) -> AssertionFormatter) override fun register(assertionFormatterFactory: (AssertionFormatterController) -> AssertionFormatter) =
= assertionFormatterController.register(assertionFormatterFactory(assertionFormatterController)) assertionFormatterController.register(assertionFormatterFactory(assertionFormatterController))
} }

View File

@@ -38,8 +38,15 @@ class AssertionFormatterControllerImpl : AssertionFormatterController {
&& !parameterObject.assertionFilter(assertion) && !parameterObject.assertionFilter(assertion)
} }
private fun formatGroup(assertionGroup: AssertionGroup, assertionFormatter: AssertionFormatter, parameterObject: AssertionFormatterParameterObject) { private fun formatGroup(
assertionFormatter.formatGroup(assertionGroup, parameterObject) { childParameterObject, formatAssertionInGroup -> assertionGroup: AssertionGroup,
assertionFormatter: AssertionFormatter,
parameterObject: AssertionFormatterParameterObject
) {
assertionFormatter.formatGroup(
assertionGroup,
parameterObject
) { childParameterObject, formatAssertionInGroup ->
assertionGroup.assertions assertionGroup.assertions
.filter { !noNeedToFormat(it, childParameterObject) } .filter { !noNeedToFormat(it, childParameterObject) }
.forEach { formatChild(it, formatAssertionInGroup) } .forEach { formatChild(it, formatAssertionInGroup) }

View File

@@ -6,4 +6,4 @@ expect class MultiAtriumErrorAdjusterImpl(
firstAdjuster: AtriumErrorAdjuster, firstAdjuster: AtriumErrorAdjuster,
secondAdjuster: AtriumErrorAdjuster, secondAdjuster: AtriumErrorAdjuster,
otherAdjusters: List<AtriumErrorAdjuster> otherAdjusters: List<AtriumErrorAdjuster>
): AtriumErrorAdjuster ) : AtriumErrorAdjuster

View File

@@ -29,7 +29,10 @@ abstract class NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<in T :
) : SingleAssertionGroupTypeFormatter<T>(clazz) { ) : SingleAssertionGroupTypeFormatter<T>(clazz) {
override fun formatGroupAssertions(formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit, childParameterObject: AssertionFormatterParameterObject) { override fun formatGroupAssertions(
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit,
childParameterObject: AssertionFormatterParameterObject
) {
formatAssertions(childParameterObject) { formatAssertions(childParameterObject) {
assertionFormatterController.format(it, childParameterObject) assertionFormatterController.format(it, childParameterObject)
} }

View File

@@ -24,8 +24,8 @@ class OnlyFailureReporter(
* Formats the given [assertion] with the help of the defined [assertionFormatterFacade] * Formats the given [assertion] with the help of the defined [assertionFormatterFacade]
* and appends the result to the given [sb] but only in case the given [assertion] [holds][Assertion.holds]. * and appends the result to the given [sb] but only in case the given [assertion] [holds][Assertion.holds].
*/ */
override fun format(assertion: Assertion, sb: StringBuilder) override fun format(assertion: Assertion, sb: StringBuilder) =
= assertionFormatterFacade.format(assertion, sb, this::assertionFilter) assertionFormatterFacade.format(assertion, sb, this::assertionFilter)
private fun assertionFilter(assertion: Assertion) = !assertion.holds() private fun assertionFilter(assertion: Assertion) = !assertion.holds()
} }

View File

@@ -2,4 +2,4 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting
import ch.tutteli.atrium.reporting.AtriumErrorAdjuster import ch.tutteli.atrium.reporting.AtriumErrorAdjuster
expect class RemoveAtriumFromAtriumErrorAdjuster(): AtriumErrorAdjuster expect class RemoveAtriumFromAtriumErrorAdjuster() : AtriumErrorAdjuster

View File

@@ -2,4 +2,4 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting
import ch.tutteli.atrium.reporting.AtriumErrorAdjuster import ch.tutteli.atrium.reporting.AtriumErrorAdjuster
expect class RemoveRunnerAtriumErrorAdjuster(): AtriumErrorAdjuster expect class RemoveRunnerAtriumErrorAdjuster() : AtriumErrorAdjuster

View File

@@ -29,8 +29,7 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
* Returns true if the given [assertion] is an [AssertionGroup] and its [type][AssertionGroup.type] * Returns true if the given [assertion] is an [AssertionGroup] and its [type][AssertionGroup.type]
* is [T] or a sub type. * is [T] or a sub type.
*/ */
final override fun canFormat(assertion: Assertion) final override fun canFormat(assertion: Assertion) = assertion is AssertionGroup && clazz.isInstance(assertion.type)
= assertion is AssertionGroup && clazz.isInstance(assertion.type)
/** /**
* Always throws an [UnsupportedOperationException], because this [AssertionFormatter] can only format * Always throws an [UnsupportedOperationException], because this [AssertionFormatter] can only format
@@ -38,8 +37,10 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
* *
* @throws UnsupportedOperationException always! * @throws UnsupportedOperationException always!
*/ */
final override fun formatNonGroup(assertion: Assertion, parameterObject: AssertionFormatterParameterObject) final override fun formatNonGroup(assertion: Assertion, parameterObject: AssertionFormatterParameterObject) =
= throw UnsupportedOperationException("supports only ${clazz.fullName} for which one has to call ${AssertionFormatter::formatGroup.name}") throw UnsupportedOperationException(
"supports only ${clazz.fullName} for which one has to call ${AssertionFormatter::formatGroup.name}"
)
/** /**
* Checks whether [assertionGroup] is [T] or a sub type and if so, calls [formatGroupHeaderAndGetChildParameterObject] * Checks whether [assertionGroup] is [T] or a sub type and if so, calls [formatGroupHeaderAndGetChildParameterObject]
@@ -59,12 +60,20 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
* *
* @throws UnsupportedOperationException if the given [assertionGroup] is not [T] or a sub type of it. * @throws UnsupportedOperationException if the given [assertionGroup] is not [T] or a sub type of it.
*/ */
final override fun formatGroup(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject, formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit) = when { final override fun formatGroup(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject,
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit
) = when {
clazz.isInstance(assertionGroup.type) -> formatSpecificGroup(assertionGroup, parameterObject, formatAssertions) clazz.isInstance(assertionGroup.type) -> formatSpecificGroup(assertionGroup, parameterObject, formatAssertions)
else -> throw UnsupportedOperationException("supports only ${clazz.fullName}") else -> throw UnsupportedOperationException("supports only ${clazz.fullName}")
} }
private fun formatSpecificGroup(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject, formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit) { private fun formatSpecificGroup(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject,
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit
) {
val childParameterObject = formatGroupHeaderAndGetChildParameterObject(assertionGroup, parameterObject) val childParameterObject = formatGroupHeaderAndGetChildParameterObject(assertionGroup, parameterObject)
formatGroupAssertions(formatAssertions, childParameterObject) formatGroupAssertions(formatAssertions, childParameterObject)
} }
@@ -80,7 +89,10 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
* *
* @return The [AssertionFormatterParameterObject] which shall be used for the [AssertionGroup.assertions]. * @return The [AssertionFormatterParameterObject] which shall be used for the [AssertionGroup.assertions].
*/ */
protected abstract fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject protected abstract fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject
/** /**
* Formats the [AssertionGroup.assertions] -- has to call the given [formatAssertions] function in order that * Formats the [AssertionGroup.assertions] -- has to call the given [formatAssertions] function in order that
@@ -92,5 +104,8 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
* @param childParameterObject The parameter object which shall be used to format [AssertionGroup.assertions] -- contains * @param childParameterObject The parameter object which shall be used to format [AssertionGroup.assertions] -- contains
* inter alia the [sb][AssertionFormatterParameterObject.sb] to which the result will be appended. * inter alia the [sb][AssertionFormatterParameterObject.sb] to which the result will be appended.
*/ */
protected abstract fun formatGroupAssertions(formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit, childParameterObject: AssertionFormatterParameterObject) protected abstract fun formatGroupAssertions(
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit,
childParameterObject: AssertionFormatterParameterObject
)
} }

View File

@@ -36,11 +36,17 @@ import kotlin.reflect.KClass
class TextExplanatoryAssertionGroupFormatter( class TextExplanatoryAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>, bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController assertionFormatterController: AssertionFormatterController
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<ExplanatoryAssertionGroupType>(ExplanatoryAssertionGroupType::class, assertionFormatterController) { ) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<ExplanatoryAssertionGroupType>(
ExplanatoryAssertionGroupType::class,
assertionFormatterController
) {
private val explanatoryBulletPoint = bulletPoints[ExplanatoryAssertionGroupType::class] ?: "» " private val explanatoryBulletPoint = bulletPoints[ExplanatoryAssertionGroupType::class] ?: "» "
private val warningBulletPoint = bulletPoints[WarningAssertionGroupType::class] ?: "❗❗ " private val warningBulletPoint = bulletPoints[WarningAssertionGroupType::class] ?: "❗❗ "
override fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject { override fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
val bulletPoint = when (assertionGroup.type) { val bulletPoint = when (assertionGroup.type) {
WarningAssertionGroupType -> warningBulletPoint WarningAssertionGroupType -> warningBulletPoint
else -> explanatoryBulletPoint else -> explanatoryBulletPoint

View File

@@ -59,20 +59,31 @@ class TextFallbackAssertionFormatter(
} }
} }
private fun appendDescriptiveAssertion(basicAssertion: DescriptiveAssertion, parameterObject: AssertionFormatterParameterObject) { private fun appendDescriptiveAssertion(
basicAssertion: DescriptiveAssertion,
parameterObject: AssertionFormatterParameterObject
) {
assertionPairFormatter.format(parameterObject, basicAssertion.description, basicAssertion.representation) assertionPairFormatter.format(parameterObject, basicAssertion.description, basicAssertion.representation)
} }
private fun appendExplanatoryAssertion(assertion: ExplanatoryAssertion, parameterObject: AssertionFormatterParameterObject) { private fun appendExplanatoryAssertion(
assertion: ExplanatoryAssertion,
parameterObject: AssertionFormatterParameterObject
) {
parameterObject.sb.append(objectFormatter.format(assertion.explanation)) parameterObject.sb.append(objectFormatter.format(assertion.explanation))
} }
private fun formatFallback(assertion: Assertion, parameterObject: AssertionFormatterParameterObject) { private fun formatFallback(assertion: Assertion, parameterObject: AssertionFormatterParameterObject) {
val translatable = Untranslatable("Unsupported type ${assertion::class.fullName}, can only report whether it holds") val translatable =
Untranslatable("Unsupported type ${assertion::class.fullName}, can only report whether it holds")
assertionPairFormatter.format(parameterObject, translatable, assertion.holds()) assertionPairFormatter.format(parameterObject, translatable, assertion.holds())
} }
override fun formatGroup(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject, formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit) { override fun formatGroup(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject,
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit
) {
val childParameterObject = formatGroupHeaderAndGetChildParameterObject(assertionGroup, parameterObject) val childParameterObject = formatGroupHeaderAndGetChildParameterObject(assertionGroup, parameterObject)
formatAssertions(childParameterObject) { formatAssertions(childParameterObject) {
assertionFormatterController.format(it, childParameterObject) assertionFormatterController.format(it, childParameterObject)
@@ -82,7 +93,9 @@ class TextFallbackAssertionFormatter(
private fun formatGroupHeaderAndGetChildParameterObject( private fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject
) = when (assertionGroup.type) { ) = when (assertionGroup.type) {
RootAssertionGroupType -> formatter.formatAfterAppendLnEtc(assertionPairFormatter, assertionGroup, parameterObject) RootAssertionGroupType -> formatter.formatAfterAppendLnEtc(
assertionPairFormatter, assertionGroup, parameterObject
)
else -> formatter.formatWithGroupName(assertionPairFormatter, assertionGroup, parameterObject) else -> formatter.formatWithGroupName(assertionPairFormatter, assertionGroup, parameterObject)
} }

View File

@@ -37,12 +37,18 @@ class TextFeatureAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>, bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController, assertionFormatterController: AssertionFormatterController,
private val assertionPairFormatter: AssertionPairFormatter private val assertionPairFormatter: AssertionPairFormatter
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<FeatureAssertionGroupType>(FeatureAssertionGroupType::class, assertionFormatterController) { ) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<FeatureAssertionGroupType>(
FeatureAssertionGroupType::class,
assertionFormatterController
) {
private val prefix = (bulletPoints[FeatureAssertionGroupType::class] ?: "◾ ") private val prefix = (bulletPoints[FeatureAssertionGroupType::class] ?: "◾ ")
private val arrow = (bulletPoints[PrefixFeatureAssertionGroupHeader::class] ?: "▶ ") private val arrow = (bulletPoints[PrefixFeatureAssertionGroupHeader::class] ?: "▶ ")
override fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject { override fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
parameterObject.appendLnIndentAndPrefix() parameterObject.appendLnIndentAndPrefix()
val translatable = TranslatableWithArgs(Untranslatable("$arrow%s"), assertionGroup.description) val translatable = TranslatableWithArgs(Untranslatable("$arrow%s"), assertionGroup.description)
val group = val group =

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) @file:Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
package ch.tutteli.atrium.core.robstoll.lib.reporting package ch.tutteli.atrium.core.robstoll.lib.reporting
import ch.tutteli.atrium.assertions.AssertionGroup import ch.tutteli.atrium.assertions.AssertionGroup
@@ -31,9 +32,14 @@ import kotlin.reflect.KClass
class TextIndentAssertionGroupFormatter( class TextIndentAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>, bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController assertionFormatterController: AssertionFormatterController
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<IndentAssertionGroupType>(IndentAssertionGroupType::class, assertionFormatterController) { ) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<IndentAssertionGroupType>(
IndentAssertionGroupType::class,
assertionFormatterController
) {
private val bulletPoint = bulletPoints[IndentAssertionGroupType::class] ?: "" private val bulletPoint = bulletPoints[IndentAssertionGroupType::class] ?: ""
override fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject) override fun formatGroupHeaderAndGetChildParameterObject(
= parameterObject.createChildWithNewPrefix(bulletPoint) assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject = parameterObject.createChildWithNewPrefix(bulletPoint)
} }

View File

@@ -32,6 +32,9 @@ abstract class TextListBasedAssertionGroupFormatter<in T : AssertionGroupType>(
private val formatter = private val formatter =
TextPrefixBasedAssertionGroupFormatter(bulletPoint) TextPrefixBasedAssertionGroupFormatter(bulletPoint)
override fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject) override fun formatGroupHeaderAndGetChildParameterObject(
= formatter.formatWithGroupName(assertionPairFormatter, assertionGroup, parameterObject) assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject =
formatter.formatWithGroupName(assertionPairFormatter, assertionGroup, parameterObject)
} }

View File

@@ -30,13 +30,24 @@ class TextNextLineAssertionPairFormatter(
private val translator: Translator private val translator: Translator
) : AssertionPairFormatter { ) : AssertionPairFormatter {
override fun formatGroupHeader(parameterObject: AssertionFormatterParameterObject, assertionGroup: AssertionGroup, newParameterObject: AssertionFormatterParameterObject) override fun formatGroupHeader(
= format(parameterObject, assertionGroup.description, assertionGroup.representation, newParameterObject) parameterObject: AssertionFormatterParameterObject,
assertionGroup: AssertionGroup,
newParameterObject: AssertionFormatterParameterObject
): Unit = format(parameterObject, assertionGroup.description, assertionGroup.representation, newParameterObject)
override fun format(parameterObject: AssertionFormatterParameterObject, translatable: Translatable, representation: Any) override fun format(
= format(parameterObject, translatable, representation, parameterObject) parameterObject: AssertionFormatterParameterObject,
translatable: Translatable,
representation: Any
): Unit = format(parameterObject, translatable, representation, parameterObject)
private fun format(parameterObject: AssertionFormatterParameterObject, translatable: Translatable, representation: Any, newParameterObject: AssertionFormatterParameterObject) { private fun format(
parameterObject: AssertionFormatterParameterObject,
translatable: Translatable,
representation: Any,
newParameterObject: AssertionFormatterParameterObject
) {
parameterObject.sb.append(translator.translate(translatable)).append(":") parameterObject.sb.append(translator.translate(translatable)).append(":")
if (representation !is RawString || representation != RawString.EMPTY) { if (representation !is RawString || representation != RawString.EMPTY) {
newParameterObject.appendLnAndIndent() newParameterObject.appendLnAndIndent()

View File

@@ -7,12 +7,20 @@ import ch.tutteli.atrium.reporting.AssertionPairFormatter
class TextPrefixBasedAssertionGroupFormatter( class TextPrefixBasedAssertionGroupFormatter(
private val prefix: String private val prefix: String
) { ) {
fun formatWithGroupName(assertionPairFormatter: AssertionPairFormatter, assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject { fun formatWithGroupName(
assertionPairFormatter: AssertionPairFormatter,
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
parameterObject.appendLnIndentAndPrefix() parameterObject.appendLnIndentAndPrefix()
return formatAfterAppendLnEtc(assertionPairFormatter, assertionGroup, parameterObject) return formatAfterAppendLnEtc(assertionPairFormatter, assertionGroup, parameterObject)
} }
fun formatAfterAppendLnEtc(assertionPairFormatter: AssertionPairFormatter, assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject { fun formatAfterAppendLnEtc(
assertionPairFormatter: AssertionPairFormatter,
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
val newParameterObject = parameterObject.createChildWithNewPrefix(prefix) val newParameterObject = parameterObject.createChildWithNewPrefix(prefix)
assertionPairFormatter.formatGroupHeader(parameterObject, assertionGroup, newParameterObject) assertionPairFormatter.formatGroupHeader(parameterObject, assertionGroup, newParameterObject)
return newParameterObject return newParameterObject

View File

@@ -28,10 +28,18 @@ class TextSameLineAssertionPairFormatter(
private val translator: Translator private val translator: Translator
) : AssertionPairFormatter { ) : AssertionPairFormatter {
override fun formatGroupHeader(parameterObject: AssertionFormatterParameterObject, assertionGroup: AssertionGroup, newParameterObject: AssertionFormatterParameterObject) override fun formatGroupHeader(
= format(parameterObject, assertionGroup.description, assertionGroup.representation) parameterObject: AssertionFormatterParameterObject,
assertionGroup: AssertionGroup,
newParameterObject: AssertionFormatterParameterObject
): Unit = format(parameterObject, assertionGroup.description, assertionGroup.representation)
override fun format(parameterObject: AssertionFormatterParameterObject, translatable: Translatable, representation: Any) { override fun format(
parameterObject.sb.append(translator.translate(translatable)).append(": ").append(objectFormatter.format(representation)) parameterObject: AssertionFormatterParameterObject,
translatable: Translatable,
representation: Any
) {
parameterObject.sb.append(translator.translate(translatable)).append(": ")
.append(objectFormatter.format(representation))
} }
} }

View File

@@ -36,14 +36,20 @@ class TextSummaryAssertionGroupFormatter(
private val successful = (bulletPoints[PrefixSuccessfulSummaryAssertion::class] ?: "✔ ") private val successful = (bulletPoints[PrefixSuccessfulSummaryAssertion::class] ?: "✔ ")
private val failing = (bulletPoints[PrefixFailingSummaryAssertion::class] ?: "✘ ") private val failing = (bulletPoints[PrefixFailingSummaryAssertion::class] ?: "✘ ")
override fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject { override fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
parameterObject.appendLnIndentAndPrefix() parameterObject.appendLnIndentAndPrefix()
assertionPairFormatter.format(parameterObject, assertionGroup.description, assertionGroup.representation) assertionPairFormatter.format(parameterObject, assertionGroup.description, assertionGroup.representation)
//the prefix which should be used for assertions is defined in the formatGroupAssertions //the prefix which should be used for assertions is defined in the formatGroupAssertions
return parameterObject.createForDoNotFilterAssertionGroup() return parameterObject.createForDoNotFilterAssertionGroup()
} }
override fun formatGroupAssertions(formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit, childParameterObject: AssertionFormatterParameterObject) { override fun formatGroupAssertions(
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit,
childParameterObject: AssertionFormatterParameterObject
) {
val successfulParameterObject = childParameterObject.createChildWithNewPrefix(successful) val successfulParameterObject = childParameterObject.createChildWithNewPrefix(successful)
val failingParameterObject = childParameterObject.createChildWithNewPrefix(failing) val failingParameterObject = childParameterObject.createChildWithNewPrefix(failing)
formatAssertions(childParameterObject) { formatAssertions(childParameterObject) {

View File

@@ -15,5 +15,5 @@ abstract class FilterAtriumErrorAdjuster : AtriumErrorAdjuster {
/** /**
* Does nothing (no adjustments) - override in subclass if you want a different behaviour. * Does nothing (no adjustments) - override in subclass if you want a different behaviour.
*/ */
override fun adjustOtherThanStacks(throwable: Throwable){} override fun adjustOtherThanStacks(throwable: Throwable) {}
} }

View File

@@ -1,9 +1,9 @@
package ch.tutteli.atrium.core.robstoll.lib.reporting package ch.tutteli.atrium.core.robstoll.lib.reporting
import ch.tutteli.atrium.reporting.LazyRepresentation
import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.ObjectFormatter
import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.StringBasedRawString import ch.tutteli.atrium.reporting.StringBasedRawString
import ch.tutteli.atrium.reporting.LazyRepresentation
import ch.tutteli.atrium.reporting.translating.TranslatableBasedRawString import ch.tutteli.atrium.reporting.translating.TranslatableBasedRawString
import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.Translator
import kotlin.reflect.KClass import kotlin.reflect.KClass

View File

@@ -7,7 +7,8 @@ actual class RemoveRunnerAtriumErrorAdjuster : FilterAtriumErrorAdjuster(), Atri
override fun adjustStackTrace(stackTrace: Sequence<StackTraceElement>): Sequence<StackTraceElement> = override fun adjustStackTrace(stackTrace: Sequence<StackTraceElement>): Sequence<StackTraceElement> =
stackTrace.takeWhile { stackTrace.takeWhile {
!it.className.startsWith("org.junit") && !it.className.startsWith("org.junit") &&
!it.className.startsWith("org.jetbrains.spek") && !it.className.startsWith("org.jetbrains.spek") &&
!it.className.startsWith("io.kotlintest") !it.className.startsWith("org.spekframework.spek2") &&
!it.className.startsWith("io.kotlintest")
} }
} }

View File

@@ -60,7 +60,7 @@ internal class ResourceBundleBasedTranslator(
* [primaryLocale] or one of its secondary alternatives -- the [fallbackLocales] are used in the * [primaryLocale] or one of its secondary alternatives -- the [fallbackLocales] are used in the
* given order. * given order.
*/ */
fun create(primaryLocale: Locale, vararg fallbackLocales: Locale) fun create(primaryLocale: Locale, vararg fallbackLocales: Locale) =
= ResourceBundleBasedTranslator(primaryLocale, fallbackLocales.toList()) ResourceBundleBasedTranslator(primaryLocale, fallbackLocales.toList())
} }
} }

View File

@@ -1,2 +1,2 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = ist (de) ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=ist (de)
ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE = ist nicht ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE=ist nicht

View File

@@ -1 +1 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = ist ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=ist

View File

@@ -1,6 +1,6 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = est ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=est
ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE = n'est pas ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE=n'est pas
ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_NOT_SAME = n'est pas la m\u00EAme instance que ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_NOT_SAME=n'est pas la m\u00EAme instance que
ch.tutteli.atrium.specs.AssertionVerb-ASSERT = il applique que ch.tutteli.atrium.specs.AssertionVerb-ASSERT=il applique que
ch.tutteli.atrium.specs.reporting.translating.TranslatorIntSpec.TestTranslatable-DATE_KNOWN=%tD \u00E9tait %<tA!! ch.tutteli.atrium.specs.reporting.translating.TranslatorIntSpec.TestTranslatable-DATE_KNOWN=%tD \u00E9tait %<tA!!
ch.tutteli.atrium.specs.reporting.translating.TranslatorIntSpec.TestTranslatable-PLACEHOLDER=Caract\u00E8re de remplacement %s ch.tutteli.atrium.specs.reporting.translating.TranslatorIntSpec.TestTranslatable-PLACEHOLDER=Caract\u00E8re de remplacement %s

View File

@@ -1,4 +1,4 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE =TO_BE zh ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=TO_BE zh
ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE=NOT_TO_BE zh ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE=NOT_TO_BE zh
ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_NOT_SAME=IS_NOT_SAME zh ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_NOT_SAME=IS_NOT_SAME zh
ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_SAME=IS_SAME zh ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_SAME=IS_SAME zh

View File

@@ -1,2 +1,2 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = TO_BE zh_Hans ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=TO_BE zh_Hans
ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE = NOT_TO_BE zh_Hans ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE=NOT_TO_BE zh_Hans

View File

@@ -1 +1 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = TO_BE zh_Hans_CN ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=TO_BE zh_Hans_CN

View File

@@ -1,2 +1,2 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = zh_Hant ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=zh_Hant
ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE = NOT_TO_BE zh_Hant ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE=NOT_TO_BE zh_Hant

View File

@@ -1 +1 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = TO_BE zh_Hant_HK ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=TO_BE zh_Hant_HK

View File

@@ -1 +1 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = TO_BE zh_Hant_MO ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=TO_BE zh_Hant_MO

View File

@@ -1 +1 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = TO_BE zh_Hant_TW ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=TO_BE zh_Hant_TW

View File

@@ -1 +1 @@
IS_NOT_SAME = n'est pas la m\u00EAme instance que IS_NOT_SAME=n'est pas la m\u00EAme instance que

View File

@@ -1,2 +1,2 @@
TO_BE = ist (de) TO_BE=ist (de)
NOT_TO_BE = ist nicht NOT_TO_BE=ist nicht

Some files were not shown because too many files have changed in this diff Show More