From 09a58537ff27949ba9108534e093cd3fc763ee6d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 20 May 2021 22:11:44 +0200 Subject: [PATCH] rename bigDecimalAssertion functions to new schema in api-fluent --- .../api/fluent/en_GB/featureAssertions.kt | 2 +- .../atrium/api/fluent/en_GB/fun0Assertions.kt | 2 +- .../fluent/en_GB/bigDecimalExpectations.kt | 170 ++++++++++++++++++ .../en_GB/BigDecimalExpectationsSpec.kt | 16 +- .../samples/BigDecimalExpectationSamples.kt | 15 ++ .../integration/BigDecimalExpectationsSpec.kt | 164 ++++++++--------- 6 files changed, 277 insertions(+), 92 deletions(-) create mode 100644 apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalExpectations.kt create mode 100644 apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/BigDecimalExpectationSamples.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/featureAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/featureAssertions.kt index c0da3f08f..953b0f810 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/featureAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/featureAssertions.kt @@ -1,4 +1,4 @@ -//TODO rename file with 0.18.0 +//TODO rename file to featureExtractors in 0.18.0 package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.api.fluent.en_GB.creating.feature.MetaFeatureOption diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fun0Assertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fun0Assertions.kt index c9b440a99..ce2bf066c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fun0Assertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/fun0Assertions.kt @@ -1,4 +1,4 @@ -//TODO rename file to fun0Expecations.kt with 0.18.0 +//TODO rename file to fun0Expectations.kt with 0.18.0 package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalExpectations.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalExpectations.kt new file mode 100644 index 000000000..556f22c8c --- /dev/null +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalExpectations.kt @@ -0,0 +1,170 @@ +@file:Suppress( + // TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed + "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" +) + +package ch.tutteli.atrium.api.fluent.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.PleaseUseReplacementException +import ch.tutteli.atrium.logic.* +import java.math.BigDecimal + +/** + * Deprecated as it would compare the subject against [expected] including scale + * -- many developers are not aware of that. + * + * Use [toEqualNumerically] if you expect that the following assertion holds: + * ``` + * expect(BigDecimal("10").toEqual(BigDecimal("10.0")) + * ``` + * However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use [toEqualIncludingScale]. + * + * @since 0.17.0 + */ +@Deprecated( + "Use `toEqualNumerically` if you expect that the following assertion holds:\n" + + "`expect(BigDecimal(\"10\")).toEqual(BigDecimal(\"10.0\"))`\n" + + "However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use `toEqualIncludingScale`.", + ReplaceWith("toEqualNumerically(expected) or toEqualIncludingScale(expected)") +) +@Suppress("UNUSED_PARAMETER", "unused") +fun Expect.toEqual(expected: T): Nothing = + throw PleaseUseReplacementException( + "BigDecimal.equals() compares also BigDecimal.scale, which you might not be aware of.\n" + + "If you know it and want that `scale` is included in the comparison, then use `toEqualIncludingScale`." + ) + +/** + * Deprecated as it would compare the subject against [expected] including scale + * -- many developers are not aware of that. + * + * Use [toEqualNumerically] if you expect that the following assertion holds: + * ``` + * expect(BigDecimal("10").toEqual(BigDecimal("10.0")) + * ``` + * However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use [toEqualIncludingScale]. + * + * @since 0.17.0 + */ +@Suppress("UNUSED_PARAMETER", "unused") +@JvmName("toBeNullable") +@Deprecated( + "Use `toEqualNumerically` if you expect that the following assertion holds:\n" + + "`expect(BigDecimal(\"10\")).toEqual(BigDecimal(\"10.0\"))`\n" + + "However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use `toEqualIncludingScale`.", + ReplaceWith("toEqualNumerically(expected) or toEqualIncludingScale(expected)") +) +fun Expect.toEqual(expected: T): Nothing = + throw PleaseUseReplacementException( + "BigDecimal.equals() compares also BigDecimal.scale, which you might not be aware of.\n" + + "If you know it and want that `scale` is included in the comparison, then use `toEqualIncludingScale`." + ) + +/** + * Expects that the subject of `this` expectation (a [BigDecimal]) is `null`. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.fluent.en_GB.samples.BigDecimalExpectationSamples.toEqual + * + * @since 0.17.0 + */ +@JvmName("toBeNull") +fun Expect.toEqual(expected: Nothing?): Expect = + _logicAppend { toBe(expected) } + +/** + * Deprecated as it would compare the subject against [expected] including scale + * -- many developers are not aware of that. + * + * Use [notToEqualNumerically] if you expect that the following assertion is wrong: + * ``` + * expect(BigDecimal("10").notToBe(BigDecimal("10.0")) + * ``` + * However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use [notToEqualIncludingScale]. + * + * @since 0.17.0 + */ +@Deprecated( + "Use `notToEqualNumerically` if you expect that the following assertion is wrong:\n" + + "`expect(BigDecimal(\"10\")).notToBe(BigDecimal(\"10.0\"))`\n" + + "However, if you expect it to hold (because `BigDecimal.scale` differ), then use `notToEqualIncludingScale`.", + ReplaceWith("notToEqualNumerically(expected) or notToEqualIncludingScale(expected)") +) +@Suppress("UNUSED_PARAMETER", "unused") +fun Expect.notToEqual(expected: T): Nothing = + throw PleaseUseReplacementException( + "BigDecimal.equals() compares also BigDecimal.scale, which you might not be aware of.\n" + + "If you know it and want that `scale` is included in the comparison, then use `notToEqualIncludingScale`." + ) + +/** + * Expects that the subject of `this` expectation (a [BigDecimal]) is numerically equal to [expected]. + * + * By numerically is meant that it will not compare [BigDecimal.scale] (or in other words, + * it uses `compareTo(expected) == 0`) + * + * Most of the time you want to use this function instead of [toEqualIncludingScale] because + * [toEqualIncludingScale] compares [BigDecimal.scale]. + * Following the two functions compared: + * - `expect(BigDecimal("10")).toEqualIncludingScale(BigDecimal("10.0"))` does not hold. + * - `expect(BigDecimal("10")).toEqualNumerically(BigDecimal("10.0"))` holds. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun Expect.toEqualNumerically(expected: T): Expect = + _logicAppend { isNumericallyEqualTo(expected) } + +/** + * Expects that the subject of `this` expectation (a [BigDecimal]) is not numerically equal to [expected]. + * + * By numerically is meant that it will not compare [BigDecimal.scale] (or in other words, + * it uses `compareTo(expected) != 0`) + * + * Most of the time you want to use this function instead of [notToEqualIncludingScale] because + * [notToEqualIncludingScale] compares [BigDecimal.scale]. + * Following the two functions compared: + * - `expect(BigDecimal("10")).notToEqualIncludingScale(BigDecimal("10.0"))` holds. + * - `expect(BigDecimal("10")).notToEqualNumerically(BigDecimal("10.0"))` does not hold. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun Expect.notToEqualNumerically(expected: T): Expect = + _logicAppend { isNotNumericallyEqualTo(expected) } + +/** + * Expects that the subject of `this` expectation (a [BigDecimal]) is equal to [expected] including [BigDecimal.scale]. + * + * Most of the time you want to use [toEqualNumerically] which does not compare [BigDecimal.scale] + * in contrast to this function. + * Following the two functions compared: + * - `expect(BigDecimal("10")).toEqualIncludingScale(BigDecimal("10.0"))` does not hold. + * - `expect(BigDecimal("10")).toEqualNumerically(BigDecimal("10.0"))` holds. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun Expect.toEqualIncludingScale(expected: T): Expect = + _logicAppend { isEqualIncludingScale(expected, Expect::toEqualNumerically.name) } + +/** + * Expects that the subject of `this` expectation (a [BigDecimal]) is not equal to [expected] including [BigDecimal.scale]. + * + * Most of the time you want to use [notToEqualNumerically] which does not compare [BigDecimal.scale] + * in contrast to this function. + * Following the two functions compared: + * - `expect(BigDecimal("10")).notToEqualIncludingScale(BigDecimal("10.0"))` holds. + * - `expect(BigDecimal("10")).notToEqualNumerically(BigDecimal("10.0"))` does not hold. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun Expect.notToEqualIncludingScale(expected: T): Expect = + _logicAppend { isNotEqualIncludingScale(expected) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/BigDecimalExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/BigDecimalExpectationsSpec.kt index 401cd9b5e..8e20a1544 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/BigDecimalExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/BigDecimalExpectationsSpec.kt @@ -10,16 +10,16 @@ import java.math.BigDecimal class BigDecimalExpectationsSpec : Spek({ include(object : ch.tutteli.atrium.specs.integration.BigDecimalExpectationsSpec( - @Suppress("DEPRECATION") fun1(Expect::toBe), - @Suppress("DEPRECATION") fun1(Expect::toBe).withNullableSuffix(), - fun1(Expect::toBe).withNullableSuffix(), + @Suppress("DEPRECATION") fun1(Expect::toEqual), + @Suppress("DEPRECATION") fun1(Expect::toEqual).withNullableSuffix(), + fun1(Expect::toEqual).withNullableSuffix(), Expect::toEqual, - @Suppress("DEPRECATION") Expect::notToBe.name to @Suppress("DEPRECATION") Expect::notToBe, + @Suppress("DEPRECATION") Expect::notToEqual.name to @Suppress("DEPRECATION") Expect::notToEqual, Expect::notToEqual, - Expect::isNumericallyEqualTo.name to Expect::isNumericallyEqualTo, - Expect::isNotNumericallyEqualTo.name to Expect::isNotNumericallyEqualTo, - Expect::isEqualIncludingScale.name to Expect::isEqualIncludingScale, - Expect::isNotEqualIncludingScale.name to Expect::isNotEqualIncludingScale + Expect::toEqualNumerically.name to Expect::toEqualNumerically, + Expect::notToEqualNumerically.name to Expect::notToEqualNumerically, + Expect::toEqualIncludingScale.name to Expect::toEqualIncludingScale, + Expect::notToEqualIncludingScale.name to Expect::notToEqualIncludingScale ) {}) describe("fun toBe for BigDecimal? and subject is null") { diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/BigDecimalExpectationSamples.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/BigDecimalExpectationSamples.kt new file mode 100644 index 000000000..5054d0de9 --- /dev/null +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/BigDecimalExpectationSamples.kt @@ -0,0 +1,15 @@ +package ch.tutteli.atrium.api.fluent.en_GB.samples + +import ch.tutteli.atrium.api.fluent.en_GB.toEqual +import ch.tutteli.atrium.api.verbs.internal.expect +import java.math.BigDecimal +import kotlin.test.Test + +class BigDecimalExpectationSamples { + + @Test + fun toEqual() { + // only use toEqual to check against null, otherwise use toEqualNumerically or toEqualIncludingScale + expect(null as BigDecimal?).toEqual(null) + } +} diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/BigDecimalExpectationsSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/BigDecimalExpectationsSpec.kt index 15892f061..5814d6854 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/BigDecimalExpectationsSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/BigDecimalExpectationsSpec.kt @@ -12,38 +12,38 @@ import org.spekframework.spek2.style.specification.Suite import java.math.BigDecimal abstract class BigDecimalExpectationsSpec( - toBeDontUse: Fun1, - toBeNullableDontUse: Fun1, - toBeNull: Fun1, - toBeAnyFun: Expect.(Any) -> Expect, - notToBe: Fun1, - notToBeAnyFun: Expect.(Any) -> Expect, - isNumericallyEqualTo: Fun1, - isNotNumericallyEqualTo: Fun1, - isEqualIncludingScale: Fun1, - isNotEqualIncludingScale: Fun1, + toEqualDontUse: Fun1, + toEqualNullableDontUse: Fun1, + toEqualNull: Fun1, + toEqualAnyFun: Expect.(Any) -> Expect, + notToEqual: Fun1, + notToEqualAnyFun: Expect.(Any) -> Expect, + toEqualNumerically: Fun1, + notToEqualNumerically: Fun1, + toEqualIncludingScale: Fun1, + notToEqualIncludingScale: Fun1, describePrefix: String = "[Atrium] " ) : Spek({ include(object : SubjectLessSpec( describePrefix, - isNumericallyEqualTo.forSubjectLess(BigDecimal.TEN), - isNotNumericallyEqualTo.forSubjectLess(BigDecimal.TEN), - isEqualIncludingScale.forSubjectLess(BigDecimal.TEN), - isNotEqualIncludingScale.forSubjectLess(BigDecimal.TEN) + toEqualNumerically.forSubjectLess(BigDecimal.TEN), + notToEqualNumerically.forSubjectLess(BigDecimal.TEN), + toEqualIncludingScale.forSubjectLess(BigDecimal.TEN), + notToEqualIncludingScale.forSubjectLess(BigDecimal.TEN) ) {}) include(object : SubjectLessSpec( "$describePrefix[nullable] ", - toBeNull.forSubjectLess(null) + toEqualNull.forSubjectLess(null) ) {}) fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) - describeFun(isNumericallyEqualTo, isNotNumericallyEqualTo) { - val isNumericallyEqualToFun = isNumericallyEqualTo.lambda - val isNotNumericallyEqualToFun = isNotNumericallyEqualTo.lambda + describeFun(toEqualNumerically, notToEqualNumerically) { + val toEqualNumericallyFun = toEqualNumerically.lambda + val notToEqualNumericallyFun = notToEqualNumerically.lambda mapOf( BigDecimal.TEN to BigDecimal("10.00"), @@ -53,12 +53,12 @@ abstract class BigDecimalExpectationsSpec( BigDecimal.ZERO to BigDecimal("00.0") ).forEach { (subject, expected) -> context("subject $subject and expected $expected") { - it("`${isNumericallyEqualTo.name}` does not throw") { - expect(subject).isNumericallyEqualToFun(expected) + it("`${toEqualNumerically.name}` does not throw") { + expect(subject).toEqualNumericallyFun(expected) } - it("`${isNotNumericallyEqualTo.name}` throws AssertionError") { + it("`${notToEqualNumerically.name}` throws AssertionError") { expect { - expect(subject).isNotNumericallyEqualToFun(expected) + expect(subject).notToEqualNumericallyFun(expected) }.toThrow { messageToContain( subject, @@ -74,9 +74,9 @@ abstract class BigDecimalExpectationsSpec( BigDecimal.ZERO to BigDecimal("0.0000001") ).forEach { (subject, expected) -> context("subject $subject and expected $expected") { - it("`${isNumericallyEqualTo.name}` throws AssertionError") { + it("`${toEqualNumerically.name}` throws AssertionError") { expect { - expect(subject).isNumericallyEqualToFun(expected) + expect(subject).toEqualNumericallyFun(expected) }.toThrow { messageToContain( subject, @@ -84,61 +84,61 @@ abstract class BigDecimalExpectationsSpec( ) } } - it("`$isNotNumericallyEqualTo` does not throw") { - expect(subject).isNotNumericallyEqualToFun(expected) + it("`$notToEqualNumerically` does not throw") { + expect(subject).notToEqualNumericallyFun(expected) } } } } - val assertTen = expect(BigDecimal.TEN as BigDecimal) - val assertNullableTen: Expect = expect(BigDecimal.TEN) - val assertTenAny = expect(BigDecimal.TEN as Any) + val expectTen = expect(BigDecimal.TEN as BigDecimal) + val expectNullableTen: Expect = expect(BigDecimal.TEN) + val expectTenAsAny = expect(BigDecimal.TEN as Any) describeFun( - toBeDontUse, - toBeNullableDontUse, - isEqualIncludingScale, - notToBe, - isNotEqualIncludingScale + toEqualDontUse, + toEqualNullableDontUse, + toEqualIncludingScale, + notToEqual, + notToEqualIncludingScale ) { - val toBeFun = toBeDontUse.lambda - val toBeNullableFun = toBeNullableDontUse.lambda - val isEqualIncludingScaleFun = isEqualIncludingScale.lambda - val notToBeFun = notToBe.lambda - val isNotEqualIncludingScaleFun = isNotEqualIncludingScale.lambda + val toEqualFun = toEqualDontUse.lambda + val toEqualNullableFun = toEqualNullableDontUse.lambda + val toEqualIncludingScaleFun = toEqualIncludingScale.lambda + val notToEqualFun = notToEqual.lambda + val notToEqualIncludingScaleFun = notToEqualIncludingScale.lambda val failureHintNotNumerically = String.format( DescriptionBigDecimalAssertion.FAILURE_IS_EQUAL_INCLUDING_SCALE_BUT_NUMERICALLY_EQUAL.getDefault(), - isNotNumericallyEqualTo.name + notToEqualNumerically.name ) context("subject is 10 and expected is 10") { val expected = BigDecimal("10") - it("${toBeDontUse.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${toEqualDontUse.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertTen.toBeFun(expected) + expectTen.toEqualFun(expected) }.toThrow() } - it("${toBeDontUse.name} with BigDecimal? overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${toEqualDontUse.name} with BigDecimal? overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertNullableTen.toBeNullableFun(expected) + expectNullableTen.toEqualNullableFun(expected) }.toThrow() } - it("${notToBe.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${notToEqual.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertTen.notToBeFun(expected) + expectTen.notToEqualFun(expected) }.toThrow() } - it("${toBeDontUse.name} with Any overload does not throw") { - assertTenAny.toBeAnyFun(expected) + it("${toEqualDontUse.name} with Any overload does not throw") { + expectTenAsAny.toEqualAnyFun(expected) } - it("$isEqualIncludingScale does not throw") { - assertTen.isEqualIncludingScaleFun(expected) + it("$toEqualIncludingScale does not throw") { + expectTen.toEqualIncludingScaleFun(expected) } - it("${notToBe.name} with Any overload throws an AssertionError and does not contain the hint") { + it("${notToEqual.name} with Any overload throws an AssertionError and does not contain the hint") { expect { - assertTenAny.notToBeAnyFun(expected) + expectTenAsAny.notToEqualAnyFun(expected) }.toThrow { message { toContain(BigDecimal.TEN, "${NOT_TO_BE.getDefault()}: $expected") @@ -146,9 +146,9 @@ abstract class BigDecimalExpectationsSpec( } } } - it("${isNotEqualIncludingScale.name} throws an AssertionError and does not contain the hint") { + it("${notToEqualIncludingScale.name} throws an AssertionError and does not contain the hint") { expect { - assertTen.isNotEqualIncludingScaleFun(expected) + expectTen.notToEqualIncludingScaleFun(expected) }.toThrow { message { toContain( @@ -163,27 +163,27 @@ abstract class BigDecimalExpectationsSpec( val failureHintNumerically = String.format( DescriptionBigDecimalAssertion.FAILURE_IS_EQUAL_INCLUDING_SCALE_BUT_NUMERICALLY_EQUAL.getDefault(), - isNumericallyEqualTo.name + toEqualNumerically.name ) listOf( BigDecimal("10.0"), BigDecimal("10.00") ).forEach { expected -> context("subject is 10 and expected is $expected") { - it("${toBeDontUse.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${toEqualDontUse.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertTen.toBeFun(expected) + expectTen.toEqualFun(expected) }.toThrow() } - it("${notToBe.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${notToEqual.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertTen.notToBeFun(expected) + expectTen.notToEqualFun(expected) }.toThrow() } - it("${toBeDontUse.name} with Any overload throws an AssertionError and does not contain the hint") { + it("${toEqualDontUse.name} with Any overload throws an AssertionError and does not contain the hint") { expect { - assertTenAny.toBeAnyFun(expected) + expectTenAsAny.toEqualAnyFun(expected) }.toThrow { message { toContain(BigDecimal.TEN, "$toBeDescr: $expected") @@ -191,9 +191,9 @@ abstract class BigDecimalExpectationsSpec( } } } - it("${isEqualIncludingScale.name} throws an AssertionError mentioning that ${isNumericallyEqualTo.name} could have been used") { + it("${toEqualIncludingScale.name} throws an AssertionError mentioning that ${toEqualNumerically.name} could have been used") { expect { - assertTen.isEqualIncludingScaleFun(expected) + expectTen.toEqualIncludingScaleFun(expected) }.toThrow { messageToContain( BigDecimal.TEN, @@ -203,31 +203,31 @@ abstract class BigDecimalExpectationsSpec( } } - it("${notToBe.name} with Any overload does not throw") { - assertTenAny.notToBeAnyFun(expected) + it("${notToEqual.name} with Any overload does not throw") { + expectTenAsAny.notToEqualAnyFun(expected) } - it("${isEqualIncludingScale.name} does not throw") { - assertTen.isNotEqualIncludingScaleFun(expected) + it("${toEqualIncludingScale.name} does not throw") { + expectTen.notToEqualIncludingScaleFun(expected) } } } context("subject is 10 and expected is 9") { val expected = BigDecimal("9.999999999999") - it("${toBeDontUse.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${toEqualDontUse.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertTen.toBeFun(expected) + expectTen.toEqualFun(expected) }.toThrow() } - it("${notToBe.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { + it("${notToEqual.name} with BigDecimal overload throws ${PleaseUseReplacementException::class.simpleName}") { expect { - assertTen.notToBeFun(expected) + expectTen.notToEqualFun(expected) }.toThrow() } - it("${toBeDontUse.name} with Any overload throws an AssertionError and does not contain the hint") { + it("${toEqualDontUse.name} with Any overload throws an AssertionError and does not contain the hint") { expect { - assertTenAny.toBeAnyFun(expected) + expectTenAsAny.toEqualAnyFun(expected) }.toThrow { message { toContain(BigDecimal.TEN, "$toBeDescr: $expected") @@ -235,9 +235,9 @@ abstract class BigDecimalExpectationsSpec( } } } - it("${isEqualIncludingScale.name} throws an AssertionError and does not contain the hint") { + it("${toEqualIncludingScale.name} throws an AssertionError and does not contain the hint") { expect { - assertTen.isEqualIncludingScaleFun(expected) + expectTen.toEqualIncludingScaleFun(expected) }.toThrow { message { toContain( @@ -249,19 +249,19 @@ abstract class BigDecimalExpectationsSpec( } } - it("${notToBe.name} with Any overload does not throw") { - assertTenAny.notToBeAnyFun(expected) + it("${notToEqual.name} with Any overload does not throw") { + expectTenAsAny.notToEqualAnyFun(expected) } - it("${isEqualIncludingScale.name} does not throw") { - assertTen.isNotEqualIncludingScaleFun(expected) + it("${toEqualIncludingScale.name} does not throw") { + expectTen.notToEqualIncludingScaleFun(expected) } } } - describeFun(toBeNull) { - val toBeFun = toBeNull.lambda + describeFun(toEqualNull) { + val toEqualFun = toEqualNull.lambda it("does not throw if subject is null") { - expect(null as BigDecimal?).toBeFun(null) + expect(null as BigDecimal?).toEqualFun(null) } } })