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

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

View File

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

View File

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

View File

@@ -298,6 +298,7 @@ def createRegisterJsServicesTask(String projectName, String packageName, Functio
doLast {
services.write("""\
@file:Suppress("DEPRECATION")
package $packageName
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.assertions.Assertion
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.translating.StringBasedTranslatable
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 _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 {
IS_MULTIPLE_OF("is multiple of")

View File

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

View File

@@ -16,7 +16,8 @@ interface DescriptiveAssertion : Assertion {
val representation: Any
@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.

View File

@@ -10,5 +10,5 @@ package ch.tutteli.atrium.assertions
*/
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
@Deprecated("So far indentation was achieved by grouping (which is the solution to go). See AssertImpl.builder for different groups. Will be removed with 1.0.0")
class IndentAssertionGroup(assertions: List<Assertion>)
: EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, assertions)
class IndentAssertionGroup(assertions: List<Assertion>) :
EmptyNameAndRepresentationAssertionGroup(DefaultIndentAssertionGroupType, assertions)

View File

@@ -9,5 +9,5 @@ package ch.tutteli.atrium.assertions
*/
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */)
@Deprecated("Use AssertionGroup, do not rely on this specific type, will be made internal with 1.0.0")
class InvisibleAssertionGroup internal constructor(assertions: List<Assertion>)
: EmptyNameAndRepresentationAssertionGroup(InvisibleAssertionGroupType, assertions)
class InvisibleAssertionGroup internal constructor(assertions: List<Assertion>) :
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].
* @param T the type of the [Assertion].
*/
interface AssertionBuilderFinalStep<T: Assertion> {
interface AssertionBuilderFinalStep<T : Assertion> {
/**
* 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.AssertionGroupType
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.Untranslatable
import ch.tutteli.atrium.reporting.RawString
/**
* Option step which allows to specify the [AssertionGroup.description] -- [RawString.EMPTY] is
* used as [AssertionGroup.representation].
*/
interface AssertionGroupDescriptionAndEmptyRepresentationOption<out T: AssertionGroupType, R> {
interface AssertionGroupDescriptionAndEmptyRepresentationOption<out T : AssertionGroupType, R> {
/**
* The previously defined [AssertionGroup.type].
*/
@@ -35,9 +35,10 @@ interface AssertionGroupDescriptionAndEmptyRepresentationOption<out T: Assertion
* Factory method to create a [AssertionGroupDescriptionAndEmptyRepresentationOption] step in the building
* process of an [AssertionGroup].
*/
fun <T: AssertionGroupType, R> create(
fun <T : AssertionGroupType, R> create(
type: T,
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].
*/
fun withAssertions(assertion1: Assertion, assertion2: Assertion, assertion3: Assertion): R
= withAssertions(listOf(assertion1, assertion2, assertion3))
fun withAssertions(assertion1: Assertion, assertion2: Assertion, assertion3: Assertion): R =
withAssertions(listOf(assertion1, assertion2, assertion3))
/**
* Uses the given [assertions] as [AssertionGroup.assertions].
@@ -82,8 +82,12 @@ interface AssertionsOption<out T : AssertionGroupType, out R> {
*/
fun <T : AssertionGroupType> withDefaultFinalStepAndEmptyDescriptionAndRepresentation(
groupType: T
): AssertionsOption<T, BasicAssertionGroupFinalStep>
= AssertionsOptionImpl(groupType, Untranslatable.EMPTY, RawString.EMPTY, BasicAssertionGroupFinalStep.Companion::create)
): AssertionsOption<T, BasicAssertionGroupFinalStep> = AssertionsOptionImpl(
groupType,
Untranslatable.EMPTY,
RawString.EMPTY,
BasicAssertionGroupFinalStep.Companion::create
)
/**
* 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 */
"UNCHECKED_CAST"
)
val factory = factoryWithDefaultFinalStep as (T, Translatable, Any) -> AssertionsOption<T, BasicAssertionGroupFinalStep>
val factory =
factoryWithDefaultFinalStep as (T, Translatable, Any) -> AssertionsOption<T, BasicAssertionGroupFinalStep>
return factory
}
private val factoryWithDefaultFinalStep: (AssertionGroupType, Translatable, Any) -> AssertionsOption<AssertionGroupType, BasicAssertionGroupFinalStep>
= { t, d, r ->
private val factoryWithDefaultFinalStep: (AssertionGroupType, Translatable, Any) -> AssertionsOption<AssertionGroupType, BasicAssertionGroupFinalStep> =
{ t, d, r ->
AssertionsOptionImpl(t, d, r, BasicAssertionGroupFinalStep.Companion::create)
}
}

View File

@@ -42,6 +42,8 @@ interface BasicAssertionGroupFinalStep : AssertionBuilderFinalStep<AssertionGrou
description: Translatable,
representation: Any,
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,
* then wrap it into a [RawString] via [RawString.create] and pass the [RawString] instead.
*/
fun withDescriptionAndRepresentation(description: String, representation: Any?): R
= withDescriptionAndRepresentation(Untranslatable(description), representation)
fun withDescriptionAndRepresentation(description: String, representation: Any?): R =
withDescriptionAndRepresentation(Untranslatable(description), 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].
*/
interface ExplanationOption{
interface ExplanationOption {
/**
* 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
* how the [Translatable] is used as [ExplanatoryAssertion.explanation].
*/
fun withExplanation(translatable: Translatable, arg: Any, vararg otherArgs: Any): FinalStep
= withExplanation(TranslatableWithArgs(translatable, arg glue otherArgs))
fun withExplanation(translatable: Translatable, arg: Any, vararg otherArgs: Any): FinalStep =
withExplanation(TranslatableWithArgs(translatable, arg glue otherArgs))
/**
* Uses the given [description] as explanation.
*/
fun withExplanation(description: String): FinalStep
= withExplanation(Untranslatable(description))
fun withExplanation(description: String): FinalStep = withExplanation(Untranslatable(description))
/**
* 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
* given [translatable] and treats the result as raw string.
*/
fun withExplanation(translatable: Translatable): FinalStep
= withExplanation(RawString.create(translatable))
fun withExplanation(translatable: Translatable): FinalStep = withExplanation(RawString.create(translatable))
/**
* 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,
* 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)"))
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, 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)
@Deprecated("use withExplanation instead; will be removed with 1.0.0", ReplaceWith("this.withExplanation(explanation)"))
fun withDescription(explanation: Any?) : FinalStep = withExplanation(explanation)
@Deprecated(
"use withExplanation instead; will be removed with 1.0.0",
ReplaceWith("this.withExplanation(explanation)")
)
fun withDescription(explanation: Any?): FinalStep = withExplanation(explanation)
companion object {
@@ -78,7 +85,7 @@ interface Explanatory {
/**
* 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].
*/

View File

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

View File

@@ -5,28 +5,28 @@ import ch.tutteli.atrium.assertions.builders.*
internal object AssertionBuilderImpl : AssertionBuilder {
override val list: DefaultAssertionGroupBuilderOptions<ListAssertionGroupType>
= createDescriptionAndRepresentationOption(DefaultListAssertionGroupType)
override val list: DefaultAssertionGroupBuilderOptions<ListAssertionGroupType> =
createDescriptionAndRepresentationOption(DefaultListAssertionGroupType)
override val feature: DefaultAssertionGroupBuilderOptions<FeatureAssertionGroupType>
= createDescriptionAndRepresentationOption(DefaultFeatureAssertionGroupType)
override val feature: DefaultAssertionGroupBuilderOptions<FeatureAssertionGroupType> =
createDescriptionAndRepresentationOption(DefaultFeatureAssertionGroupType)
override val summary: AssertionGroupDescriptionAndEmptyRepresentationOption<SummaryAssertionGroupType, AssertionsOption<SummaryAssertionGroupType, BasicAssertionGroupFinalStep>>
= AssertionGroupDescriptionAndEmptyRepresentationOption.create(DefaultSummaryAssertionGroupType, AssertionsOption.factoryWithDefaultFinalStep())
override val summary: AssertionGroupDescriptionAndEmptyRepresentationOption<SummaryAssertionGroupType, AssertionsOption<SummaryAssertionGroupType, BasicAssertionGroupFinalStep>> =
AssertionGroupDescriptionAndEmptyRepresentationOption.create(
DefaultSummaryAssertionGroupType,
AssertionsOption.factoryWithDefaultFinalStep()
)
override val explanatoryGroup: ExplanatoryGroup.GroupTypeOption
= ExplanatoryGroup.GroupTypeOption.create()
override val explanatoryGroup: ExplanatoryGroup.GroupTypeOption = ExplanatoryGroup.GroupTypeOption.create()
override val descriptive: Descriptive.HoldsOption
= Descriptive.HoldsOption.create()
override val descriptive: Descriptive.HoldsOption = Descriptive.HoldsOption.create()
override val explanatory: Explanatory.ExplanationOption
= Explanatory.ExplanationOption.create()
override val explanatory: Explanatory.ExplanationOption = Explanatory.ExplanationOption.create()
override fun <T : AssertionGroupType> customType(groupType: T): DefaultAssertionGroupBuilderOptions<T>
= createDescriptionAndRepresentationOption(groupType)
override fun <T : AssertionGroupType> customType(groupType: T): DefaultAssertionGroupBuilderOptions<T> =
createDescriptionAndRepresentationOption(groupType)
private fun <T: AssertionGroupType> createDescriptionAndRepresentationOption(type: T): DefaultAssertionGroupBuilderOptions<T>
= AssertionGroupDescriptionAndRepresentationOption.create(type, AssertionsOption.factoryWithDefaultFinalStep())
private fun <T : AssertionGroupType> createDescriptionAndRepresentationOption(type: T): DefaultAssertionGroupBuilderOptions<T> =
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.translating.Translatable
internal class AssertionGroupDescriptionAndEmptyRepresentationOptionImpl<out T: AssertionGroupType, R>(
internal class AssertionGroupDescriptionAndEmptyRepresentationOptionImpl<out T : AssertionGroupType, R>(
override val groupType: T,
private val factory: (T, Translatable, Any) -> 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
) : AssertionsOption<T, R> {
override fun withAssertions(assertions: List<Assertion>): R
= factory(groupType, description, representation, assertions)
override fun withAssertions(assertions: List<Assertion>): R =
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>>
get() = createDescriptionAndRepresentationOption(false)
override fun withClaim(holds: Boolean): AssertionGroupDescriptionAndRepresentationOption<T, AssertionsOption<T, R>>
= createDescriptionAndRepresentationOption(holds)
override fun withClaim(holds: Boolean): AssertionGroupDescriptionAndRepresentationOption<T, AssertionsOption<T, R>> =
createDescriptionAndRepresentationOption(holds)
private fun createDescriptionAndRepresentationOption(holds: Boolean)
= AssertionGroupDescriptionAndRepresentationOption.create(groupType, createAssertionOptionWithHolds(holds))
private fun createDescriptionAndRepresentationOption(holds: Boolean) =
AssertionGroupDescriptionAndRepresentationOption.create(groupType, createAssertionOptionWithHolds(holds))
private fun createAssertionOptionWithHolds(holds: Boolean): (T, Translatable, Any) -> AssertionsOption<T, R>
= { t, d, r -> AssertionsOption.create(t, d, r, createFixedClaimLikeAssertionGroupFinalStep(holds)) }
private fun createAssertionOptionWithHolds(holds: Boolean): (T, Translatable, Any) -> AssertionsOption<T, R> =
{ t, d, r -> AssertionsOption.create(t, d, r, createFixedClaimLikeAssertionGroupFinalStep(holds)) }
protected abstract fun createFixedClaimLikeAssertionGroupFinalStep(
holds: Boolean

View File

@@ -1,6 +1,6 @@
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.core.trueProvider
import ch.tutteli.atrium.creating.SubjectProvider
@@ -46,6 +46,7 @@ internal class FinalStepImpl(
override val representation: Any
) : Descriptive.FinalStep {
@Suppress("DEPRECATION")
override fun build(): DescriptiveAssertion = BasicDescriptiveAssertion(description, representation, test)
@Suppress("DEPRECATION" /* TODO remove annotation with 1.0.0 */)
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
import ch.tutteli.atrium.assertions.*
import ch.tutteli.atrium.assertions.ExplanatoryAssertion
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)
}
internal class FinalStepImpl(override val explanation: Any?) : Explanatory.FinalStep {
@Suppress("DEPRECATION" /* TODO remove with 1.0.0 */ )
override fun build(): ExplanatoryAssertion = BasicExplanatoryAssertion(explanation)
@Suppress("DEPRECATION" /* TODO remove annotation with 1.0.0 */)
override fun build(): ExplanatoryAssertion = ch.tutteli.atrium.assertions.BasicExplanatoryAssertion(explanation)
}

View File

@@ -1,6 +1,8 @@
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
internal data class FixedClaimAssertionGroup(

View File

@@ -1,6 +1,8 @@
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
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 */)
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.
* @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].

View File

@@ -31,8 +31,8 @@ interface AssertionPlant<out T : Any> : BaseAssertionPlant<T, 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
* to the plant.
* Creates a [DescriptiveAssertion] based on the given [description], [expected] and [test] and
* [adds][addAssertion] it to the plant.
*
* @param description The description of the assertion, e.g., `is less than`.
* @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
* evaluated (see [ReportingAssertionPlant]).
*/
fun createAndAddAssertion(description: Translatable, expected: Any, test: () -> Boolean): AssertionPlant<T>
= addAssertion(assertionBuilder.createDescriptive(description, expected, test))
fun createAndAddAssertion(description: Translatable, expected: Any, test: () -> Boolean): AssertionPlant<T> =
addAssertion(assertionBuilder.createDescriptive(description, expected, test))
}

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
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
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.checking.AssertionChecker
import ch.tutteli.atrium.core.evalOnce
import ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields
import ch.tutteli.atrium.reporting.translating.Translatable
/**

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,7 +18,7 @@ sealed class MaybeSubject<out T> {
*/
@Suppress("DEPRECATION")
@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 PlantHasNoSubjectException if this method is called.
@@ -33,7 +33,7 @@ sealed class MaybeSubject<out T> {
*/
@Suppress("DEPRECATION")
@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].
*/
@@ -42,7 +42,7 @@ sealed class MaybeSubject<out T> {
companion object {
@Suppress("DEPRECATION")
operator fun <T: Any> invoke(subject: T?) =
operator fun <T : Any> invoke(subject: T?) =
if (subject == null) Absent
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")
class PlantHasNoSubjectException
@Deprecated("Use the constructor without argument; will be removed with 1.0.0", ReplaceWith("PlantHasNoSubjectException()"))
constructor(message: String) : RuntimeException(message){
@Deprecated(
"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 */)
constructor(): this(
constructor() : this(
"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"
)

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
package ch.tutteli.atrium.creating
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.None
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.core.Some
import ch.tutteli.atrium.core.None
/**
* Provides the subject of an [Assertion].

View File

@@ -97,7 +97,11 @@ interface AssertionFormatter {
* 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].
*/
fun formatGroup(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject, formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit)
fun formatGroup(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject,
formatAssertions: (AssertionFormatterParameterObject, (Assertion) -> Unit) -> Unit
)
companion object {
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.AssertionGroup
import ch.tutteli.atrium.assertions.InvisibleAssertionGroupType
import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType
import ch.tutteli.atrium.assertions.InvisibleAssertionGroupType
import ch.tutteli.atrium.core.CoreFactory
/**
@@ -52,8 +52,8 @@ interface AssertionFormatterController {
*
* @return `true` if it is an explanatory assertion group; `false` otherwise.
*/
fun isExplanatoryAssertionGroup(assertion: Assertion)
= assertion is AssertionGroup && assertion.type is ExplanatoryAssertionGroupType
fun isExplanatoryAssertionGroup(assertion: Assertion) =
assertion is AssertionGroup && assertion.type is ExplanatoryAssertionGroupType
companion object {
/**

View File

@@ -54,8 +54,14 @@ class AssertionFormatterParameterObject private constructor(
*
* @return The newly created [AssertionFormatterParameterObject].
*/
fun createChildWithNewPrefixAndAdditionalIndent(newPrefix: String, additionalIndent: Int)
= AssertionFormatterParameterObject(sb, newPrefix, indentLevel + prefix.length + additionalIndent, assertionFilter, numberOfDoNotFilterGroups)
fun createChildWithNewPrefixAndAdditionalIndent(newPrefix: String, additionalIndent: Int) =
AssertionFormatterParameterObject(
sb,
newPrefix,
indentLevel + prefix.length + additionalIndent,
assertionFilter,
numberOfDoNotFilterGroups
)
/**
@@ -65,8 +71,8 @@ class AssertionFormatterParameterObject private constructor(
*
* @return The newly created [AssertionFormatterParameterObject].
*/
fun createForDoNotFilterAssertionGroup(): AssertionFormatterParameterObject
= AssertionFormatterParameterObject(sb, prefix, indentLevel, assertionFilter, numberOfDoNotFilterGroups + 1)
fun createForDoNotFilterAssertionGroup(): AssertionFormatterParameterObject =
AssertionFormatterParameterObject(sb, prefix, indentLevel, assertionFilter, numberOfDoNotFilterGroups + 1)
/**
* 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].
*/
fun indent(numberOfSpaces: Int){
fun indent(numberOfSpaces: Int) {
for (i in 0 until numberOfSpaces) {
sb.append(' ')
}

View File

@@ -18,7 +18,11 @@ interface AssertionPairFormatter {
* @param assertionGroup The [AssertionGroup] of which we want to format the header.
* @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]

View File

@@ -1,7 +1,7 @@
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.Untranslatable
/**
* 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.
*/
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.

View File

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

View File

@@ -1,6 +1,7 @@
package ch.tutteli.atrium.reporting.translating
import ch.tutteli.atrium.core.CoreFactory
/**
* 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 {
private fun createList(arg: Any): List<Any>
= ArrayList<Any>(1).apply {
private fun createList(arg: Any): List<Any> = ArrayList<Any>(1).apply {
add(arg)
}
private fun createList(arg1: Any, arg2: Any): List<Any>
= ArrayList<Any>(2).apply {
private fun createList(arg1: Any, arg2: Any): List<Any> = ArrayList<Any>(2).apply {
add(arg1)
add(arg2)
}
private fun createList(arg1: Any, arg2: Any, otherArgs: Array<out Any>): List<Any>
= ArrayList<Any>(2 + otherArgs.size).apply {
private fun createList(arg1: Any, arg2: Any, otherArgs: Array<out Any>): List<Any> =
ArrayList<Any>(2 + otherArgs.size).apply {
add(arg1)
add(arg2)
addAll(otherArgs)

View File

@@ -1,7 +1,5 @@
package ch.tutteli.atrium.reporting.translating
import ch.tutteli.atrium.core.polyfills.format
/**
* This translator does not translate but uses [Translatable.getDefault] instead
* 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.checking.AssertionChecker
import ch.tutteli.atrium.creating.*
import ch.tutteli.atrium.creating.ReportingAssertionPlantNullable
import ch.tutteli.atrium.reporting.RawString
import ch.tutteli.atrium.reporting.Reporter
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.
*
* It creates a [newThrowingAssertionChecker] based on the given [reporter] for assertion checking,
* uses [subjectProvider] as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* uses [subjectProvider] as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once).
*
* 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
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @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.
*
* It uses the given [assertionChecker] for assertion checking, uses [subjectProvider] as
* [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once).
*
* 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
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @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.
*/

View File

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

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /*TODO remove with 1.0.0 */)
package ch.tutteli.atrium.core.polyfills
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.checking.AssertionChecker
import ch.tutteli.atrium.creating.*
import ch.tutteli.atrium.creating.ReportingAssertionPlantNullable
import ch.tutteli.atrium.reporting.AssertionFormatterFacade
import ch.tutteli.atrium.reporting.RawString
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.
*
* It creates a [newThrowingAssertionChecker] based on the given [reporter] for assertion checking,
* uses [subjectProvider] as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* uses [subjectProvider] as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once).
*
* 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
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @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].
*
* @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.
*
* It uses the given [assertionChecker] for assertion checking, uses [subjectProvider] as
* [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but also as
* [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* Notice that [evalOnce] is applied to the given [subjectProvider] to avoid side effects
* (the provider is most likely called more than once).
*
* 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
* (see [AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [AssertionPlantWithCommonFields.CommonFields.representationProvider].
* (see [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.assertionVerb]).
* @param subjectProvider Used as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.subjectProvider] but
* also as [ch.tutteli.atrium.creating.AssertionPlantWithCommonFields.CommonFields.representationProvider].
* @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.
*/
@@ -112,6 +112,4 @@ actual interface CoreFactory : CoreFactoryCommon {
): ReportingAssertionPlantNullable<T> = newReportingPlantNullableFromCommon(
assertionVerb, subjectProvider, assertionChecker, nullRepresentation
)
}

View File

@@ -5,10 +5,9 @@ import ch.tutteli.kbox.blankToNull
@Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("Only here to ease migration, use Atrium's Locale directly; will be removed with 1.0.0")
fun java.util.Locale.toAtriumLocale(): Locale
= ch.tutteli.atrium.reporting.translating.Locale(
fun java.util.Locale.toAtriumLocale(): Locale = ch.tutteli.atrium.reporting.translating.Locale(
language,
script.blankToNull(),
country.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.toJavaLocale
import kotlin.String
actual fun String.format(locale: Locale, arg: Any, vararg otherArgs: Any): String {
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
* (adjusting might filter the [stackTrace]).
*/
actual fun create(message: String, atriumErrorAdjuster: AtriumErrorAdjuster): AtriumError
= createAtriumError(message, atriumErrorAdjuster)
actual fun create(message: String, atriumErrorAdjuster: AtriumErrorAdjuster): AtriumError =
createAtriumError(message, atriumErrorAdjuster)
}
}

View File

@@ -42,7 +42,8 @@ class FeatureAssertionChecker(private val originalAssertionHolder: AssertionHold
* @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>) {
originalAssertionHolder.addAssertion(assertionBuilder.feature
originalAssertionHolder.addAssertion(
assertionBuilder.feature
.withDescriptionAndRepresentation(assertionVerb, representation)
.withAssertions(ArrayList(assertions))
.build()

View File

@@ -1,4 +1,5 @@
@file:Suppress("DEPRECATION" /* will be removed with 1.0.0 */)
package ch.tutteli.atrium.core.robstoll.lib.creating
import ch.tutteli.atrium.assertions.Assertion
@@ -14,7 +15,7 @@ abstract class MutableListBasedAssertionPlant<out T : Any?, out A : BaseAssertio
@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."
)
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.

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,7 +29,10 @@ abstract class NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<in T :
) : 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) {
assertionFormatterController.format(it, childParameterObject)
}

View File

@@ -24,8 +24,8 @@ class OnlyFailureReporter(
* 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].
*/
override fun format(assertion: Assertion, sb: StringBuilder)
= assertionFormatterFacade.format(assertion, sb, this::assertionFilter)
override fun format(assertion: Assertion, sb: StringBuilder) =
assertionFormatterFacade.format(assertion, sb, this::assertionFilter)
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
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
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]
* is [T] or a sub type.
*/
final override fun canFormat(assertion: Assertion)
= assertion is AssertionGroup && clazz.isInstance(assertion.type)
final override fun canFormat(assertion: Assertion) = assertion is AssertionGroup && clazz.isInstance(assertion.type)
/**
* Always throws an [UnsupportedOperationException], because this [AssertionFormatter] can only format
@@ -38,8 +37,10 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
*
* @throws UnsupportedOperationException always!
*/
final override fun formatNonGroup(assertion: Assertion, parameterObject: AssertionFormatterParameterObject)
= throw UnsupportedOperationException("supports only ${clazz.fullName} for which one has to call ${AssertionFormatter::formatGroup.name}")
final override fun formatNonGroup(assertion: Assertion, parameterObject: AssertionFormatterParameterObject) =
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]
@@ -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.
*/
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)
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)
formatGroupAssertions(formatAssertions, childParameterObject)
}
@@ -80,7 +89,10 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
*
* @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
@@ -92,5 +104,8 @@ abstract class SingleAssertionGroupTypeFormatter<in T : AssertionGroupType>(
* @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.
*/
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(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<ExplanatoryAssertionGroupType>(ExplanatoryAssertionGroupType::class, assertionFormatterController) {
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<ExplanatoryAssertionGroupType>(
ExplanatoryAssertionGroupType::class,
assertionFormatterController
) {
private val explanatoryBulletPoint = bulletPoints[ExplanatoryAssertionGroupType::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) {
WarningAssertionGroupType -> warningBulletPoint
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)
}
private fun appendExplanatoryAssertion(assertion: ExplanatoryAssertion, parameterObject: AssertionFormatterParameterObject) {
private fun appendExplanatoryAssertion(
assertion: ExplanatoryAssertion,
parameterObject: AssertionFormatterParameterObject
) {
parameterObject.sb.append(objectFormatter.format(assertion.explanation))
}
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())
}
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)
formatAssertions(childParameterObject) {
assertionFormatterController.format(it, childParameterObject)
@@ -82,7 +93,9 @@ class TextFallbackAssertionFormatter(
private fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject
) = when (assertionGroup.type) {
RootAssertionGroupType -> formatter.formatAfterAppendLnEtc(assertionPairFormatter, assertionGroup, parameterObject)
RootAssertionGroupType -> formatter.formatAfterAppendLnEtc(
assertionPairFormatter, assertionGroup, parameterObject
)
else -> formatter.formatWithGroupName(assertionPairFormatter, assertionGroup, parameterObject)
}

View File

@@ -37,12 +37,18 @@ class TextFeatureAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController,
private val assertionPairFormatter: AssertionPairFormatter
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<FeatureAssertionGroupType>(FeatureAssertionGroupType::class, assertionFormatterController) {
) : NoSpecialChildFormattingSingleAssertionGroupTypeFormatter<FeatureAssertionGroupType>(
FeatureAssertionGroupType::class,
assertionFormatterController
) {
private val prefix = (bulletPoints[FeatureAssertionGroupType::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()
val translatable = TranslatableWithArgs(Untranslatable("$arrow%s"), assertionGroup.description)
val group =

View File

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

View File

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

View File

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

View File

@@ -7,12 +7,20 @@ import ch.tutteli.atrium.reporting.AssertionPairFormatter
class TextPrefixBasedAssertionGroupFormatter(
private val prefix: String
) {
fun formatWithGroupName(assertionPairFormatter: AssertionPairFormatter, assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject {
fun formatWithGroupName(
assertionPairFormatter: AssertionPairFormatter,
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
parameterObject.appendLnIndentAndPrefix()
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)
assertionPairFormatter.formatGroupHeader(parameterObject, assertionGroup, newParameterObject)
return newParameterObject

View File

@@ -28,10 +28,18 @@ class TextSameLineAssertionPairFormatter(
private val translator: Translator
) : AssertionPairFormatter {
override fun formatGroupHeader(parameterObject: AssertionFormatterParameterObject, assertionGroup: AssertionGroup, newParameterObject: AssertionFormatterParameterObject)
= format(parameterObject, assertionGroup.description, assertionGroup.representation)
override fun formatGroupHeader(
parameterObject: AssertionFormatterParameterObject,
assertionGroup: AssertionGroup,
newParameterObject: AssertionFormatterParameterObject
): Unit = format(parameterObject, assertionGroup.description, assertionGroup.representation)
override fun format(parameterObject: AssertionFormatterParameterObject, translatable: Translatable, representation: Any) {
parameterObject.sb.append(translator.translate(translatable)).append(": ").append(objectFormatter.format(representation))
override fun format(
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 failing = (bulletPoints[PrefixFailingSummaryAssertion::class] ?: "✘ ")
override fun formatGroupHeaderAndGetChildParameterObject(assertionGroup: AssertionGroup, parameterObject: AssertionFormatterParameterObject): AssertionFormatterParameterObject {
override fun formatGroupHeaderAndGetChildParameterObject(
assertionGroup: AssertionGroup,
parameterObject: AssertionFormatterParameterObject
): AssertionFormatterParameterObject {
parameterObject.appendLnIndentAndPrefix()
assertionPairFormatter.format(parameterObject, assertionGroup.description, assertionGroup.representation)
//the prefix which should be used for assertions is defined in the formatGroupAssertions
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 failingParameterObject = childParameterObject.createChildWithNewPrefix(failing)
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.
*/
override fun adjustOtherThanStacks(throwable: Throwable){}
override fun adjustOtherThanStacks(throwable: Throwable) {}
}

View File

@@ -1,9 +1,9 @@
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.RawString
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.Translator
import kotlin.reflect.KClass

View File

@@ -8,6 +8,7 @@ actual class RemoveRunnerAtriumErrorAdjuster : FilterAtriumErrorAdjuster(), Atri
stackTrace.takeWhile {
!it.className.startsWith("org.junit") &&
!it.className.startsWith("org.jetbrains.spek") &&
!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
* given order.
*/
fun create(primaryLocale: Locale, vararg fallbackLocales: Locale)
= ResourceBundleBasedTranslator(primaryLocale, fallbackLocales.toList())
fun create(primaryLocale: Locale, vararg fallbackLocales: Locale) =
ResourceBundleBasedTranslator(primaryLocale, fallbackLocales.toList())
}
}

View File

@@ -1,2 +1,2 @@
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE = ist (de)
ch.tutteli.atrium.translations.DescriptionBasic-NOT_TO_BE = ist nicht
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=ist (de)
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-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.specs.AssertionVerb-ASSERT = il applique que
ch.tutteli.atrium.translations.DescriptionBasic-TO_BE=est
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.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-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.DescriptionAnyAssertion-IS_NOT_SAME=IS_NOT_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-NOT_TO_BE = NOT_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

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-NOT_TO_BE = NOT_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

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)
NOT_TO_BE = ist nicht
TO_BE=ist (de)
NOT_TO_BE=ist nicht

View File

@@ -1,2 +1,2 @@
TO_BE = est
NOT_TO_BE = n'est pas
TO_BE=est
NOT_TO_BE=n'est pas

View File

@@ -1,2 +1,2 @@
TO_BE = TO_BE zh_Hans
NOT_TO_BE = NOT_TO_BE zh_Hans
TO_BE=TO_BE zh_Hans
NOT_TO_BE=NOT_TO_BE zh_Hans

View File

@@ -1,2 +1,2 @@
TO_BE = TO_BE zh_Hant
NOT_TO_BE = NOT_TO_BE zh_Hant
TO_BE=TO_BE zh_Hant
NOT_TO_BE=NOT_TO_BE zh_Hant

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