Skip to content

Commit

Permalink
Suppress deprecations, start to replace stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Nov 2, 2024
1 parent 4e36ffd commit f9bc1c1
Show file tree
Hide file tree
Showing 49 changed files with 1,693 additions and 1,490 deletions.
849 changes: 425 additions & 424 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ class IterableToHaveElementsAndAnyExpectationsSpec : Spek({
private fun getToContainSequencePair() =
"asSequence().${Sequence<*>::asIterable.name}().$toContain" to Companion::toContainInAnyOrderEntrySequence


private fun toContainInAnyOrderEntrySequence(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
//TODO 1.3.0 switch to _core
@Suppress("DEPRECATION")
expect._logic.changeSubject.unreported { it.asSequence() }.asIterable().toContain(a)

fun getToContainNullableSequencePair() =
Expand All @@ -76,7 +79,10 @@ class IterableToHaveElementsAndAnyExpectationsSpec : Spek({
private fun toContainNullableEntrySequence(
expect: Expect<Iterable<Double?>>,
a: (Expect<Double>.() -> Unit)?
) = expect._logic.changeSubject.unreported { it.asSequence() }.asIterable { toContain(a) }.asIterable()
) =
//TODO 1.3.0 switch to _core
@Suppress("DEPRECATION")
expect._logic.changeSubject.unreported { it.asSequence() }.asIterable { toContain(a) }.asIterable()
}


Expand Down
944 changes: 472 additions & 472 deletions atrium-core/api/main/atrium-core.api

Large diffs are not rendered by default.

953 changes: 479 additions & 474 deletions atrium-core/api/using-kotlin-1.9-or-newer/atrium-core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class DelegatingExpectImpl<T>(private val container: AssertionContainer
override val components: ComponentFactoryContainer
get() = container.components

@Suppress("OVERRIDE_DEPRECATION")
override fun append(assertion: Assertion): Expect<T> =
apply { container.append(assertion) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.reporting.prerendering.text.impl.assertion

import ch.tutteli.atrium.assertions.*
Expand All @@ -14,7 +16,6 @@ import ch.tutteli.atrium.reporting.reportables.Reportable
import ch.tutteli.atrium.reporting.theming.text.StyledString
import ch.tutteli.atrium.reporting.theming.text.TextIconStyler

@Suppress("DEPRECATION")
@Deprecated("Switch from Assertion to Proof, was introduced to ease the migration to Proof, will be removed with 2.0.0 at the latest")
class DefaultAssertionGroupTextPreRenderer(private val iconStyler: TextIconStyler) : TextPreRenderer {
override fun canTransform(reportable: Reportable): Boolean = reportable is AssertionGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//TODO remove file with 2.0.0
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.reporting.prerendering.text.impl.assertion

import ch.tutteli.atrium.assertions.DescriptiveAssertion
import ch.tutteli.atrium.creating.proofs.Proof
import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderControlObject
import ch.tutteli.atrium.reporting.prerendering.text.OutputNode
import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderControlObject
import ch.tutteli.atrium.reporting.prerendering.text.TypedTextPreRenderer
import ch.tutteli.atrium.reporting.prerendering.text.transformGroup

@Suppress("DEPRECATION")
@Deprecated("Switch from Assertion to Proof, was introduced to ease the migration to Proof, will be removed with 2.0.0 at the latest")
class DefaultDescriptiveAssertionTextPreRenderer :
TypedTextPreRenderer<DescriptiveAssertion>(DescriptiveAssertion::class) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.reporting.prerendering.text.impl.assertion

import ch.tutteli.atrium.assertions.*
Expand All @@ -9,7 +11,6 @@ import ch.tutteli.atrium.reporting.prerendering.text.OutputNode
import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderer
import ch.tutteli.atrium.reporting.reportables.Reportable

@Suppress("DEPRECATION")
@Deprecated("Switch from Assertion to Proof, was introduced to ease the migration to Proof, will be removed with 2.0.0 at the latest")
class DefaultExplanatoryAssertionGroupTextPreRenderer : TextPreRenderer {
override fun canTransform(reportable: Reportable): Boolean =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.reporting.prerendering.text.impl.assertion

import ch.tutteli.atrium.assertions.ExplanatoryAssertion
Expand All @@ -6,7 +8,6 @@ import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderControlObject
import ch.tutteli.atrium.reporting.prerendering.text.OutputNode
import ch.tutteli.atrium.reporting.prerendering.text.TypedTextPreRenderer

@Suppress("DEPRECATION")
@Deprecated("Switch from Assertion to Proof, was introduced to ease the migration to Proof, will be removed with 2.0.0 at the latest")
class DefaultExplanatoryAssertionTextPreRenderer(private val objFormatter: TextObjFormatter) :
TypedTextPreRenderer<ExplanatoryAssertion>(ExplanatoryAssertion::class) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.reporting.prerendering.text.impl.assertion

import ch.tutteli.atrium.assertions.RepresentationOnlyAssertion
Expand All @@ -6,7 +8,6 @@ import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderControlObject
import ch.tutteli.atrium.reporting.prerendering.text.OutputNode
import ch.tutteli.atrium.reporting.prerendering.text.TypedTextPreRenderer

@Suppress("DEPRECATION")
@Deprecated("Switch from Assertion to Proof, was introduced to ease the migration to Proof, will be removed with 2.0.0 at the latest")
class DefaultRepresentationOnlyAssertionTextPreRenderer(private val objFormatter: TextObjFormatter) :
TypedTextPreRenderer<RepresentationOnlyAssertion>(RepresentationOnlyAssertion::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ enum class DescriptionBasic(override val string: String) : Description {

/** @since 1.3.0 (but was in DescriptionBasic of atrium-translations before) */
NOT_TO_BE("not to be"),

/** @since 1.3.0 (but was since 0.18.0 in DescriptionBasic of atrium-translations before) */
TO_HAVE("to have"),

/** @since 1.3.0 (but was since 0.18.0 in DescriptionBasic of atrium-translations before) */
NOT_TO_HAVE("not to have"),
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.tutteli.atrium.reporting.reportables.descriptions

import ch.tutteli.atrium.reporting.reportables.Description
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable

/**
* Contains [Description]s that are related to expectation functions which are applicable to [CharSequence].
Expand All @@ -28,13 +27,9 @@ enum class DescriptionCharSequenceProof(override val string: String) : Descripti
/** @since 1.3.0 (but was since 0.18.0 in atrium-translations DescriptionCharSequenceExpectation) */
NOT_FOUND("but no match was found"),

/** @since 1.3.0 (but was since 0.18.0 in atrium-translations DescriptionCharSequenceExpectation) */
NUMBER_OF_MATCHES_FOUND("and %s matches were found"),

/** @since 1.3.0 (but was since 0.18.0 in atrium-translations DescriptionCharSequenceExpectation) */
NUMBER_OF_MATCHES("number of matches"),


/** @since 1.3.0 (but was since 0.18.0 in atrium-translations DescriptionCharSequenceExpectation) */
TO_CONTAIN("to contain"),

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.tutteli.atrium.reporting.text

import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.reporting.Reporter

// TODO 1.3.0 KDOC
Expand All @@ -10,6 +9,6 @@ interface TextReporter : Reporter {
ReplaceWith("sb.append(this.createReport(assertion))"),
level = DeprecationLevel.ERROR
)
override fun format(@Suppress("DEPRECATION") assertion: Assertion, sb: StringBuilder) =
override fun format(@Suppress("DEPRECATION") assertion: ch.tutteli.atrium.assertions.Assertion, sb: StringBuilder) =
throw UnsupportedOperationException("no longer supported")
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package ch.tutteli.atrium.reporting.translating
@Suppress("DEPRECATION")
@Deprecated(
"Will be removed with 2.0.0 at the latest",
ReplaceWith("Text(getDefault())", "ch.tutteli.atrium.reporting.Text")
ReplaceWith("Text(representation)", "ch.tutteli.atrium.reporting.Text")
)
class Untranslatable(representation: String) : Translatable {
override val name: String = representation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO remove file with 2.0.0 at the latest
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.assertions.builders

import ch.tutteli.atrium.assertions.Assertion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO remove file with 2.0.0 at the latest
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.reporting

import ch.tutteli.atrium.reporting.impl.DefaultAssertionFormatterController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package ch.tutteli.atrium.reporting
import ch.tutteli.atrium.api.infix.en_GB.feature
import ch.tutteli.atrium.api.infix.en_GB.toEqual
import ch.tutteli.atrium.api.verbs.internal.expect
import ch.tutteli.atrium.assertions.BasicDescriptiveAssertion
import ch.tutteli.atrium.core.falseProvider
import ch.tutteli.atrium.creating.proofs.Proof
import ch.tutteli.atrium.reporting.erroradjusters.NoOpAtriumErrorAdjuster
import ch.tutteli.atrium.reporting.translating.Untranslatable
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe

Expand All @@ -15,7 +14,7 @@ class AtriumErrorSpec : Spek({
it("has `null` as cause - regression for #303") {
val e = AtriumError.create(
"hello world",
BasicDescriptiveAssertion(Untranslatable("no really the reason"), 1, falseProvider),
Proof.simple(Text("no really the reason"), 1, falseProvider),
NoOpAtriumErrorAdjuster
)
expect(e).feature(Throwable::cause) toEqual null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.reporting

import ch.tutteli.atrium.api.infix.en_GB.toEqual
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.reporting

import ch.tutteli.atrium.assertions.BulletPointIdentifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.reporting.text

import ch.tutteli.atrium.api.infix.en_GB.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.reporting.translating

import ch.tutteli.atrium.api.infix.en_GB.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.core.polyfills

import ch.tutteli.atrium.api.infix.en_GB.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.core.polyfills

import ch.tutteli.atrium.api.infix.en_GB.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//TODO 2.0.0 remove file
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.core.polyfills

import ch.tutteli.atrium.assertions.Assertion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package ch.tutteli.atrium.reporting.erroradjusters

import ch.tutteli.atrium._core
import ch.tutteli.atrium.api.infix.en_GB.*
import ch.tutteli.atrium.api.verbs.internal.expect
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
import ch.tutteli.atrium.core.polyfills.stackBacktrace
import ch.tutteli.atrium.creating.ComponentFactoryContainer
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer
import ch.tutteli.atrium.creating.build
import ch.tutteli.atrium.creating.*
import ch.tutteli.atrium.logic._logic
import ch.tutteli.atrium.logic.creating.RootExpectBuilder
import ch.tutteli.atrium.reporting.AtriumErrorAdjuster
Expand All @@ -22,7 +20,12 @@ class AdjustStackTest {
}

private fun <T> expectWithNoOpErrorAdjuster(subject: T, assertionCreator: Expect<T>.() -> Unit): Expect<T> =
expectWithNoOpErrorAdjuster(subject)._logic.appendAsGroup(assertionCreator)
expectWithNoOpErrorAdjuster(subject)._core.appendAsGroupIndicateIfOneCollected(
ExpectationCreatorWithUsageHints(
usageHintsOverloadWithoutExpectationCreator = emptyList(),
expectationCreator = assertionCreator
)
).first

@Test
fun noOp_containsMochaAndAtrium() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//TODO remove with 2.0.0 at the latest
@file:Suppress("DEPRECATION")

import ch.tutteli.atrium._coreAppend
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
import ch.tutteli.atrium.api.verbs.expect
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.creating.ProofContainer
import ch.tutteli.atrium.creating.proofs.Proof
import ch.tutteli.atrium.creating.proofs.builders.buildSimpleProof
import ch.tutteli.atrium.logic._logic
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable
import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE
import kotlin.test.Test

//TODO 1.3.0 SmokeTest with Proof
class AssertionSmokeTest {

@Test
fun toEqual_canBeUsed() {
expect(1).toEqual(1)
}

@Test
fun expectationFunctionWithoutI18nCanBeUsed() {
expect(2).toBeEvenDeprecated()
expect(1).toBeOddDeprecated()
}

@Test
fun expectationFunctionWithI18nCanBeUsed() {
expect(4).toBeAMultipleOfDeprecated(2)
}

}

fun Expect<Int>.toBeEvenDeprecated() =
_logic.append(_logic.createDescriptiveAssertion(TO_BE, Text("an even number")) { it % 2 == 0 })

fun Expect<Int>.toBeOddDeprecated() =
_logic.append(_logic.createDescriptiveAssertion(TO_BE, Text("an odd number")) { it % 2 == 1})

fun Expect<Int>.toBeAMultipleOfDeprecated(base: Int): Expect<Int> = _coreAppend { toBeAMultipleOfDeprecated(base) }

private fun ProofContainer<Int>.toBeAMultipleOfDeprecated(base: Int): Proof =
buildSimpleProof(DescriptionIntAssertions.TO_BE_MULTIPLE_OF, base) { it % base == 0 }

enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable {
TO_BE_MULTIPLE_OF("to be multiple of")
}
23 changes: 10 additions & 13 deletions bundles/fluent/atrium-fluent/src/commonTest/kotlin/SmokeTest.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import ch.tutteli.atrium._core
import ch.tutteli.atrium._coreAppend
import ch.tutteli.atrium.api.fluent.en_GB.messageToContain
import ch.tutteli.atrium.api.fluent.en_GB.notToThrow
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
import ch.tutteli.atrium.api.fluent.en_GB.toThrow
import ch.tutteli.atrium.api.fluent.en_GB.*
import ch.tutteli.atrium.api.verbs.ExpectationVerb
import ch.tutteli.atrium.api.verbs.expect
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.creating.ProofContainer
import ch.tutteli.atrium.creating.proofs.Proof
import ch.tutteli.atrium.creating.proofs.buildSimpleProof
import ch.tutteli.atrium.creating.proofs.builders.buildSimpleProof
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.reportables.Description
import ch.tutteli.atrium.reporting.reportables.descriptions.DescriptionAnyProof
import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE
import ch.tutteli.atrium.reporting.reportables.descriptions.DescriptionBasic.TO_BE
import kotlin.test.Test

class SmokeTest {
Expand All @@ -40,11 +37,11 @@ class SmokeTest {
expect(2).toEqual(1)
}
}.toThrow<AssertionError> {
messageToContain(
"${ExpectationVerb.EXPECT.string}: 1",
"${ExpectationVerb.EXPECT.string}: 2",
"${DescriptionAnyProof.TO_EQUAL.string}: 1"
)
message {
toContainRegex("${ExpectationVerb.EXPECT.string}\\s+: 1")
toContainRegex("${ExpectationVerb.EXPECT.string}\\s+: 2")
toContainRegex("${DescriptionAnyProof.TO_EQUAL.string}\\s+: 1")
}
}
}

Expand Down Expand Up @@ -81,8 +78,8 @@ fun Expect<Int>.toBeOdd() =
fun Expect<Int>.toBeAMultipleOf(base: Int): Expect<Int> = _coreAppend { toBeAMultipleOf(base) }

private fun ProofContainer<Int>.toBeAMultipleOf(base: Int): Proof =
buildSimpleProof(DescriptionIntAssertions.TO_BE_MULTIPLE_OF, base) { it % base == 0 }
buildSimpleProof(DescriptionIntProofs.TO_BE_MULTIPLE_OF, base) { it % base == 0 }

enum class DescriptionIntAssertions(override val string: String) : Description {
enum class DescriptionIntProofs(override val string: String) : Description {
TO_BE_MULTIPLE_OF("to be multiple of")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ch.tutteli.atrium.api.verbs.expect
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.creating.ProofContainer
import ch.tutteli.atrium.creating.proofs.Proof
import ch.tutteli.atrium.creating.proofs.buildSimpleProof
import ch.tutteli.atrium.creating.proofs.builders.buildSimpleProof
import ch.tutteli.atrium.reporting.Text
import ch.tutteli.atrium.reporting.reportables.Description
import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE
Expand Down
Loading

0 comments on commit f9bc1c1

Please sign in to comment.