From d02d87940c0ee5917fa47dff9a521a8c70a4d421 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 3 Feb 2020 15:53:22 +0200 Subject: [PATCH 001/142] feat(infix-api): add pathAssertions for infix API --- .../src/main/kotlin/pathAssertions.kt | 257 ++++++++++++++++++ .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 42 +++ 2 files changed, 299 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/pathAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/pathAssertions.kt new file mode 100644 index 000000000..10478a6e5 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/pathAssertions.kt @@ -0,0 +1,257 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.path +import java.nio.file.Path + +/** + * Expects that the subject of the assertion (a [Path]) starts with the [expected] [Path]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.startsWith(expected: Path): Expect = + addAssertion(ExpectImpl.path.startsWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [Path]) does not start with the [expected] [Path]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.startsNotWith(expected: Path): Expect = + addAssertion(ExpectImpl.path.startsNotWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [Path]) ends with the expected [Path]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.endsWith(expected: Path): Expect = + addAssertion(ExpectImpl.path.endsWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [Path]) does not end with the expected [Path]; + * + * @param expected The [Path] provided to the assertion + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.endsNotWith(expected: Path): Expect = + addAssertion(ExpectImpl.path.endsNotWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [Path]) exists; + * meaning that there is a file system entry at the location the [Path] points to. + * + * This matcher _resolves_ symbolic links. Therefore, if a symbolic link exists at the location the subject points to, + * then the search will continue at that location. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +fun Expect.exists(): Expect = addAssertion(ExpectImpl.path.exists(this)) + +/** + * Expects that the subject of the assertion (a [Path]) does not exist; + * meaning that there is no file system entry at the location the [Path] points to. + * + * This matcher _resolves_ symbolic links. Therefore, if a symbolic link exists at the location the subject points to, + * then the search will continue at that location. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +fun Expect.existsNot(): Expect = addAssertion(ExpectImpl.path.existsNot(this)) + +/** + * Creates an [Expect] for the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] + * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 1.0.0 + */ +val Expect.fileName: Expect + get() = ExpectImpl.path.fileName(this).getExpectOfFeature() + +/** + * Expects that the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] + * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.fileName(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.path.fileName(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [Path.fileNameWithoutExtension][ch.tutteli.niok.fileNameWithoutExtension] + * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +val Expect.fileNameWithoutExtension: Expect + get() = ExpectImpl.path.fileNameWithoutExtension(this).getExpectOfFeature() + +/** + * Expects that the property [Path.fileNameWithoutExtension][ch.tutteli.niok.fileNameWithoutExtension] + * (provided via [niok](https://github.com/robstoll/niok)) + * of the subject of the assertion holds all assertions the given [assertionCreator] creates for it + * and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.fileNameWithoutExtension(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.path.fileNameWithoutExtension(this).addToInitial(assertionCreator) + +/** + * Expects that this [Path] has a [parent][Path.getParent] and creates an [Expect] for it, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +val Expect.parent: Expect + get() = ExpectImpl.path.parent(this).getExpectOfFeature() + +/** + * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the + * given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.parent(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.path.parent(this).addToInitial(assertionCreator) + + +/** + * Expects that the subject of the assertion (a [Path]) is readable; + * meaning that there is a file system entry at the location the [Path] points to and + * that the current thread has the permission to read from it. + * + * This matcher _resolves_ symbolic links. + * Therefore, if a symbolic link exists at the location the subject points to, + * search will continue at the location the link points at. + * + * This assertion is not atomic with respect to concurrent file system operations on the paths the assertions works on. + * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations + * take place. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +fun Expect.isReadable(): Expect = addAssertion(ExpectImpl.path.isReadable(this)) + +/** + * Expects that the subject of the assertion (a [Path]) is writable; + * meaning that there is a file system entry at the location the [Path] points to and + * that the current thread has the permission to write to it. + * + * This matcher _resolves_ symbolic links. + * Therefore, if a symbolic link exists at the location the subject points to, search will continue + * at the location the link points at. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +fun Expect.isWritable(): Expect = addAssertion(ExpectImpl.path.isWritable(this)) + +/** + * Expects that the subject of the assertion (a [Path]) is a file; + * meaning that there is a file system entry at the location the [Path] points to and that is a regular file. + * + * This matcher _resolves_ symbolic links. + * Therefore, if a symbolic link exists at the location the subject points to, search will continue + * at the location the link points at. + * + * This assertion is not atomic with respect to concurrent file system operations on the paths the assertions works on. + * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations + * take place. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +fun Expect.isRegularFile(): Expect = addAssertion(ExpectImpl.path.isRegularFile(this)) + +/** + * Expects that the subject of the assertion (a [Path]) is a directory; + * meaning that there is a file system entry at the location the [Path] points to and that is a directory. + * + * This matcher _resolves_ symbolic links. + * Therefore, if a symbolic link exists at the location the subject points to, search will continue + * at the location the link points at. + * + * This assertion is not atomic with respect to concurrent file system operations on the paths the assertions works on. + * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations + * take place. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +fun Expect.isDirectory(): Expect = addAssertion(ExpectImpl.path.isDirectory(this)) + +/** + * Creates an [Expect] for the property [Path.extension][ch.tutteli.niok.extension] + * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 1.0.0 + */ +val Expect.extension: Expect + get() = ExpectImpl.path.extension(this).getExpectOfFeature() + +/** + * Expects that the property [Path.extension][ch.tutteli.niok.extension] + * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 1.0.0 + */ +infix fun Expect.extension(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.path.extension(this).addToInitial(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt new file mode 100644 index 000000000..214edc1a4 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -0,0 +1,42 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun0 +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import java.nio.file.Path +import java.nio.file.Paths + +class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpec( + fun0(Expect::exists), + fun0(Expect::existsNot), + fun1(Expect::startsWith), + fun1(Expect::startsNotWith), + fun1(Expect::endsWith), + fun1(Expect::endsNotWith), + fun0(Expect::isReadable), + fun0(Expect::isWritable), + fun0(Expect::isRegularFile), + fun0(Expect::isDirectory) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1.exists() + a1.existsNot() + a1 startsWith Paths.get("a") + a1 startsNotWith Paths.get("a") + a1 endsWith Paths.get("a") + a1 endsNotWith Paths.get("a") + a1.fileName {} + a1.fileNameWithoutExtension {} + a1.extension {} + a1.parent {} + a1.isReadable() + a1.isWritable() + a1.isRegularFile() + a1.isDirectory() + + } +} From c6846af224768b365ceaa871c98cf3baed657b2c Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 3 Feb 2020 16:25:04 +0200 Subject: [PATCH 002/142] refactor(infix-api): move pathAssertions to package folder --- .../tutteli/atrium/api/infix/en_GB/jdk8}/pathAssertions.kt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/{ => ch/tutteli/atrium/api/infix/en_GB/jdk8}/pathAssertions.kt (100%) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt similarity index 100% rename from apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/pathAssertions.kt rename to apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt From 4c37933ea1a6889ac30e831d84dee09d689daf51 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 3 Feb 2020 17:04:27 +0200 Subject: [PATCH 003/142] feat(infix-api): keyword-based infix path assertions --- .../src/module/module-info.java | 2 +- .../atrium/api/infix/en_GB/jdk8/keywords.kt | 34 +++++++++++++ .../api/infix/en_GB/jdk8/pathAssertions.kt | 18 ++++--- .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 48 ++++++++++++------- 4 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java index ac21a37b6..311fe4b30 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java @@ -3,7 +3,7 @@ module ch.tutteli.atrium.api.infix.en_GB { requires kotlin.stdlib; -// exports ch.tutteli.atrium.api.infix.en_GB; + exports ch.tutteli.atrium.api.infix.en_GB; // exports ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders; // exports ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders; } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt new file mode 100644 index 000000000..3174b5a4a --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt @@ -0,0 +1,34 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.api.infix.en_GB.Keyword + + +/** + * A helper construct to allow expressing assertions about path existence. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object exist : Keyword + +/** + * A helper construct to allow expressing assertions about a path being a regular file. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object aRegularFile : Keyword + +/** + * A helper construct to allow expressing assertions about a path being a directory. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object aDirectory : Keyword + +/** + * A helper construct to allow expressing assertions about a path being a readable. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object readable: Keyword + +/** + * A helper construct to allow expressing assertions about a path being a writable. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object writable: Keyword diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 10478a6e5..300dce944 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -64,7 +64,8 @@ infix fun Expect.endsNotWith(expected: Path): Expect = * * @since 1.0.0 */ -fun Expect.exists(): Expect = addAssertion(ExpectImpl.path.exists(this)) +infix fun Expect.does(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = + addAssertion(ExpectImpl.path.exists(this)) /** * Expects that the subject of the assertion (a [Path]) does not exist; @@ -78,7 +79,8 @@ fun Expect.exists(): Expect = addAssertion(ExpectImpl.path.exis * * @since 1.0.0 */ -fun Expect.existsNot(): Expect = addAssertion(ExpectImpl.path.existsNot(this)) +infix fun Expect.doesNot(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = + addAssertion(ExpectImpl.path.existsNot(this)) /** * Creates an [Expect] for the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] @@ -175,7 +177,8 @@ infix fun Expect.parent(assertionCreator: Expect.() -> Unit) * * @since 1.0.0 */ -fun Expect.isReadable(): Expect = addAssertion(ExpectImpl.path.isReadable(this)) +infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") readable: readable): Expect = + addAssertion(ExpectImpl.path.isReadable(this)) /** * Expects that the subject of the assertion (a [Path]) is writable; @@ -191,7 +194,8 @@ fun Expect.isReadable(): Expect = addAssertion(ExpectImpl.path. * * @since 1.0.0 */ -fun Expect.isWritable(): Expect = addAssertion(ExpectImpl.path.isWritable(this)) +infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") writable: writable): Expect = + addAssertion(ExpectImpl.path.isWritable(this)) /** * Expects that the subject of the assertion (a [Path]) is a file; @@ -210,7 +214,8 @@ fun Expect.isWritable(): Expect = addAssertion(ExpectImpl.path. * * @since 1.0.0 */ -fun Expect.isRegularFile(): Expect = addAssertion(ExpectImpl.path.isRegularFile(this)) +infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aRegularFile: aRegularFile): Expect = + addAssertion(ExpectImpl.path.isRegularFile(this)) /** * Expects that the subject of the assertion (a [Path]) is a directory; @@ -229,7 +234,8 @@ fun Expect.isRegularFile(): Expect = addAssertion(ExpectImpl.pa * * @since 1.0.0 */ -fun Expect.isDirectory(): Expect = addAssertion(ExpectImpl.path.isDirectory(this)) +infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aDirectory: aDirectory): Expect = + addAssertion(ExpectImpl.path.isDirectory(this)) /** * Creates an [Expect] for the property [Path.extension][ch.tutteli.niok.extension] diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index 214edc1a4..beaace5de 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -1,42 +1,54 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.fun0 import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented import java.nio.file.Path import java.nio.file.Paths class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpec( - fun0(Expect::exists), - fun0(Expect::existsNot), + fun1(Expect::does).name to ::exists, + fun1(Expect::doesNot).name to ::existsNot, fun1(Expect::startsWith), fun1(Expect::startsNotWith), fun1(Expect::endsWith), fun1(Expect::endsNotWith), - fun0(Expect::isReadable), - fun0(Expect::isWritable), - fun0(Expect::isRegularFile), - fun0(Expect::isDirectory) + fun1(Expect::toBe).name to ::isReadable, + fun1(Expect::toBe).name to ::isWritable, + fun1(Expect::toBe).name to ::isRegularFile, + fun1(Expect::toBe).name to ::isDirectory ) { + companion object { + fun exists(expect: Expect) = expect does exist + fun existsNot(expect: Expect) = expect doesNot exist + fun isReadable(expect: Expect) = expect toBe readable + fun isWritable(expect: Expect) = expect toBe writable + fun isRegularFile(expect: Expect) = expect toBe aRegularFile + fun isDirectory(expect: Expect) = expect toBe aDirectory + } + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { val a1: Expect = notImplemented() - a1.exists() - a1.existsNot() + a1 does exist + a1 doesNot exist a1 startsWith Paths.get("a") a1 startsNotWith Paths.get("a") a1 endsWith Paths.get("a") a1 endsNotWith Paths.get("a") - a1.fileName {} - a1.fileNameWithoutExtension {} - a1.extension {} - a1.parent {} - a1.isReadable() - a1.isWritable() - a1.isRegularFile() - a1.isDirectory() - + a1.fileName + a1 fileName {} + a1.fileNameWithoutExtension + a1 fileNameWithoutExtension {} + a1.extension + a1 extension {} + a1.parent + a1 parent {} + a1 toBe readable + a1 toBe writable + a1 toBe aRegularFile + a1 toBe aDirectory } } From b1b741137e324d3d3eb0f1f3895aa3f660eb2e14 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 3 Feb 2020 21:31:49 +0200 Subject: [PATCH 004/142] doc(infix-api): Will be introduced in v0.10.0 --- .../api/infix/en_GB/jdk8/pathAssertions.kt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 300dce944..0ef963a8c 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -13,7 +13,7 @@ import java.nio.file.Path * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.startsWith(expected: Path): Expect = addAssertion(ExpectImpl.path.startsWith(this, expected)) @@ -24,7 +24,7 @@ infix fun Expect.startsWith(expected: Path): Expect = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.startsNotWith(expected: Path): Expect = addAssertion(ExpectImpl.path.startsNotWith(this, expected)) @@ -35,7 +35,7 @@ infix fun Expect.startsNotWith(expected: Path): Expect = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.endsWith(expected: Path): Expect = addAssertion(ExpectImpl.path.endsWith(this, expected)) @@ -47,7 +47,7 @@ infix fun Expect.endsWith(expected: Path): Expect = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.endsNotWith(expected: Path): Expect = addAssertion(ExpectImpl.path.endsNotWith(this, expected)) @@ -62,7 +62,7 @@ infix fun Expect.endsNotWith(expected: Path): Expect = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.does(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.exists(this)) @@ -77,7 +77,7 @@ infix fun Expect.does(@Suppress("UNUSED_PARAMETER") exist: exist): * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.doesNot(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.existsNot(this)) @@ -89,7 +89,7 @@ infix fun Expect.doesNot(@Suppress("UNUSED_PARAMETER") exist: exis * * @return The newly created [Expect]. * - * @since 1.0.0 + * @since 0.10.0 */ val Expect.fileName: Expect get() = ExpectImpl.path.fileName(this).getExpectOfFeature() @@ -102,7 +102,7 @@ val Expect.fileName: Expect * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.fileName(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.fileName(this).addToInitial(assertionCreator) @@ -115,7 +115,7 @@ infix fun Expect.fileName(assertionCreator: Expect.() -> U * @return The newly created [Expect]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ val Expect.fileNameWithoutExtension: Expect get() = ExpectImpl.path.fileNameWithoutExtension(this).getExpectOfFeature() @@ -129,7 +129,7 @@ val Expect.fileNameWithoutExtension: Expect * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.fileNameWithoutExtension(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.fileNameWithoutExtension(this).addToInitial(assertionCreator) @@ -141,7 +141,7 @@ infix fun Expect.fileNameWithoutExtension(assertionCreator: Expect * @return The newly created [Expect]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ val Expect.parent: Expect get() = ExpectImpl.path.parent(this).getExpectOfFeature() @@ -153,7 +153,7 @@ val Expect.parent: Expect * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.parent(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.parent(this).addToInitial(assertionCreator) @@ -175,7 +175,7 @@ infix fun Expect.parent(assertionCreator: Expect.() -> Unit) * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") readable: readable): Expect = addAssertion(ExpectImpl.path.isReadable(this)) @@ -192,7 +192,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") readable: read * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") writable: writable): Expect = addAssertion(ExpectImpl.path.isWritable(this)) @@ -212,7 +212,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") writable: writ * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aRegularFile: aRegularFile): Expect = addAssertion(ExpectImpl.path.isRegularFile(this)) @@ -232,7 +232,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aRegularFile: * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aDirectory: aDirectory): Expect = addAssertion(ExpectImpl.path.isDirectory(this)) @@ -244,7 +244,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aDirectory: aD * * @return The newly created [Expect]. * - * @since 1.0.0 + * @since 0.10.0 */ val Expect.extension: Expect get() = ExpectImpl.path.extension(this).getExpectOfFeature() @@ -257,7 +257,7 @@ val Expect.extension: Expect * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 1.0.0 + * @since 0.10.0 */ infix fun Expect.extension(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.extension(this).addToInitial(assertionCreator) From 355a884489ae26333d55cb3c6716e82cda8761d4 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 3 Feb 2020 21:36:58 +0200 Subject: [PATCH 005/142] test(infix-api): Test path assertions with DummyPath --- .../tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index beaace5de..bffaf1ec0 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -30,7 +30,7 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - val a1: Expect = notImplemented() + val a1: Expect = notImplemented() a1 does exist a1 doesNot exist @@ -52,3 +52,5 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe a1 toBe aDirectory } } + +class DummyPath(path: Path) : Path by path From 3e41c14b9cb4630cf648e022599b6836da989794 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Mon, 3 Feb 2020 21:53:05 +0200 Subject: [PATCH 006/142] feat(infix-api): file.asPath() assertion --- .../api/infix/en_GB/jdk8/fileAssertions.kt | 35 +++++++++++++++++++ .../en_GB/jdk8/FileAsPathAssertionsSpec.kt | 17 +++++++++ 2 files changed, 52 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt new file mode 100644 index 000000000..7c88de900 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt @@ -0,0 +1,35 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import java.io.File +import java.nio.file.Path + +/** + * Turns `Expect` into `Expect`. + * + * The transformation as such is not reflected in reporting. + * Use `feature(File::toPath)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.10.0 + */ +fun Expect.asPath(): Expect = + ExpectImpl.changeSubject(this).unreported { it.toPath() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [Path]. + * + * The transformation as such is not reflected in reporting. + * Use `feature(File::toPath, assertionCreator)` if you want to show the transformation in reporting. + * + * @return This assertion container to support a fluent API. + * + * @since 0.10.0 + */ +infix fun Expect.asPath(assertionCreator: Expect.() -> Unit): Expect = + apply { asPath().addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt new file mode 100644 index 000000000..247a8fb02 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt @@ -0,0 +1,17 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.notImplemented +import java.io.File + +class FileAsPathAssertionsSpec : ch.tutteli.atrium.specs.integration.FileAsPathAssertionsSpec( + Expect::asPath +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect = notImplemented() + + a1.asPath() + a1 = a1 asPath { } + } +} From 7871080ffb469c9924ce633de070260ec16401eb Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Tue, 4 Feb 2020 21:04:03 +0200 Subject: [PATCH 007/142] feat(infix-api): `to exist` instead of `does exist` --- .../atrium/api/infix/en_GB/jdk8/pathAssertions.kt | 4 ++-- .../api/infix/en_GB/jdk8/PathAssertionsSpec.kt | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 0ef963a8c..03dfde03a 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -64,7 +64,7 @@ infix fun Expect.endsNotWith(expected: Path): Expect = * * @since 0.10.0 */ -infix fun Expect.does(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = +infix fun Expect.to(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.exists(this)) /** @@ -79,7 +79,7 @@ infix fun Expect.does(@Suppress("UNUSED_PARAMETER") exist: exist): * * @since 0.10.0 */ -infix fun Expect.doesNot(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = +infix fun Expect.toNot(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.existsNot(this)) /** diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index bffaf1ec0..f72c8bab8 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -8,8 +8,8 @@ import java.nio.file.Path import java.nio.file.Paths class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpec( - fun1(Expect::does).name to ::exists, - fun1(Expect::doesNot).name to ::existsNot, + fun1(Expect::to).name to ::exists, + fun1(Expect::toNot).name to ::existsNot, fun1(Expect::startsWith), fun1(Expect::startsNotWith), fun1(Expect::endsWith), @@ -20,8 +20,8 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe fun1(Expect::toBe).name to ::isDirectory ) { companion object { - fun exists(expect: Expect) = expect does exist - fun existsNot(expect: Expect) = expect doesNot exist + fun exists(expect: Expect) = expect to exist + fun existsNot(expect: Expect) = expect toNot exist fun isReadable(expect: Expect) = expect toBe readable fun isWritable(expect: Expect) = expect toBe writable fun isRegularFile(expect: Expect) = expect toBe aRegularFile @@ -32,8 +32,8 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe private fun ambiguityTest() { val a1: Expect = notImplemented() - a1 does exist - a1 doesNot exist + a1 to exist + a1 toNot exist a1 startsWith Paths.get("a") a1 startsNotWith Paths.get("a") a1 endsWith Paths.get("a") From e1226662d57f155057dd3ad8e8b2a242c6570a20 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 4 Feb 2020 20:29:51 +0100 Subject: [PATCH 008/142] exclude internal tools from being published --- build.gradle | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 07c798475..321a69bcd 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,9 @@ buildscript { def sampleProjectsFun = subprojects.findAll { it.projectDir.path.contains('/samples/') || it.projectDir.path.contains('\\samples\\') } + def toolProjectsFun = subprojects.findAll { + it.projectDir.path.contains('/misc/tools/') || it.projectDir.path.contains('\\misc\\tools\\') + } ext { // main kbox_version = '0.14.3' @@ -32,14 +35,12 @@ buildscript { node_plugin_version = '1.3.1' // gh-pages.gradle - docProjects = subprojects.findAll { + docProjects = (subprojects - sampleProjectsFun - toolProjectsFun).findAll { !it.name.endsWith("-js") && !it.name.endsWith("-android") && !it.name.contains("robstoll") && it.name != "${rootProject.name}-spec" && - !it.name.startsWith("${rootProject.name}-specs") && - !(it.projectDir.path.contains("/samples/") || it.projectDir.path.contains("\\samples\\")) && - !(it.projectDir.path.contains("/misc/tools/") || it.projectDir.path.contains("\\misc\\tools\\")) + !it.name.startsWith("${rootProject.name}-specs") } ghPages_version = rootProject.version srcKotlin = 'src/main/kotlin' @@ -48,11 +49,13 @@ buildscript { sampleProjects = sampleProjectsFun + toolProjects = toolProjectsFun + // jacoco-multi-project.gradle def deprecatedProjects = subprojects.findAll { it.name.endsWith("-deprecated") } jacocoMulti = [ sourceProjects: - (subprojects - deprecatedProjects - sampleProjectsFun).findAll { + (subprojects - deprecatedProjects - sampleProjectsFun - toolProjectsFun).findAll { !it.name.endsWith("-js") && !it.name.endsWith("-android") && // would have two classes with the same name if we add it as project as well, @@ -60,13 +63,11 @@ buildscript { it.name != "${rootProject.name}-translations-de_CH-jvm" && // does not make sense to listen specs in coverage it.name != "${rootProject.name}-spec" && - !it.name.startsWith("${rootProject.name}-specs") && - !(it.projectDir.path.contains("/misc/tools/") || it.projectDir.path.contains("\\misc\\tools\\")) + !it.name.startsWith("${rootProject.name}-specs") }, jacocoProjects: - (subprojects - deprecatedProjects - sampleProjectsFun).findAll { + (subprojects - deprecatedProjects - sampleProjectsFun - toolProjectsFun).findAll { !(it.projectDir.path.contains("/translations/") || it.projectDir.path.contains("\\translations\\")) && - !(it.projectDir.path.contains("/misc/tools/") || it.projectDir.path.contains("\\misc\\tools\\")) && !it.name.endsWith("-common") && !it.name.endsWith("-js") && !it.name.endsWith("-android") && @@ -211,14 +212,16 @@ configure(jsProjects) { subProject -> } } - -configure(subprojects - commonProjects - jsProjects - sampleProjects) { +def nonCommonJsAndSampleProjects = subprojects - commonProjects - jsProjects - sampleProjects +configure(nonCommonJsAndSampleProjects - toolProjects) { apply plugin: 'ch.tutteli.dokka' apply plugin: 'ch.tutteli.kotlin.module.info' dokka { logging.setLevel(LogLevel.QUIET) } +} +configure(nonCommonJsAndSampleProjects) { compileKotlin { kotlinOptions { languageVersion = '1.2' @@ -259,7 +262,7 @@ configure(apiProjects) { apiProject -> def bundleSmokeTests = subprojects.findAll { it.name.endsWith('smoke-test') } -configure(subprojects - bundleSmokeTests - sampleProjects) { subproject -> +configure(subprojects - bundleSmokeTests - sampleProjects - toolProjects) { subproject -> apply plugin: 'ch.tutteli.publish' tutteliPublish { @@ -308,7 +311,7 @@ configure(jacocoMulti.jacocoProjects + getAndroidProjects()) { } } -configure(subprojects - sampleProjects) { +configure(subprojects - sampleProjects - toolProjects) { sourceSets { all { languageSettings { From f9b6d3f93734f79e08588e21130800214d0f3ebe Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 4 Feb 2020 21:13:52 +0100 Subject: [PATCH 009/142] de-activate new infix API for release --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 3c2e71196..58ea66d51 100644 --- a/settings.gradle +++ b/settings.gradle @@ -62,7 +62,7 @@ include { apis('api-') { apiWithExtensions(delegate, 'fluent-en_GB') - apiWithExtensions(delegate, 'infix-en_GB') +// apiWithExtensions(delegate, 'infix-en_GB') } domain('domain-') { From c81cedaa3ca84e420d720f3ce6ffd65c83752692 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 4 Feb 2020 21:17:59 +0100 Subject: [PATCH 010/142] v0.9.1 --- .github/CONTRIBUTING.md | 2 +- README.md | 219 +++++++++++++++++------------------ apis/differences.md | 8 +- build.gradle | 15 ++- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 6 files changed, 122 insertions(+), 130 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9577075ee..a43446daa 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/master/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/v0.9.1/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index 26ebe9edd..a80a38511 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Download](https://api.bintray.com/packages/robstoll/tutteli-jars/atrium/images/download.svg)](https://bintray.com/robstoll/tutteli-jars/atrium/_latestVersion "Download from Bintray") [![EUPL](https://img.shields.io/badge/%E2%9A%96-EUPL%201.2-%230b45a6)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-11-12 "License") [![atrium @ kotlinlang.slack.com](https://img.shields.io/static/v1?label=kotlinlang&message=atrium&color=blue&logo=slack)](https://kotlinlang.slack.com/messages/C887ZKGCQ "See invitation link under section FAQ") -[![Build Status Travis](https://travis-ci.org/robstoll/atrium.svg?branch=master)](https://travis-ci.org/robstoll/atrium/branches) +[![Build Status Travis](https://travis-ci.org/robstoll/atrium.svg?tag=v0.9.1)](https://travis-ci.org/robstoll/atrium/branches) [![Build Status GitHub Actions](https://github.com/robstoll/atrium/workflows/Windows/badge.svg)](https://github.com/robstoll/atrium/actions/) [![Coverage](https://codecov.io/gh/robstoll/atrium/branch/master/graph/badge.svg)](https://codecov.io/github/robstoll/atrium/branch/master) [![Newcomers Welcome](https://img.shields.io/badge/%F0%9F%91%8B-Newcomers%20Welcome-blueviolet)](https://github.com/robstoll/atrium/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 "Ask in slack for help") @@ -20,13 +20,6 @@ Atrium currently provides two [API Styles](#api-styles): pure fluent and infix where both of them have their design focus on usability in conjunction with code completion functionality provided by your IDE. See [Examples](#examples) below to get a feel for how you could benefit from Atrium. ----- -❗ You are taking a *sneak peek* at the next version. -Please have a look at the README of the git tag in case you are looking for the documentation of the corresponding version. -For instance, the [README of v0.9.0](https://github.com/robstoll/atrium/tree/v0.9.0/README.md). - ----- - **Table of Content** - [Installation](#installation) - [JVM](#jvm) @@ -135,9 +128,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/v0.9.1/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/v0.9.1/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -166,24 +159,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/master/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/master/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/v0.9.1/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/v0.9.1/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/master/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/v0.9.1/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -241,11 +234,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.1/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -260,7 +253,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -273,7 +266,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -302,7 +295,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -334,7 +327,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -365,7 +358,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -400,7 +393,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -420,7 +413,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -443,7 +436,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -463,7 +456,7 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1 Notice that stacks are filtered so that you only see what is of interest. Filtering can be configured via [`ReporterBuilder`](#reporterbuilder) by choosing an appropriate -[AtriumErrorAdjuster](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). +[AtriumErrorAdjuster](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). Stack frames of Atrium and of test runners (Spek, Kotlintest and JUnit for JVM, mocha for JS) are excluded per default. [Create a Feature Request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]) in case you use a different runner, we can add yours to the list as well. @@ -496,7 +489,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -548,7 +541,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -598,7 +591,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -628,7 +621,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) @@ -650,7 +643,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -696,7 +689,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -782,7 +775,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -803,7 +796,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -831,7 +824,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -844,7 +837,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -864,7 +857,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -880,7 +873,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -915,7 +908,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -934,7 +927,7 @@ This is reflected in the output, which tells us that we expected that the `numbe Exactly, what about the expected value `2`, why do we not see anything about it in the output? The output does not show anything about the expected value `2` because the predefined assertion verbs have configured [`ReporterBuilder`](#reporterbuilder) -to use an [Only Failure Reporter](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) +to use an [Only Failure Reporter](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) which shows us only assertions (or sub assertions) which failed. Back to the shortcut functions. @@ -955,7 +948,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -994,7 +987,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1010,7 +1003,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1028,7 +1021,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1057,7 +1050,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1107,7 +1100,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1131,7 +1124,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1147,7 +1140,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1167,7 +1160,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1189,7 +1182,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1215,7 +1208,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1246,7 +1239,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1265,7 +1258,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1301,7 +1294,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1325,7 +1318,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) `isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry`. There are more assertion functions, a full list can be found in -[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). +[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). In case you should miss an assertion function, then please [open a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]). @@ -1342,7 +1335,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1357,7 +1350,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1379,7 +1372,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1416,7 +1409,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1450,7 +1443,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1490,7 +1483,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1508,11 +1501,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.1/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/master/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/v0.9.1/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1546,7 +1539,7 @@ We try to provide a workaround whenever possible._ There is, but IntelliJ will not show it to you due to [this bug](https://youtrack.jetbrains.com/issue/KT-24836) (please upvote it). You should be able to see the KDoc of other functions without problems. -But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). +But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). @@ -1619,7 +1612,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1661,7 +1654,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1678,7 +1671,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1754,7 +1747,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1769,9 +1762,9 @@ Let us see how we actually defined `isMultipleOf`. the assertion to itself (creating alone is not enough, it needs to be added in order that it is evaluated). The method `createAndAddAssertion` returns itself (the same `Expect`) making it easy for you to provide a fluent API as well. - The method [createAndAddAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) + The method [createAndAddAssertion](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) expects: - - a either a `String` or a [Translatable](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) + - a either a `String` or a [Translatable](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) as description of your assertion. - the representation of the expected value. - and the actual check as lambda where you typically use `it` which refers to the subject of the assertion. @@ -1794,7 +1787,7 @@ fun Expect.isEven() = ``` -We are using a [RawString](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) +We are using a [RawString](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting/-raw-string/index.html) here so that `"an even number"` is not treated as a `String` in reporting. Its usage looks then as follows: @@ -1803,7 +1796,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1902,7 +1895,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1934,7 +1927,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1975,7 +1968,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2036,7 +2029,7 @@ fun >> Expect.sameInitialsAs( There are a few additional methods which you can call after `mapArguments`. -See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). +See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). In case you want to provide your own implementation it suffices to create an extension function for `ArgumentMapperBuilder`. @@ -2046,21 +2039,21 @@ extension function for `ArgumentMapperBuilder`. Yet, sometimes we would like to create functions which have a better error reporting than the one we get when we compose assertion functions. -[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) is the entry point in this case. Its a builder and thus lets you find the functions you need via code completion. Following a quick overview what it provides: - all assertion functions on the domain level (what you have seen in [Compose-assertion-functions](#compose-assertion-functions) was the API level) so that you can reuse and compose them in other ways. -- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). +- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/master/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2072,7 +2065,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/master/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/v0.9.1/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2086,7 +2079,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/master/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/v0.9.1/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2127,7 +2120,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2159,8 +2152,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/v0.9.1/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2190,24 +2183,24 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
💬 Using a TranslationSupplier Next to providing translations via code you can also use a -[TranslationSupplier](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) -based [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) +[TranslationSupplier](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) +based [Translator](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translator/index.html) by configuring the [`ReporterBuilder`](#reporterbuilder) accordingly (e.g. use `withDefaultTranslationSupplier` instead of `withoutTranslations`). Atrium supports a properties files based `TranslationSupplier` for JVM (a supplier for JS will follow) which is more or less what [ResourceBundle](https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html) provides out of the box. Yet, a `Translator` uses a more enhanced fallback mechanism compared to a `ResourceBundle`. -For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). +For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translator/index.html). Notice though, that we plan to move away from the `ResourceBundle`-inspired approach due to enconding problems and missing implementations on other platforms than JVM. @@ -2266,15 +2259,15 @@ fun _isMultipleOf(container: Expect, base: Int): Assertion = Notice that the impl-function is not an extension function as before because we do not want to pollute the API of `Expect` with this function. -In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) +In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) (`createAndAddAssertion` does the same under the hood) with a test which defines whether the assertion holds as well as a description (`IS_MULTIPLE_OF`) and a representation (`base`). -[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) helps you in writing own assertion functions. We suggest you use it as entry point (rather than memorizing different class names), it guides you to existing assertion function implementations for different types -as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) +as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) which in turn helps you with creating assertions. In the API module we define the extension function and call the impl-function: @@ -2326,17 +2319,17 @@ Both have their design focus on interoperability with code completion functional -- so that you can let your IDE do some of the work. Atrium is -[built up by different modules](https://docs.atriumlib.org/latest#/doc/) +[built up by different modules](https://docs.atriumlib.org/0.9.0/docc/) and it is your choice which implementation you want to use. However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.1/apis/differences.md) for more information and to see how the API styles differ. @@ -2351,15 +2344,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2413,13 +2406,13 @@ expect(sequenceOf(1, 2, 3)).feature { f(it::asIterable) }.contains(2) ## Where do I find a list of all available functions? Atrium provides KDoc for all APIs - have a look at their KDoc: -- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) -- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) Deprecated APIs: -- [atrium-api-cc-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-api-cc-en_UK](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) -- [atrium-api-cc-de_CH](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) +- [atrium-api-cc-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-api-cc-en_UK](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) +- [atrium-api-cc-de_CH](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) ## Problems in conjunction with `feature` @@ -2498,7 +2491,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/master/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/v0.9.1/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 1663e47f6..505507290 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,14 +14,14 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/0.9.0/docc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) +- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.0/docc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/v0.9.1/README.md#installation) for the rest): ``` dependencies { diff --git a/build.gradle b/build.gradle index 321a69bcd..64a0278c8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - rootProject.version = '0.10.0-SNAPSHOT' + rootProject.version = '0.9.1' rootProject.group = 'ch.tutteli.atrium' def sampleProjectsFun = subprojects.findAll { @@ -45,7 +45,7 @@ buildscript { ghPages_version = rootProject.version srcKotlin = 'src/main/kotlin' github_url = "https://github.com/robstoll/${rootProject.name}" - dokka_sourceMapping = "tree/master" + dokka_sourceMapping = "tree/v0.9.1" sampleProjects = sampleProjectsFun @@ -526,11 +526,10 @@ Release & deploy a commit 2. update master: a) point to the tag 1) search for old version and replace with new, except for samples (gradle, maven and section own assertion verb in README.md) - 2) search for branch/master and replace with branch/vX.Y.Z (coverage in README.md) - 3) adjust branch=master manually, use tag=vX.Y.Z except for travis where you need to use branch=vX.Y.Z - 4) search for `tree/master` and replace it with `tree/vX.Y.Z` (README.md) - 5) search for `latest#/doc` and replace with `X.Y.Z/doc` (README.md and differences.md) - 6) Remove the warning in README.md about taking a sneak peak (copy it, well be added afterwards) + 2) adjust branch=master manually, use tag=vX.Y.Z except for travis where you need to use branch=vX.Y.Z + 3) search for `tree/master` and replace it with `tree/vX.Y.Z` (README.md) + 4) search for `latest#/doc` and replace with `X.Y.Z/doc` (README.md and differences.md) + 5) Remove the warning in README.md about taking a sneak peak (copy it, well be added afterwards) b) Update README -> Use own Assertion Verbs -> link to atriumVerbs if it changed c) commit & push (modified build.gradle, README.md and differences.md) 3. update github pages: @@ -540,7 +539,7 @@ Release & deploy a commit d) commit & push changes 4. deploy to bintray: // CI=true is a temporary work around till https://youtrack.jetbrains.com/issue/KT-29069 is fixed: - a) java -version 2>&1 | grep "version \"9" && CI=true ./gr clean publishToBintray + a) java -version 2>&1 | grep "version \"11" && CI=true ./gr clean publishToBintray b) Log in to bintray, check that there are 926 artifacts and publish them c) synchronise to maven central 5. create release on github diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 888ac9bb2..9d50886e5 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index 35fcd84a6..fa9c005ce 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From 948e004ae6486d31a68c0ff7c9cf4f7d956fe132 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Tue, 4 Feb 2020 22:45:46 +0200 Subject: [PATCH 011/142] test(infix-api): Add missing PathFeatureAssertionsSpec --- .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 8 ----- .../en_GB/jdk8/PathFeatureAssertionsSpec.kt | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index f72c8bab8..b81d91dee 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -38,14 +38,6 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe a1 startsNotWith Paths.get("a") a1 endsWith Paths.get("a") a1 endsNotWith Paths.get("a") - a1.fileName - a1 fileName {} - a1.fileNameWithoutExtension - a1 fileNameWithoutExtension {} - a1.extension - a1 extension {} - a1.parent - a1 parent {} a1 toBe readable a1 toBe writable a1 toBe aRegularFile diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt new file mode 100644 index 000000000..c05359c31 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -0,0 +1,35 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.property +import java.nio.file.Path + +class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatureAssertionsSpec( + property(Expect::parent), + fun1.() -> Unit>(Expect::parent), + property(Expect::fileName), + fun1.() -> Unit>(Expect::fileName), + property(Expect::fileNameWithoutExtension), + fun1.() -> Unit>(Expect::fileNameWithoutExtension), + property(Expect::extension), + fun1.() -> Unit>(Expect::extension) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1.fileName + a1 fileName {} + + a1.fileNameWithoutExtension + a1 fileNameWithoutExtension {} + + a1.extension + a1 extension {} + + a1.parent + a1 parent {} + } +} From c0fad62a229039e3123500c3f037bd1a41ab272c Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 2 Feb 2020 00:10:35 +0100 Subject: [PATCH 012/142] prepare 0.10.0 dev cycle --- .github/CONTRIBUTING.md | 2 +- README.md | 219 ++++++++++++++++++----------------- apis/differences.md | 8 +- build.gradle | 7 +- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 6 files changed, 124 insertions(+), 120 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a43446daa..9577075ee 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/v0.9.1/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/master/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index a80a38511..76bff6fc6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Download](https://api.bintray.com/packages/robstoll/tutteli-jars/atrium/images/download.svg)](https://bintray.com/robstoll/tutteli-jars/atrium/_latestVersion "Download from Bintray") [![EUPL](https://img.shields.io/badge/%E2%9A%96-EUPL%201.2-%230b45a6)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-11-12 "License") [![atrium @ kotlinlang.slack.com](https://img.shields.io/static/v1?label=kotlinlang&message=atrium&color=blue&logo=slack)](https://kotlinlang.slack.com/messages/C887ZKGCQ "See invitation link under section FAQ") -[![Build Status Travis](https://travis-ci.org/robstoll/atrium.svg?tag=v0.9.1)](https://travis-ci.org/robstoll/atrium/branches) +[![Build Status Travis](https://travis-ci.org/robstoll/atrium.svg?branch=master)](https://travis-ci.org/robstoll/atrium/branches) [![Build Status GitHub Actions](https://github.com/robstoll/atrium/workflows/Windows/badge.svg)](https://github.com/robstoll/atrium/actions/) [![Coverage](https://codecov.io/gh/robstoll/atrium/branch/master/graph/badge.svg)](https://codecov.io/github/robstoll/atrium/branch/master) [![Newcomers Welcome](https://img.shields.io/badge/%F0%9F%91%8B-Newcomers%20Welcome-blueviolet)](https://github.com/robstoll/atrium/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 "Ask in slack for help") @@ -20,6 +20,13 @@ Atrium currently provides two [API Styles](#api-styles): pure fluent and infix where both of them have their design focus on usability in conjunction with code completion functionality provided by your IDE. See [Examples](#examples) below to get a feel for how you could benefit from Atrium. +---- +❗ You are taking a *sneak peek* at the next version. +Please have a look at the README of the git tag in case you are looking for the documentation of the corresponding version. +For instance, the [README of v0.9.1](https://github.com/robstoll/atrium/tree/v0.9.1/README.md). + +---- + **Table of Content** - [Installation](#installation) - [JVM](#jvm) @@ -128,9 +135,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/v0.9.1/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/v0.9.1/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -159,24 +166,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/master/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/v0.9.1/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/master/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/v0.9.1/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/v0.9.1/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/master/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -234,11 +241,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.1/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -253,7 +260,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -266,7 +273,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -295,7 +302,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -327,7 +334,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -358,7 +365,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -393,7 +400,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -413,7 +420,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -436,7 +443,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -456,7 +463,7 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1 Notice that stacks are filtered so that you only see what is of interest. Filtering can be configured via [`ReporterBuilder`](#reporterbuilder) by choosing an appropriate -[AtriumErrorAdjuster](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). +[AtriumErrorAdjuster](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). Stack frames of Atrium and of test runners (Spek, Kotlintest and JUnit for JVM, mocha for JS) are excluded per default. [Create a Feature Request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]) in case you use a different runner, we can add yours to the list as well. @@ -489,7 +496,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -541,7 +548,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -591,7 +598,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -621,7 +628,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)
@@ -643,7 +650,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -689,7 +696,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -775,7 +782,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -796,7 +803,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -824,7 +831,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -837,7 +844,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -857,7 +864,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -873,7 +880,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -908,7 +915,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -927,7 +934,7 @@ This is reflected in the output, which tells us that we expected that the `numbe Exactly, what about the expected value `2`, why do we not see anything about it in the output? The output does not show anything about the expected value `2` because the predefined assertion verbs have configured [`ReporterBuilder`](#reporterbuilder) -to use an [Only Failure Reporter](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) +to use an [Only Failure Reporter](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) which shows us only assertions (or sub assertions) which failed. Back to the shortcut functions. @@ -948,7 +955,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -987,7 +994,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1003,7 +1010,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1021,7 +1028,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1050,7 +1057,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1100,7 +1107,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1124,7 +1131,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1140,7 +1147,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1160,7 +1167,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1182,7 +1189,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1208,7 +1215,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1239,7 +1246,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1258,7 +1265,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1294,7 +1301,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1318,7 +1325,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) `isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry`. There are more assertion functions, a full list can be found in -[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). +[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). In case you should miss an assertion function, then please [open a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]). @@ -1335,7 +1342,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1350,7 +1357,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1372,7 +1379,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1409,7 +1416,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1443,7 +1450,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1483,7 +1490,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1501,11 +1508,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.1/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/v0.9.1/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/master/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1539,7 +1546,7 @@ We try to provide a workaround whenever possible._ There is, but IntelliJ will not show it to you due to [this bug](https://youtrack.jetbrains.com/issue/KT-24836) (please upvote it). You should be able to see the KDoc of other functions without problems. -But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). +But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). @@ -1612,7 +1619,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1654,7 +1661,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1671,7 +1678,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1747,7 +1754,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1762,9 +1769,9 @@ Let us see how we actually defined `isMultipleOf`. the assertion to itself (creating alone is not enough, it needs to be added in order that it is evaluated). The method `createAndAddAssertion` returns itself (the same `Expect`) making it easy for you to provide a fluent API as well. - The method [createAndAddAssertion](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) + The method [createAndAddAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) expects: - - a either a `String` or a [Translatable](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) + - a either a `String` or a [Translatable](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) as description of your assertion. - the representation of the expected value. - and the actual check as lambda where you typically use `it` which refers to the subject of the assertion. @@ -1787,7 +1794,7 @@ fun Expect.isEven() = ``` -We are using a [RawString](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting/-raw-string/index.html) +We are using a [RawString](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) here so that `"an even number"` is not treated as a `String` in reporting. Its usage looks then as follows: @@ -1796,7 +1803,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1895,7 +1902,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1927,7 +1934,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1968,7 +1975,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.1/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2029,7 +2036,7 @@ fun >> Expect.sameInitialsAs( There are a few additional methods which you can call after `mapArguments`. -See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). +See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). In case you want to provide your own implementation it suffices to create an extension function for `ArgumentMapperBuilder`. @@ -2039,21 +2046,21 @@ extension function for `ArgumentMapperBuilder`. Yet, sometimes we would like to create functions which have a better error reporting than the one we get when we compose assertion functions. -[`ExpectImpl`](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) is the entry point in this case. Its a builder and thus lets you find the functions you need via code completion. Following a quick overview what it provides: - all assertion functions on the domain level (what you have seen in [Compose-assertion-functions](#compose-assertion-functions) was the API level) so that you can reuse and compose them in other ways. -- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). +- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/master/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/v0.9.1/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2065,7 +2072,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/v0.9.1/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/master/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2079,7 +2086,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/v0.9.1/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/master/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2120,7 +2127,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2152,8 +2159,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/v0.9.1/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2183,24 +2190,24 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
💬 Using a TranslationSupplier Next to providing translations via code you can also use a -[TranslationSupplier](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) -based [Translator](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translator/index.html) +[TranslationSupplier](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) +based [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) by configuring the [`ReporterBuilder`](#reporterbuilder) accordingly (e.g. use `withDefaultTranslationSupplier` instead of `withoutTranslations`). Atrium supports a properties files based `TranslationSupplier` for JVM (a supplier for JS will follow) which is more or less what [ResourceBundle](https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html) provides out of the box. Yet, a `Translator` uses a more enhanced fallback mechanism compared to a `ResourceBundle`. -For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.reporting.translating/-translator/index.html). +For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). Notice though, that we plan to move away from the `ResourceBundle`-inspired approach due to enconding problems and missing implementations on other platforms than JVM. @@ -2259,15 +2266,15 @@ fun _isMultipleOf(container: Expect, base: Int): Assertion = Notice that the impl-function is not an extension function as before because we do not want to pollute the API of `Expect` with this function. -In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) +In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) (`createAndAddAssertion` does the same under the hood) with a test which defines whether the assertion holds as well as a description (`IS_MULTIPLE_OF`) and a representation (`base`). -[`ExpectImpl`](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) helps you in writing own assertion functions. We suggest you use it as entry point (rather than memorizing different class names), it guides you to existing assertion function implementations for different types -as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) +as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) which in turn helps you with creating assertions. In the API module we define the extension function and call the impl-function: @@ -2319,17 +2326,17 @@ Both have their design focus on interoperability with code completion functional -- so that you can let your IDE do some of the work. Atrium is -[built up by different modules](https://docs.atriumlib.org/0.9.0/docc/) +[built up by different modules](https://docs.atriumlib.org/latest#/doc/) and it is your choice which implementation you want to use. However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.1/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.1/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for more information and to see how the API styles differ. @@ -2344,15 +2351,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/v0.9.1/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2406,13 +2413,13 @@ expect(sequenceOf(1, 2, 3)).feature { f(it::asIterable) }.contains(2) ## Where do I find a list of all available functions? Atrium provides KDoc for all APIs - have a look at their KDoc: -- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) -- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) Deprecated APIs: -- [atrium-api-cc-en_GB](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-api-cc-en_UK](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) -- [atrium-api-cc-de_CH](https://docs.atriumlib.org/0.9.0/docc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) +- [atrium-api-cc-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-api-cc-en_UK](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) +- [atrium-api-cc-de_CH](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) ## Problems in conjunction with `feature` @@ -2491,7 +2498,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/v0.9.1/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/master/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 505507290..1663e47f6 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,14 +14,14 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/0.9.0/docc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.0/docc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.0/docc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) +- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/v0.9.1/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) for the rest): ``` dependencies { diff --git a/build.gradle b/build.gradle index 64a0278c8..bb8381952 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,10 @@ buildscript { - rootProject.version = '0.9.1' + rootProject.version = '0.10.0-SNAPSHOT' rootProject.group = 'ch.tutteli.atrium' def sampleProjectsFun = subprojects.findAll { it.projectDir.path.contains('/samples/') || it.projectDir.path.contains('\\samples\\') } - def toolProjectsFun = subprojects.findAll { - it.projectDir.path.contains('/misc/tools/') || it.projectDir.path.contains('\\misc\\tools\\') - } ext { // main kbox_version = '0.14.3' @@ -45,7 +42,7 @@ buildscript { ghPages_version = rootProject.version srcKotlin = 'src/main/kotlin' github_url = "https://github.com/robstoll/${rootProject.name}" - dokka_sourceMapping = "tree/v0.9.1" + dokka_sourceMapping = "tree/master" sampleProjects = sampleProjectsFun diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 9d50886e5..888ac9bb2 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index fa9c005ce..35fcd84a6 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.1/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From 1a8ba31d97eb9bfca9ec099221b596d3297d6c1d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 4 Feb 2020 22:00:00 +0100 Subject: [PATCH 013/142] re-activate the new infix API --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 58ea66d51..3c2e71196 100644 --- a/settings.gradle +++ b/settings.gradle @@ -62,7 +62,7 @@ include { apis('api-') { apiWithExtensions(delegate, 'fluent-en_GB') -// apiWithExtensions(delegate, 'infix-en_GB') + apiWithExtensions(delegate, 'infix-en_GB') } domain('domain-') { From 50ee05b33412fdb402c65c7a9f7f97e73ada8a5a Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 4 Feb 2020 22:01:10 +0100 Subject: [PATCH 014/142] use 0.9.1 in bc/bbc tests instead of 0.9.0 --- misc/tools/atrium-bc-test/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/tools/atrium-bc-test/build.gradle b/misc/tools/atrium-bc-test/build.gradle index e684dc2de..ba9357166 100644 --- a/misc/tools/atrium-bc-test/build.gradle +++ b/misc/tools/atrium-bc-test/build.gradle @@ -369,7 +369,7 @@ createBcAndBbcTasksForApis('0.8.0', ')', 'cc-de_CH', 'cc-en_GB', 'cc-infix-en_GB' ) -createBcAndBbcTasksForApis('0.9.0', +createBcAndBbcTasksForApis('0.9.1', 'forgive=^$', 'fluent-en_GB' ) From 7b2f86f5eb5e4cc128c92b6c2f7de86f8ca5d6b1 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 4 Feb 2020 22:13:16 +0100 Subject: [PATCH 015/142] re-add toolProjectsFun (revert part of c0fad62a) --- build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle b/build.gradle index bb8381952..76c61f68b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,9 @@ buildscript { def sampleProjectsFun = subprojects.findAll { it.projectDir.path.contains('/samples/') || it.projectDir.path.contains('\\samples\\') } + def toolProjectsFun = subprojects.findAll { + it.projectDir.path.contains('/misc/tools/') || it.projectDir.path.contains('\\misc\\tools\\') + } ext { // main kbox_version = '0.14.3' From b51752ad5423726e463b44aaae9eff9ed199b9d6 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 17 Jan 2020 23:37:38 +0100 Subject: [PATCH 016/142] add unifySignatures to simplify feature specs, start with Result... --- .../en_GB/IterableFeatureAssertionsSpec.kt | 4 +- .../kotlin_1_3/ResultFeatureAssertionsSpec.kt | 10 +- .../ResultFeatureAssertionsSpec.kt | 259 +++++++----------- .../ch/tutteli/atrium/specs/testUtils.kt | 104 ++++++- 4 files changed, 190 insertions(+), 187 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt index d7d75beae..c2dc89cf1 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt @@ -6,9 +6,9 @@ import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented class IterableFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableFeatureAssertionsSpec( - feature0, Int>(Expect>::min, "min"), + feature0, Int>(Expect>::min), fun1, Expect.() -> Unit>(Expect>::min), - feature0, Int>(Expect>::max, "max"), + feature0, Int>(Expect>::max), fun1, Expect.() -> Unit>(Expect>::max) ) { @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt index 6be2a19ba..e6ea9a467 100644 --- a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt @@ -1,17 +1,15 @@ package ch.tutteli.atrium.api.fluent.en_GB.kotlin_1_3 import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.feature0 -import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.specs.integration.ResultFeatureAssertionsSpec -import ch.tutteli.atrium.specs.notImplemented class ResultFeatureAssertionsSpec : ResultFeatureAssertionsSpec( feature0, Int>(Expect>::isSuccess), fun1, Expect.() -> Unit>(Expect>::isSuccess), - feature0, Int?>(Expect>::isSuccess), - fun1, Expect.() -> Unit>(Expect>::isSuccess), - "isFailure" to Companion::isFailureFeature, + feature0, Int?>(Expect>::isSuccess).adjustName { "$it nullable" }, + fun1, Expect.() -> Unit>(Expect>::isSuccess).adjustName { "$it nullable" }, + ("isFailure" to Companion::isFailureFeature).withFeatureSuffix(), "isFailure" to Companion::isFailure ) { companion object { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt index 3851acedc..3a8e17b8b 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt @@ -26,14 +26,14 @@ abstract class ResultFeatureAssertionsSpec( include(object : SubjectLessSpec>( describePrefix, - isSuccessFeature.forSubjectLess().adjustName { "$it feature" }, + isSuccessFeature.forSubjectLess(), isSuccess.forSubjectLess { toBe(1) }, - isFailureFeature.forSubjectLess().adjustName { "$it feature" }, + isFailureFeature.forSubjectLess(), isFailure.forSubjectLess { messageContains("message") } ) {}) include(object : SubjectLessSpec>( - describePrefix, - isSuccessNullableFeature.forSubjectLess().adjustName { "$it feature" }, + "$describePrefix[nullable] ", + isSuccessNullableFeature.forSubjectLess(), isSuccessNullable.forSubjectLess { toBe(1) } ) {}) @@ -42,11 +42,12 @@ abstract class ResultFeatureAssertionsSpec( isSuccess.forAssertionCreatorSpec("$toBeDescr: 2") { toBe(2) } ) {}) include(object : AssertionCreatorSpec>( - describePrefix, Result.success(2), + "$describePrefix[nullable] ", Result.success(2), isSuccessNullable.forAssertionCreatorSpec("$toBeDescr: 2") { toBe(2) } ) {}) + include(object : AssertionCreatorSpec>( - describePrefix, Result.failure(IllegalArgumentException("oh no...")), + "$describePrefix[failure] ", Result.failure(IllegalArgumentException("oh no...")), assertionCreatorSpecTriple( isFailure.name, "${VALUE.getDefault()}: \"oh no...\"", @@ -55,8 +56,8 @@ abstract class ResultFeatureAssertionsSpec( ) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val resultSuccess = Result.success(1) val resultFailure = Result.failure(IllegalArgumentException("oh no...")) @@ -69,185 +70,111 @@ abstract class ResultFeatureAssertionsSpec( val exceptionDescr = DescriptionResultAssertion.EXCEPTION.getDefault() val isADescr = DescriptionAnyAssertion.IS_A.getDefault() - describeFun("${isSuccessFeature.name} feature", "${isFailureFeature.name} feature") { - val isSuccessFun = isSuccessFeature.lambda - val isFailureFun = isFailureFeature.lambda + describeFun(isSuccessFeature, isSuccess, isFailureFeature, isFailure) { + val successFunctions = unifySignatures(isSuccessFeature, isSuccess) + val failureFunctions = unifySignatures(isFailureFeature, isFailure) - context("$resultSuccess") { - it("${isSuccessFeature.name} - can perform sub-assertion which holds") { - expect(resultSuccess).isSuccessFun().toBe(1) - } - it("${isSuccessFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultSuccess).isSuccessFun().toBe(2) - }.toThrow { - messageContains("value: 1", "$toBeDescr: 2") + context("subject is $resultSuccess") { + successFunctions.forEach { (name, isSuccessFun, _) -> + it("$name - can perform sub-assertion which holds") { + expect(resultSuccess).isSuccessFun { toBe(1) } + } + it("$name - can perform sub-assertion which fails, throws AssertionError") { + expect { + expect(resultSuccess).isSuccessFun { toBe(2) } + }.toThrow { + messageContains("value: 1", "$toBeDescr: 2") + } } } - it("${isFailureFeature.name} - throws AssertionError showing the expected type") { - expect { - expect(resultSuccess).isFailureFun() - }.toThrow { - messageContains( - "exception: $isNotFailureDescr", - "$isADescr: ${IllegalArgumentException::class.simpleName}" - ) + + failureFunctions.forEach { (name, isFailureFun, hasExtraHint) -> + it("$name - throws AssertionError showing the expected type" + if (hasExtraHint) " and the expected message" else "") { + expect { + expect(resultSuccess).isFailureFun { messageContains("oh yes...") } + }.toThrow { + messageContains( + "exception: $isNotFailureDescr", + "$isADescr: ${IllegalArgumentException::class.simpleName}" + ) + if (hasExtraHint) { + messageContains( + CONTAINS.getDefault(), + "${VALUE.getDefault()}: \"oh yes...\"" + ) + } + } } } } - context("$resultFailure") { - it("${isSuccessFeature.name} - throws AssertionError") { - expect { - expect(resultFailure).isSuccessFun().toBe(1) - }.toThrow { - messageContains("value: $isNotSuccessDescr") + context("subject is $resultFailure") { + successFunctions.forEach { (name, isSuccessFun, hasExtraHint) -> + it("$name throws AssertionError" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + expect { + expect(resultFailure).isSuccessFun { toBe(1) } + }.toThrow { + messageContains("value: $isNotSuccessDescr") + if (hasExtraHint) messageContains("$toBeDescr: 1") + } } } - it("${isFailureFeature.name} - does not throw AssertionError") { - expect(resultFailure).isFailureFun() - } - it("${isFailureFeature.name} - can perform sub-assertion which holds") { - expect(resultFailure).isFailureFun().messageContains("oh no...") - } - it("${isFailureFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultFailure).isFailureFun().messageContains("oh yes...") - }.toThrow { - messageContains( - "$exceptionDescr: ${IllegalArgumentException::class.fullName}", - CONTAINS.getDefault(), "${VALUE.getDefault()}: \"oh yes...\"" - ) + failureFunctions.forEach { (name, isFailureFun, _) -> + it("$name - can perform sub-assertion which holds") { + expect(resultFailure).isFailureFun { messageContains("oh no...") } + } + it("$name - can perform sub-assertion which fails, throws AssertionError") { + expect { + expect(resultFailure).isFailureFun { messageContains("oh yes...") } + }.toThrow { + messageContains( + "$exceptionDescr: ${IllegalArgumentException::class.fullName}", + CONTAINS.getDefault(), "${VALUE.getDefault()}: \"oh yes...\"" + ) + } } } } } - describeFun(isSuccess.name, isFailure.name) { - val isSuccessFun = isSuccess.lambda - val isFailureFun = isFailure.lambda - context("$resultSuccess") { - it("${isSuccessFeature.name} - can perform sub-assertion which holds") { - expect(resultSuccess).isSuccessFun { toBe(1) } - } - it("${isSuccessFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultSuccess).isSuccessFun { toBe(2) } - }.toThrow { - messageContains("value: 1", "$toBeDescr: 2") - } - } - it("${isFailureFeature.name} - throws AssertionError showing the expected type and the expected message") { - expect { - expect(resultSuccess).isFailureFun { messageContains("oh yes...") } - }.toThrow { - messageContains( - "exception: $isNotFailureDescr", - "$isADescr: ${IllegalArgumentException::class.simpleName}", - CONTAINS.getDefault(), "${VALUE.getDefault()}: \"oh yes...\"" - ) - } - } - } + describeFun(isSuccessNullableFeature, isSuccessNullable) { + val successFunctions = unifySignatures(isSuccessNullableFeature, isSuccessNullable) - context("$resultFailure") { - it("${isSuccessFeature.name} throws AssertionError but shows intended sub-assertion") { - expect { - expect(resultFailure).isSuccessFun { toBe(1) } - }.toThrow { - messageContains("value: $isNotSuccessDescr", "$toBeDescr: 1") + successFunctions.forEach { (name, isSuccessFun, hasExtraHint) -> + context("$resultNullableSuccess") { + it("$name - can perform sub-assertion which holds") { + expect(resultNullableSuccess).isSuccessFun { toBe(1) } + } + it("$name - can perform sub-assertion which fails, throws AssertionError") { + expect { + expect(resultNullableSuccess).isSuccessFun { toBe(2) } + }.toThrow { + messageContains("value: 1", "$toBeDescr: 2") + } } } - it("${isFailure.name} - can perform sub-assertion which holds") { - expect(resultFailure).isFailureFun { messageContains("oh no...") } - } - it("${isFailure.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultFailure).isFailureFun { messageContains("oh yes...") } - }.toThrow { - messageContains( - "$exceptionDescr: ${IllegalArgumentException::class.fullName}", - CONTAINS.getDefault(), "${VALUE.getDefault()}: \"oh yes...\"" - ) + context("$resultNullSuccess") { + it("$name - can perform sub-assertion which holds") { + expect(resultNullSuccess).isSuccessFun { toBe(null) } + } + it("$name - can perform sub-assertion which fails, throws AssertionError") { + expect { + expect(resultNullSuccess).isSuccessFun { toBe(2) } + }.toThrow { + messageContains("value: null", "$toBeDescr: 2") + } } } - } - } - describeFun("${isSuccessNullableFeature.name} nullable feature") { - val isSuccessFun = isSuccessNullableFeature.lambda - - context("$resultNullableSuccess") { - it("${isSuccessFeature.name} - can perform sub-assertion which holds") { - expect(resultNullableSuccess).isSuccessFun().toBe(1) - } - it("${isSuccessFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultNullableSuccess).isSuccessFun().toBe(2) - }.toThrow { - messageContains("value: 1", "$toBeDescr: 2") - } - } - } - context("$resultNullSuccess") { - it("${isSuccessFeature.name} - can perform sub-assertion which holds") { - expect(resultNullSuccess).isSuccessFun().toBe(null) - } - it("${isSuccessFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultNullSuccess).isSuccessFun().toBe(2) - }.toThrow { - messageContains("value: null", "$toBeDescr: 2") - } - } - } - - context("$resultNullableFailure") { - it("${isSuccessFeature.name} throws AssertionError") { - expect { - expect(resultNullableFailure).isSuccessFun().toBe(1) - }.toThrow { - messageContains("value: $isNotSuccessDescr") - } - } - } - } - - describeFun("${isSuccessNullable.name} nullable") { - val isSuccessFun = isSuccessNullable.lambda - - context("$resultNullableSuccess") { - it("${isSuccessFeature.name} - can perform sub-assertion which holds") { - expect(resultNullableSuccess).isSuccessFun { toBe(1) } - } - it("${isSuccessFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultNullableSuccess).isSuccessFun { toBe(2) } - }.toThrow { - messageContains("value: 1", "$toBeDescr: 2") - } - } - } - context("$resultNullSuccess") { - it("${isSuccessFeature.name} - can perform sub-assertion which holds") { - expect(resultNullSuccess).isSuccessFun { toBe(null) } - } - it("${isSuccessFeature.name} - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultNullSuccess).isSuccessFun { toBe(2) } - }.toThrow { - messageContains("value: null", "$toBeDescr: 2") - } - } - } - - context("$resultNullableFailure") { - it("${isSuccessFeature.name} throws AssertionError but shows intended sub-assertion") { - expect { - expect(resultNullableFailure).isSuccessFun { toBe(1) } - }.toThrow { - messageContains("value: $isNotSuccessDescr", "$toBeDescr: 1") + context("$resultNullableFailure") { + it("${isSuccessFeature.name} throws AssertionError" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + expect { + expect(resultNullableFailure).isSuccessFun { toBe(1) } + }.toThrow { + messageContains("value: $isNotSuccessDescr") + if (hasExtraHint) messageContains("$toBeDescr: 1") + } } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index 48d0f2102..e233314f5 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -6,22 +6,24 @@ import ch.tutteli.atrium.core.polyfills.format import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.subExpect import ch.tutteli.atrium.translations.DescriptionBasic +import kotlin.jvm.JvmName import kotlin.reflect.KFunction1 import kotlin.reflect.KFunction2 import kotlin.reflect.KFunction3 import kotlin.reflect.KProperty1 -typealias Fun = Pair +typealias SpecPair = Pair -inline val Fun.name get(): String = this.first -inline val Fun.lambda get(): T = this.second -inline fun Fun.adjustName(f: (String) -> String): Fun = f(name) to lambda +inline val SpecPair.name get(): String = this.first +inline val SpecPair.lambda get(): T = this.second +inline fun SpecPair.withFeatureSuffix(): SpecPair = "$name (feature)" to lambda +inline fun SpecPair.adjustName(f: (String) -> String): SpecPair = f(name) to lambda -typealias Feature0 = Fun.() -> Expect> -typealias Feature1 = Fun.(A1) -> Expect> -typealias Feature2 = Fun.(A1, A2) -> Expect> -typealias Feature3 = Fun.(A1, A2, A3) -> Expect> -typealias Feature4 = Fun.(A1, A2, A3, A4) -> Expect> +typealias Feature0 = SpecPair.() -> Expect> +typealias Feature1 = SpecPair.(A1) -> Expect> +typealias Feature2 = SpecPair.(A1, A2) -> Expect> +typealias Feature3 = SpecPair.(A1, A2, A3) -> Expect> +typealias Feature4 = SpecPair.(A1, A2, A3, A4) -> Expect> typealias Fun0 = Feature0 typealias Fun1 = Feature1 @@ -105,12 +107,88 @@ inline fun Fun2.() -> Unit, Array.() -> Unit>> ) ) +fun unifySignatures( + f0: Feature0, + f1: Fun1.() -> Unit> +): List.(Expect.() -> Unit) -> Expect, Boolean>> = + listOf( + Triple(f0.name, f0.withSubAssertion(), false), + Triple(f1.name, f1.lambda, true) + ) + +@JvmName("unifySignatures1") +fun unifySignatures( + f0: Feature1, + f1: Fun2.() -> Unit> +): List.(A1, Expect.() -> Unit) -> Expect, Boolean>> = + listOf( + Triple(f0.name, f0.withSubAssertion(), false), + Triple(f1.name, f1.lambda, true) + ) + +@JvmName("unifySignatures2") +fun unifySignatures( + f0: Feature2, + f1: Fun3.() -> Unit> +): List.(A1, A2, Expect.() -> Unit) -> Expect, Boolean>> = + listOf( + Triple(f0.name, f0.withSubAssertion(), false), + Triple(f1.name, f1.lambda, true) + ) + +@JvmName("unifySignatures0Feature") +fun unifySignatures( + f0: Feature0, + f1: Feature1.() -> Unit, R> +): List.(Expect.() -> Unit) -> Expect, Boolean>> { + val f0WithSubAssertion: Expect.(Expect.() -> Unit) -> Expect = + { f: Expect.() -> Unit -> (f0.lambda)().apply(f) } + return listOf( + Triple(f0.name, f0WithSubAssertion, false), + Triple(f1.name, f1.lambda, true) + ) +} + +@JvmName("unifySignatures1Feature") +fun unifySignatures( + f0: Feature1, + f1: Feature2.() -> Unit, R> +): List.(A1, Expect.() -> Unit) -> Expect, Boolean>> { + val f0WithSubAssertion: Expect.(A1, Expect.() -> Unit) -> Expect = + { a1, f: Expect.() -> Unit -> (f0.lambda)(a1).apply(f) } + return listOf( + Triple(f0.name, f0WithSubAssertion, false), + Triple(f1.name, f1.lambda, true) + ) +} + + +internal inline fun Feature0.withSubAssertion(): Expect.(Expect.() -> Unit) -> Expect = + { f: Expect.() -> Unit -> apply { (lambda)().f() } } + +@JvmName("withSubAssertion1") +internal inline fun Feature1.withSubAssertion() + : Expect.(A1, Expect.() -> Unit) -> Expect = + { a1, f: Expect.() -> Unit -> apply { (lambda)(a1).f() } } + +@JvmName("withSubAssertion2") +internal inline fun Feature2.withSubAssertion(): + Expect.(A1, A2, Expect.() -> Unit) -> Expect = + { a1, a2, f: Expect.() -> Unit -> apply { (lambda)(a1, a2).f() } } + +@JvmName("withSubAssertion3") +internal inline fun Feature3.withSubAssertion(): + Expect.(A1, A2, A3, Expect.() -> Unit) -> Expect = + { a1, a2, a3, f: Expect.() -> Unit -> apply { (lambda)(a1, a2, a3).f() } } //@formatter:off -inline fun property(f: KProperty1, Expect>, suffix: String = ""): Feature0 = f.name + suffix to f -inline fun feature0(f: KFunction1, Expect>, suffix: String = ""): Feature0 = f.name + suffix to f -inline fun feature1(f: KFunction2, A1, Expect>, suffix: String = ""): Feature1 = f.name + suffix to f -inline fun feature2(f: KFunction3, A1, A2, Expect>, suffix: String = ""): Feature2 = f.name + suffix to f +inline fun property(f: KProperty1, Expect>): Feature0 = (f.name to f).withFeatureSuffix() +//TODO simplify further instead of adjustName { "$it nullable" } once https://youtrack.jetbrains.com/issue/KT-35992 is fixed +//@JvmName("feature0Nullable") +//inline fun feature0(f: KFunction1, Expect>): Feature0 = "${f.name} (nullable feature)" to f +inline fun feature0(f: KFunction1, Expect>): Feature0 = (f.name to f).withFeatureSuffix() +inline fun feature1(f: KFunction2, A1, Expect>): Feature1 = (f.name to f).withFeatureSuffix() +inline fun feature2(f: KFunction3, A1, A2, Expect>): Feature2 = (f.name to f).withFeatureSuffix() inline fun fun0(f: KFunction1, Expect>, suffix: String = ""): Fun0 = f.name + suffix to f inline fun fun1(f: KFunction2, A1, Expect>, suffix: String = ""): Fun1 = f.name + suffix to f From ac08da51cb789be92af81676bb15e4b2c04c0d82 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 19 Jan 2020 00:21:57 +0100 Subject: [PATCH 017/142] simplify and enhance ThrowableAssertionsSpec - add cases for empty and blank Throwable.message --- .../ResultFeatureAssertionsSpec.kt | 1 + .../integration/ThrowableAssertionsSpec.kt | 213 +++++++++--------- 2 files changed, 105 insertions(+), 109 deletions(-) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt index 3a8e17b8b..ae3f8eef0 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt @@ -119,6 +119,7 @@ abstract class ResultFeatureAssertionsSpec( } } } + failureFunctions.forEach { (name, isFailureFun, _) -> it("$name - can perform sub-assertion which holds") { expect(resultFailure).isFailureFun { messageContains("oh no...") } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt index f833c1b16..e84c8cdad 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt @@ -2,15 +2,14 @@ package ch.tutteli.atrium.specs.integration -import ch.tutteli.atrium.api.fluent.en_GB.contains -import ch.tutteli.atrium.api.fluent.en_GB.messageContains -import ch.tutteli.atrium.api.fluent.en_GB.toBe -import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.core.polyfills.fullName import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionAnyAssertion +import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion.CONTAINS +import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion.VALUE import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite @@ -22,7 +21,7 @@ abstract class ThrowableAssertionsSpec( ) : Spek({ include(object : SubjectLessSpec( - "$describePrefix[nullable Key] ", + describePrefix, messageFeature.forSubjectLess(), message.forSubjectLess { toBe("hello") }, messageContains.forSubjectLess("hello", arrayOf()) @@ -33,129 +32,125 @@ abstract class ThrowableAssertionsSpec( message.forAssertionCreatorSpec("$toBeDescr: hello") { toBe("hello") } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) + + describeFun(messageFeature, message, messageContains) { + val messageFunctions = unifySignatures(messageFeature, message) + val messageContainsFun = messageContains.lambda + + context("Throwable.message is null") { + val throwable: Throwable = IllegalArgumentException() + + messageFunctions.forEach { (name, messageFun, hasExtraHint) -> + it("$name - throws an AssertionError" + if (hasExtraHint) " which shows intended sub assertion" else "") { + expect { + expect(throwable).messageFun { toBe("hello") } + }.toThrow { + messageContains( + DescriptionAnyAssertion.IS_A.getDefault(), + String::class.fullName + ) + if (hasExtraHint) messageContains("$toBeDescr: \"hello\"") + } + } + } + + it("${messageContains.name} - throws an AssertionError which shows intended sub assertion") { - describeFun("${messageFeature.name} feature") { - val messageFun = messageFeature.lambda - checkNarrowingAssertion( - "it throws an AssertionError if the ${Throwable::message.name} is null", - { message -> - val throwable: Throwable = IllegalArgumentException() expect { - expect(throwable).message() + expect(throwable).messageContainsFun(1, arrayOf(2.3, 'z', "hello")) }.toThrow { messageContains( - DescriptionAnyAssertion.IS_A.getDefault(), - String::class.fullName + DescriptionAnyAssertion.IS_A.getDefault(), String::class.fullName, + CONTAINS.getDefault(), + VALUE.getDefault() + ": 1", + VALUE.getDefault() + ": 2.3", + VALUE.getDefault() + ": 'z'", + VALUE.getDefault() + ": \"hello\"" ) } - }, - { messageFun().toBe("hello") } - ) - - context("it allows to define an assertion for the ${Throwable::message.name} if it is not null") { - val throwable: Throwable = IllegalArgumentException("oh no") - checkNarrowingAssertion( - "it throws an AssertionError if the assertion does not hold", - { messageWithCheck -> - expect { - expect(throwable).messageWithCheck() - }.toThrow() - }, - { messageFun().contains("hello") } - ) - - checkNarrowingAssertion( - "it does not throw an exception if the assertion holds", - { messageWithCheck -> expect(throwable).messageWithCheck() }, { messageFun().contains("oh") } - ) + } } - } - describeFun(message.name) { - val messageFun = message.lambda - checkNarrowingAssertion( - "it throws an AssertionError if the ${Throwable::message.name} is null", - { message -> - val throwable: Throwable = IllegalArgumentException() - expect { - expect(throwable).message() - }.toThrow { - messageContains( - DescriptionAnyAssertion.IS_A.getDefault(), - String::class.fullName - ) - } - }, - { messageFun { toBe("hello") } } - ) - - context("it allows to define an assertion for the ${Throwable::message.name} if it is not null") { - val throwable: Throwable = IllegalArgumentException("oh no") - checkNarrowingAssertion( - "it throws an AssertionError if the assertion does not hold", - { messageWithCheck -> + context("Throwable.message is empty") { + val throwable: Throwable = IllegalArgumentException("") + messageFunctions.forEach { (name, messageFun, _) -> + it("$name - throws an AssertionError if the assertion does not hold") { expect { - expect(throwable).messageWithCheck() - }.toThrow() - }, - { messageFun { contains("hello") } } - ) + expect(throwable).messageFun { toBe("hello") } + }.toThrow { messageContains("$toBeDescr: \"hello\"") } + } - checkNarrowingAssertion( - "it does not throw an exception if the assertion holds", - { messageWithCheck -> expect(throwable).messageWithCheck() }, - { messageFun { contains("oh") } } - ) + it("$name - does not throw if the assertion holds") { + expect(throwable).messageFun { isEmpty() } + } + } + it("${messageContains.name} - throws an AssertionError if the assertion does not hold") { + expect { + expect(throwable).messageContainsFun("nada", arrayOf()) + }.toThrow { messageContains(VALUE.getDefault() + ": \"nada\"") } + } + it("${messageContains.name} - throws IllegalArgumentException if empty string is passed") { + expect { + expect(throwable).messageContainsFun("", arrayOf()) + }.toThrow() + } } - } - describeFun(messageContains.name) { - - checkNarrowingAssertion( - "it throws an AssertionError if the ${Throwable::message.name} is null", - { messageContainsFun -> - val throwable: Throwable = IllegalArgumentException() - expect { - expect(throwable).messageContainsFun() - }.toThrow { - messageContains(DescriptionAnyAssertion.IS_A.getDefault(), String::class.fullName) + context("Throwable.message is blank") { + val throwable: Throwable = IllegalArgumentException(" ") + messageFunctions.forEach { (name, messageFun, _) -> + it("$name - throws an AssertionError if the assertion does not hold") { + expect { + expect(throwable).messageFun { toBe("hello") } + }.toThrow { messageContains("$toBeDescr: \"hello\"") } } - }, - { (messageContains.lambda)(1, arrayOf(2.3, 'z', "hello")) }) + it("$name - does not throw if the assertion holds") { + expect(throwable).messageFun { toBe(" ") } + } + } + it("${messageContains.name} - throws an AssertionError if the assertion does not hold") { + expect { + expect(throwable).messageContainsFun("nada", arrayOf()) + }.toThrow { messageContains(VALUE.getDefault() + ": \"nada\"") } + } + it("${messageContains.name} - does not throw if the assertion holds") { + expect(throwable).messageContainsFun(" ", arrayOf()) + } + } - context("it allows to define an assertion for the ${Throwable::message.name} if it is not null") { - val throwable: Throwable = IllegalArgumentException("1 2.3 z hello") - checkNarrowingAssertion( - "it throws an AssertionError if the assertion does not hold", - { messageContains -> + context("Throwable.message is not empty/blank") { + val throwable: Throwable = IllegalArgumentException("1 and 2.3 with extra z results in hello") + + messageFunctions.forEach { (name, messageFun, _) -> + it("$name - throws an AssertionError if the assertion does not hold") { expect { - expect(throwable).messageContains() - }.toThrow() - }, - { (messageContains.lambda)("nada", arrayOf()) } - ) + expect(throwable).messageFun { toBe("hello") } + }.toThrow { messageContains("$toBeDescr: \"hello\"") } + } - checkNarrowingAssertion( - "it does not throw an exception if the assertion holds", - { messageWithCheck -> - expect(throwable).messageWithCheck() - }, - { (messageContains.lambda)(1, arrayOf(2.3, 'z', "hello")) } - ) + it("$name - does not throw if the assertion holds") { + expect(throwable).messageFun { contains("hello") } + } + } + it("${messageContains.name} - throws an AssertionError if the assertion does not hold") { + expect { + expect(throwable).messageContainsFun("nada", arrayOf()) + }.toThrow { messageContains(VALUE.getDefault() + ": \"nada\"") } + } + it("${messageContains.name} - does not throw if the assertion holds") { + expect(throwable).messageContainsFun(1, arrayOf(2.3, 'z', "hello")) + } + } - checkNarrowingAssertion( - "it throws an IllegalArgumentException if an object is passed", - { messageContains -> - expect { - expect(throwable).messageContains() - }.toThrow() - }, - { (messageContains.lambda)(Pair(1, 2), arrayOf()) } - ) + it("${messageContains.name} - throws an IllegalArgumentException if an object is passed") { + val throwable: Throwable = IndexOutOfBoundsException() + expect { + expect(throwable).messageContainsFun(Pair(1, 2), arrayOf()) + }.toThrow() } } }) From 56835c519ce791107ef79e9da8cd9128b33fe4ce Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 29 Jan 2020 15:34:11 +0100 Subject: [PATCH 018/142] simplify MapFeatureAssertionsSpec with unified signatures --- .../fluent/en_GB/MapFeatureAssertionsSpec.kt | 4 +- .../integration/MapFeatureAssertionsSpec.kt | 193 ++++++------------ 2 files changed, 64 insertions(+), 133 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt index 80dddc742..ad333fc54 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt @@ -10,8 +10,8 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA fun1, Expect>.() -> Unit>(Expect>::values), feature1, String, Int>(Expect>::getExisting), fun2, String, Expect.() -> Unit>(Expect>::getExisting), - feature1, String?, Int?>(Expect>::getExisting), - fun2, String?, Expect.() -> Unit>(Expect>::getExisting) + feature1, String?, Int?>(Expect>::getExisting).adjustName { "$it nullable" }, + fun2, String?, Expect.() -> Unit>(Expect>::getExisting).adjustName { "$it nullable" } ) { @Suppress("unused", "UNUSED_VALUE") diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt index 9c5fe4e9f..92851e765 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.translations.DescriptionCollectionAssertion import ch.tutteli.atrium.translations.DescriptionMapAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite @@ -24,14 +25,14 @@ abstract class MapFeatureAssertionsSpec( val mapNullable = mapOf("a" to 1, "b" to null, null to 3) include(object : SubjectLessSpec>(describePrefix, - keysFeature.forSubjectLess().adjustName { "$it feature" }, + keysFeature.forSubjectLess(), keys.forSubjectLess { isEmpty() }, - valuesFeature.forSubjectLess().adjustName { "$it feature" }, + valuesFeature.forSubjectLess(), values.forSubjectLess { isEmpty() }, getExistingFeature.forSubjectLess("a"), getExisting.forSubjectLess("a") { isGreaterThan(1) } ) {}) - include(object : SubjectLessSpec>("$describePrefix[nullable Key] ", + include(object : SubjectLessSpec>("$describePrefix[nullable] ", getExistingNullableFeature.forSubjectLess("a"), getExistingNullable.forSubjectLess("a") { toBe(null) } ) {}) @@ -43,161 +44,91 @@ abstract class MapFeatureAssertionsSpec( getExisting.forAssertionCreatorSpec("$toBeDescr: 2", "b") { toBe(2) } ) {}) include(object : AssertionCreatorSpec>( - "$describePrefix[nullable Element] ", mapNullable, + "$describePrefix[nullable] ", mapNullable, getExistingNullable.forAssertionCreatorSpec("$toBeDescr: 2", "b") { toBe(null) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val fluent = expect(map) val fluentNullable = expect(mapNullable) val keyDoesNotExist = DescriptionMapAssertion.KEY_DOES_NOT_EXIST.getDefault() - describeFun("${keysFeature.name} feature") { - val keysVal = keysFeature.lambda + describeFun(keysFeature, keys, valuesFeature, values) { + val keysFunctions = unifySignatures(keysFeature, keys) + val valuesFunctions = unifySignatures(valuesFeature, values) context("map with two entries") { - it("hasSize(2) holds") { - fluent.keysVal().hasSize(2) + keysFunctions.forEach { (name, keysFun, _) -> + it("$name - hasSize(2) holds") { + fluent.keysFun { hasSize(2) } + } + it("$name - hasSize(1) fails") { + expect { + fluent.keysFun { hasSize(1) } + }.toThrow { + messageContains("keys: [a, b]") + } + } } - it("hasSize(1) fails") { - expect { - fluent.keysVal().hasSize(1) - }.toThrow { - messageContains("keys: [a, b]") + valuesFunctions.forEach { (name, valuesFun, _) -> + it("$name - hasSize(2) holds") { + fluent.valuesFun { hasSize(2) } + } + it("$name - hasSize(1) fails") { + expect { + fluent.valuesFun { hasSize(1) } + }.toThrow { + messageContains("values: [1, 2]") + } } } } } - describeFun(keys.name) { - val keysFun = keys.lambda - - context("map with two entries") { - it("hasSize(2) holds") { - fluent.keysFun { hasSize(2) } - } - it("hasSize(1) fails") { - expect { - fluent.keysFun { hasSize(1) } - }.toThrow { - messageContains("keys: [a, b]") - } - } - } - } - - - describeFun("${valuesFeature.name} feature") { - val valuesVal = valuesFeature.lambda - - context("map with two entries") { - it("hasSize(2) holds") { - fluent.valuesVal().hasSize(2) - } - it("hasSize(1) fails") { - expect { - fluent.valuesVal().hasSize(1) - }.toThrow { - messageContains("values: [1, 2]") - } - } - } - } - - describeFun(values.name) { - val valuesFun = values.lambda - - context("map with two entries") { - it("hasSize(2) holds") { - fluent.valuesFun { hasSize(2) } - } - it("hasSize(1) fails") { - expect { - fluent.valuesFun { hasSize(1) } - }.toThrow { - messageContains("values: [1, 2]") - } - } - } - } - - describeFun("${getExistingFeature.name} feature") { - val getExistingFun = getExistingFeature.lambda - context("map $map") { - it("can perform sub-assertion on existing key") { - fluent.getExistingFun("a").toBe(1) - } - it("non-existing key throws") { - expect { - fluent.getExistingFun("c").toBe(1) - }.toThrow { - messageContains("get(\"c\"): $keyDoesNotExist") - } - } - } - } - - describeFun(getExisting.name) { - val getExistingFun = getExisting.lambda + describeFun(getExistingFeature, getExisting) { + val getExistingFunctions = unifySignatures(getExistingFeature, getExisting) context("map $map") { - it("can perform sub-assertion on existing key") { - fluent.getExistingFun("a") { toBe(1) } - } - it("non-existing key throws but shows intended sub-assertion") { - expect { - fluent.getExistingFun("c") { toBe(3) } - }.toThrow { - messageContains("get(\"c\"): $keyDoesNotExist", "$toBeDescr: 3") + getExistingFunctions.forEach { (name, getExistingFun, hasExtraHint) -> + it("$name - can perform sub-assertion on existing key") { + fluent.getExistingFun("a") { toBe(1) } + } + it("$name - non-existing key throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + expect { + fluent.getExistingFun("c") { toBe(3) } + }.toThrow { + messageContains("get(\"c\"): $keyDoesNotExist") + if (hasExtraHint) messageContains("$toBeDescr: 3") + } } } } } - describeFun("${getExistingNullableFeature.name} nullable feature") { - val getExistingNullableFun = getExistingNullableFeature.lambda + describeFun(getExistingNullableFeature, getExistingNullable) { + val getExistingFunctions = unifySignatures(getExistingNullableFeature, getExistingNullable) context("map $mapNullable") { - it("can perform sub-assertion on existing key") { - fluentNullable.getExistingNullableFun("a").toBe(1) - } - it("can perform sub-assertion on existing key which is null") { - fluentNullable.getExistingNullableFun(null).toBe(3) - } - it("can perform sub-assertion on existing key whose value is null") { - fluentNullable.getExistingNullableFun("b").toBe(null) - } - it("non-existing key throws") { - expect { - fluentNullable.getExistingNullableFun("c").toBe(null) - }.toThrow { - messageContains("get(\"c\"): $keyDoesNotExist") + getExistingFunctions.forEach { (name, getExistingFun, hasExtraHint) -> + it("$name - can perform sub-assertion on existing key") { + fluentNullable.getExistingFun("a") { toBe(1) } } - } - } - } - - describeFun("$getExistingNullable for nullable") { - val getExistingNullableFun = getExistingNullable.lambda - - context("map $mapNullable") { - it("can perform sub-assertion on existing key") { - fluentNullable.getExistingNullableFun("a") { toBe(1) } - } - it("can perform sub-assertion on existing key which is null") { - fluentNullable.getExistingNullableFun(null) { toBe(3) } - } - it("can perform sub-assertion on existing key whose value is null") { - fluentNullable.getExistingNullableFun("b") { toBe(null) } - } - it("non-existing key throws but shows intended sub-assertion") { - expect { - fluentNullable.getExistingNullableFun("c") { toBe(null) } - }.toThrow { - messageContains("get(\"c\"): $keyDoesNotExist", "$toBeDescr: null") + it("$name - can perform sub-assertion on existing key which is null") { + fluentNullable.getExistingFun(null) { toBe(3) } + } + it("$name - can perform sub-assertion on existing key whose value is null") { + fluentNullable.getExistingFun("b") { toBe(null) } + } + it("$name - non-existing key throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + expect { + fluentNullable.getExistingFun("c") { toBe(null) } + }.toThrow { + messageContains("get(\"c\"): $keyDoesNotExist") + if (hasExtraHint) messageContains("$toBeDescr: null") + } } } } From ea64bc41aeb0b11220d7bb7539dba5bf56a3cebe Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 29 Jan 2020 16:00:48 +0100 Subject: [PATCH 019/142] simplify KeyValueLikeFeatureAssertionsSpec with unified signatures --- .../en_GB/MapEntryFeatureAssertionsSpec.kt | 9 +- .../KeyValueLikeFeatureAssertionsSpec.kt | 253 ++++++------------ .../integration/MapFeatureAssertionsSpec.kt | 4 +- 3 files changed, 90 insertions(+), 176 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt index 0b4fab830..414d12fec 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.adjustName import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property @@ -10,10 +11,10 @@ class MapEntryFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEnt fun1, Expect.() -> Unit>(Expect>::key), property, Int>(Expect>::value), fun1, Expect.() -> Unit>(Expect>::value), - property, String?>(Expect>::key), - fun1, Expect.() -> Unit>(Expect>::key), - property, Int?>(Expect>::value), - fun1, Expect.() -> Unit>(Expect>::value) + property, String?>(Expect>::key).adjustName { "$it nullable" }, + fun1, Expect.() -> Unit>(Expect>::key).adjustName { "$it nullable" }, + property, Int?>(Expect>::value).adjustName { "$it nullable" }, + fun1, Expect.() -> Unit>(Expect>::value).adjustName { "$it nullable" } ) { @Suppress("unused", "UNUSED_VALUE") diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt index 9485338c3..3f4f94dae 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt @@ -4,7 +4,8 @@ import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* -import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE +import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion +import ch.tutteli.atrium.translations.DescriptionComparableAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite @@ -26,18 +27,19 @@ abstract class KeyValueLikeFeatureAssertionsSpec( val mapEntry = creator("hello", 1) val nullMapEntry = creatorNullable(null, null) - val toBeDescr = TO_BE.getDefault() include(object : SubjectLessSpec(describePrefix, - keyFeature.forSubjectLess().adjustName { "$it feature" }, + keyFeature.forSubjectLess(), key.forSubjectLess { endsWith("a") }, - valueFeature.forSubjectLess().adjustName { "$it feature" }, + valueFeature.forSubjectLess(), value.forSubjectLess { isGreaterThan(2) } ) {}) include(object : SubjectLessSpec( "$describePrefix[nullable] ", - nullableKeyFeature.forSubjectLess().adjustName { "$it feature" }, - nullableValueFeature.forSubjectLess().adjustName { "$it feature" } + nullableKeyFeature.forSubjectLess(), + nullableKey.forSubjectLess { toBe(null) }, + nullableValueFeature.forSubjectLess(), + nullableValue.forSubjectLess { toBe(null) } ) {}) include(object : AssertionCreatorSpec( @@ -46,13 +48,13 @@ abstract class KeyValueLikeFeatureAssertionsSpec( value.forAssertionCreatorSpec("$toBeDescr: 1") { toBe(1) } ) {}) include(object : AssertionCreatorSpec( - describePrefix, nullMapEntry, + "$describePrefix[nullable]", nullMapEntry, nullableKey.forAssertionCreatorSpec("$toBeDescr: null") { toBe(null) }, nullableValue.forAssertionCreatorSpec("$toBeDescr: null") { toBe(null) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val nullableMapEntry = creatorNullable("hello", 1) @@ -60,187 +62,98 @@ abstract class KeyValueLikeFeatureAssertionsSpec( val nullableFluent = expect(nullableMapEntry) val nullFluent = expect(nullMapEntry) - describeFun("${keyFeature.name} feature") { - val keyVal = keyFeature.lambda - + describeFun(keyFeature, key, valueFeature, value) { + val keyFunctions = unifySignatures(keyFeature, key) + val valueFunctions = unifySignatures(valueFeature, value) context("$mapEntry") { - it("startsWith(h) holds") { - fluent.keyVal().startsWith("h") - } - it("endsWith(h) fails") { - expect { - fluent.keyVal().endsWith("h") - }.toThrow { - messageContains("$keyName: \"hello\"") + keyFunctions.forEach { (name, keyFun, _) -> + it("$name - startsWith(h) holds") { + fluent.keyFun { startsWith("h") } + } + it("$name - endsWith(h) fails") { + expect { + fluent.keyFun { endsWith('h') } + }.toThrow { + messageContains( + "$keyName: \"hello\"", + DescriptionCharSequenceAssertion.ENDS_WITH.getDefault() + ": \"h\"" + ) + } } } - } - } - describeFun(key.name) { - val keyFun = key.lambda - - context("$mapEntry") { - it("startsWith(h) holds") { - fluent.keyFun { startsWith("h") } - } - it("endsWith(h) fails") { - expect { - fluent.keyFun { endsWith("h") } - }.toThrow { - messageContains("$keyName: \"hello\"") + valueFunctions.forEach { (name, valueFun, _) -> + it("$name - isGreaterThan(0) holds") { + fluent.valueFun { isGreaterThan(0) } + } + it("$name - isGreaterThan(1) fails") { + expect { + fluent.valueFun { isGreaterThan(1) } + }.toThrow { + messageContains( + "$valueName: 1", + DescriptionComparableAssertion.IS_GREATER_THAN.getDefault() + ": 1" + ) + } } } } } - describeFun("${valueFeature.name} feature") { - val valueVal = valueFeature.lambda - - context("$mapEntry") { - it("isGreaterThan(0) holds") { - fluent.valueVal().isGreaterThan(0) - } - it("isGreaterThan(1) fails") { - expect { - fluent.valueVal().isGreaterThan(1) - }.toThrow { - messageContains("$valueName: 1") - } - } - } - } - - describeFun(value.name) { - val valueFun = value.lambda - - context("$mapEntry") { - it("isGreaterThan(0) holds") { - fluent.valueFun { isGreaterThan(0) } - } - it("isGreaterThan(1) fails") { - expect { - fluent.valueFun { isGreaterThan(1) } - }.toThrow { - messageContains("$valueName: 1") - } - } - } - } - - describeFun("${nullableKeyFeature.name} nullable feature") { - val nullableKeyFun = nullableKeyFeature.lambda + describeFun(nullableKeyFeature, nullableKey, nullableValueFeature, nullableValue) { + val keyFunctions = unifySignatures(nullableKeyFeature, nullableKey) + val valueFunctions = unifySignatures(nullableValueFeature, nullableValue) context("$nullableMapEntry") { - it("toBe(hello)") { - nullableFluent.nullableKeyFun().toBe("hello") + keyFunctions.forEach { (name, nullableKeyFun, _) -> + it("$name - toBe(hello) holds") { + nullableFluent.nullableKeyFun { toBe("hello") } + } + it("$name - toBe(null) throws AssertionError") { + expect { + nullableFluent.nullableKeyFun { toBe(null) } + }.toThrow { + messageContains("$keyName: \"hello\"") + } + } } - it("toBe(null) fails") { - expect { - nullableFluent.nullableKeyFun().toBe(null) - }.toThrow { - messageContains("$keyName: \"hello\"") + valueFunctions.forEach { (name, nullableValueFun, _) -> + it("$name - isGreaterThan(0) holds") { + nullableFluent.nullableValueFun { notToBeNull { isGreaterThan(0) } } + } + it("$name - toBe(null) throws AssertionError") { + expect { + nullableFluent.nullableValueFun { toBe(null) } + }.toThrow { + messageContains("$valueName: 1") + } } } } context("$nullMapEntry") { - it("toBe(null)") { - nullFluent.nullableKeyFun().toBe(null) - } - it("toBe(hello) fails") { - expect { - nullFluent.nullableKeyFun().toBe("hello") - }.toThrow { - messageContains("$keyName: null") + keyFunctions.forEach { (name, nullableKeyFun, _) -> + it("$name - toBe(null) holds") { + nullFluent.nullableKeyFun { toBe(null) } + } + it("$name - toBe(hello) throws AssertionError") { + expect { + nullFluent.nullableKeyFun { toBe("hello") } + }.toThrow { + messageContains("$keyName: null", "$toBeDescr: \"hello\"") + } } } - } - } - - describeFun("${nullableKey.name} nullable") { - val nullableKeyFun = nullableKey.lambda - - context("$nullableMapEntry") { - it("toBe(hello)") { - nullableFluent.nullableKeyFun { toBe("hello") } - } - it("toBe(null) fails") { - expect { - nullableFluent.nullableKeyFun { toBe(null) } - }.toThrow { - messageContains("$keyName: \"hello\"") + valueFunctions.forEach { (name, nullableValueFun, _) -> + it("$name - toBe(null) holds") { + nullFluent.nullableValueFun { toBe(null) } } - } - } - context("$nullMapEntry") { - it("toBe(null)") { - nullFluent.nullableKeyFun { toBe(null) } - } - it("toBe(hello) fails") { - expect { - nullFluent.nullableKeyFun { toBe("hello") } - }.toThrow { - messageContains("$keyName: null") - } - } - } - } - - - describeFun("${nullableValueFeature.name} nullable feature") { - val nullableValueFun = nullableValueFeature.lambda - - context("$nullableMapEntry") { - it("isGreaterThan(0) holds") { - nullableFluent.nullableValueFun().notToBeNull { isGreaterThan(0) } - } - it("toBe(null) fails") { - expect { - nullableFluent.nullableValueFun().toBe(null) - }.toThrow { - messageContains("$valueName: 1") - } - } - } - context("$nullMapEntry") { - it("toBe(null)") { - nullFluent.nullableValueFun().toBe(null) - } - it("toBe(1) fails") { - expect { - nullFluent.nullableValueFun().toBe(1) - }.toThrow { - messageContains("$valueName: null") - } - } - } - } - - describeFun("${nullableValue.name} nullable") { - val nullableValueFun = nullableValue.lambda - - context("$nullableMapEntry") { - it("isGreaterThan(0) holds") { - nullableFluent.nullableValueFun { notToBeNull { isGreaterThan(0) } } - } - it("toBe(null) fails") { - expect { - nullableFluent.nullableValueFun { toBe(null) } - }.toThrow { - messageContains("$valueName: 1") - } - } - } - context("$nullMapEntry") { - it("toBe(null)") { - nullFluent.nullableValueFun { toBe(null) } - } - it("toBe(1) fails") { - expect { - nullFluent.nullableValueFun { toBe(1) } - }.toThrow { - messageContains("$valueName: null") + it("$name - toBe(1) throws AssertionError") { + expect { + nullFluent.nullableValueFun { toBe(1) } + }.toThrow { + messageContains("$valueName: null") + } } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt index 92851e765..7d7803ba7 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt @@ -65,7 +65,7 @@ abstract class MapFeatureAssertionsSpec( it("$name - hasSize(2) holds") { fluent.keysFun { hasSize(2) } } - it("$name - hasSize(1) fails") { + it("$name - hasSize(1) throws AssertionError") { expect { fluent.keysFun { hasSize(1) } }.toThrow { @@ -77,7 +77,7 @@ abstract class MapFeatureAssertionsSpec( it("$name - hasSize(2) holds") { fluent.valuesFun { hasSize(2) } } - it("$name - hasSize(1) fails") { + it("$name - hasSize(1) throws AssertionError") { expect { fluent.valuesFun { hasSize(1) } }.toThrow { From b361c661afa8992e1d92118f1be708871eee4853 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 29 Jan 2020 16:06:33 +0100 Subject: [PATCH 020/142] simplify MapAsEntriesAssertionsSpec.kt with unified signatures --- .../integration/MapAsEntriesAssertionsSpec.kt | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAsEntriesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAsEntriesAssertionsSpec.kt index 20c867cf3..4d22ea6a6 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAsEntriesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAsEntriesAssertionsSpec.kt @@ -15,32 +15,27 @@ abstract class MapAsEntriesAssertionsSpec( include(object : SubjectLessSpec>( describePrefix, - asEntriesFeature.forSubjectLess().adjustName { "$it feature" }, + asEntriesFeature.forSubjectLess(), asEntries.forSubjectLess { contains("a" to 1) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) - describeFun(asEntriesFeature.name + " feature") { - it("transformation can be applied and an assertion made") { - expect(mapOf("a" to 1, "b" to 2)).(asEntriesFeature.lambda)().contains.inAnyOrder.only.entries( - { isKeyValue("b", 2) }, - { key { startsWith("a") }.and.value.isGreaterThanOrEqual(1) } - ) - } - } + describeFun(asEntriesFeature, asEntries) { + val asEntriesFunctions = unifySignatures(asEntriesFeature, asEntries) - describeFun(asEntries.name) { - it("transformation can be applied and an assertion made") { - expect(mapOf("a" to 1, "b" to 2)).(asEntries.lambda){ - contains.inAnyOrder.only.entries( - { isKeyValue("b", 2) }, - { - key { startsWith("a") } - value.isGreaterThanOrEqual(1) - } - ) + asEntriesFunctions.forEach{ (name, asEntriesFun, _) -> + it("$name - transformation can be applied and an assertion made") { + expect(mapOf("a" to 1, "b" to 2)).asEntriesFun { + contains.inAnyOrder.only.entries( + { isKeyValue("b", 2) }, + { + key { startsWith("a") } + value.isGreaterThanOrEqual(1) + } + ) + } } } } From a1d1b9209ed9bbaefdf84701f4413ee3fe78d230 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 29 Jan 2020 16:12:40 +0100 Subject: [PATCH 021/142] simplify ListFeatureAssertionsSpec.kt with unified signatures --- .../fluent/en_GB/ListFeatureAssertionsSpec.kt | 5 +- .../integration/ListFeatureAssertionsSpec.kt | 81 +++++++++---------- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt index 81c46f13a..8b8d20a69 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.adjustName import ch.tutteli.atrium.specs.feature1 import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented @@ -8,8 +9,8 @@ import ch.tutteli.atrium.specs.notImplemented object ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatureAssertionsSpec( feature1, Int, Int>(Expect>::get), fun2, Int, Expect.() -> Unit>(Expect>::get), - feature1, Int, Int?>(Expect>::get), - fun2, Int, Expect.() -> Unit>(Expect>::get) + feature1, Int, Int?>(Expect>::get).adjustName { "$it nullable" }, + fun2, Int, Expect.() -> Unit>(Expect>::get).adjustName { "$it nullable" } ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt index 8f46c20d6..ef398bef9 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt @@ -21,11 +21,11 @@ abstract class ListFeatureAssertionsSpec( val list = listOf(1, 2, 3, 4) include(object : SubjectLessSpec>(describePrefix, - getFeature.forSubjectLess(1).adjustName { "$it feature" }, + getFeature.forSubjectLess(1), get.forSubjectLess(1) { toBe(1) } ) {}) include(object : SubjectLessSpec>("$describePrefix[nullable Element] ", - getNullableFeature.forSubjectLess(1).adjustName { "$it feature" }, + getNullableFeature.forSubjectLess(1), getNullable.forSubjectLess(1) { toBe(null) } ) {}) @@ -38,9 +38,8 @@ abstract class ListFeatureAssertionsSpec( getNullable.forAssertionCreatorSpec("$toBeDescr: 2", 1) { toBe(2) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val fluent = expect(list) val listNullable = listOf(1, null, 3, 4) @@ -48,39 +47,28 @@ abstract class ListFeatureAssertionsSpec( val indexOutOfBounds = DescriptionListAssertion.INDEX_OUT_OF_BOUNDS.getDefault() - describeFun("${getFeature.name} feature") { - val getFun = getFeature.lambda + describeFun(getFeature, get) { + val getFunctions = unifySignatures(getFeature, get) context("list $list") { - it("can perform sub-assertion on existing index") { - fluent.getFun(0).toBe(1) - } - it("non-existing index throws") { - expect { - fluent.getFun(4).toBe(1) - }.toThrow { - messageContains("get(4): $indexOutOfBounds") + getFunctions.forEach { (name, getFun, hasExtraHint) -> + it("$name - can perform sub-assertion on existing index") { + fluent.getFun(0) { toBe(1) } + } + it("$name - non-existing index throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + expect { + fluent.getFun(4) { toBe(3) } + }.toThrow { + messageContains("get(4): $indexOutOfBounds") + if (hasExtraHint) messageContains("$toBeDescr: 3") + } } } + + } } - describeFun(get.name) { - val getFun = get.lambda - context("list $list") { - it("can perform sub-assertion on existing index") { - fluent.getFun(0) { toBe(1) } - } - it("non-existing index throws but shows intended sub-assertion") { - expect { - fluent.getFun(4) { toBe(3) } - }.toThrow { - messageContains("get(4): $indexOutOfBounds", "$toBeDescr: 3") - } - } - } - } - - describeFun("${getNullableFeature.name} nullable feature") { + describeFun(getNullableFeature) { val getFun = getNullableFeature.lambda context("list $listNullable") { it("can perform sub-assertion on existing key") { @@ -100,21 +88,24 @@ abstract class ListFeatureAssertionsSpec( } } - describeFun("${getNullable.name} nullable") { - val getFun = getNullable.lambda + describeFun(getNullableFeature, getNullable) { + val getFunctions = unifySignatures(getNullableFeature, getNullable) context("list $listNullable") { - it("can perform sub-assertion on existing key") { - fluentNullable.getFun(0) { toBe(1) } - } - it("can perform sub-assertion on existing key with value null") { - fluentNullable.getFun(1) { toBe(null) } - } + getFunctions.forEach { (name, getFun, hasExtraHint) -> + it("$name - can perform sub-assertion on existing key") { + fluentNullable.getFun(0) { toBe(1) } + } + it("$name - can perform sub-assertion on existing key with value null") { + fluentNullable.getFun(1) { toBe(null) } + } - it("non-existing key throws but shows intended sub-assertion") { - expect { - fluentNullable.getFun(4) { toBe(null) } - }.toThrow { - messageContains("get(4): $indexOutOfBounds", "$toBeDescr: null") + it("$name - non-existing key throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + expect { + fluentNullable.getFun(4) { toBe(null) } + }.toThrow { + messageContains("get(4): $indexOutOfBounds") + if (hasExtraHint) messageContains("$toBeDescr: null") + } } } } From 3d0a9ceca1411422963a84ba54c214f1f325c009 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 30 Jan 2020 16:51:24 +0100 Subject: [PATCH 022/142] simplify IterableFeatureAssertionsSpec.kt with unified signatures --- .../IterableFeatureAssertionsSpec.kt | 138 +++++++----------- 1 file changed, 49 insertions(+), 89 deletions(-) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableFeatureAssertionsSpec.kt index ef5a10bcf..ca0053c10 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableFeatureAssertionsSpec.kt @@ -7,17 +7,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.fluent.en_GB.toThrow import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.AssertionCreatorSpec -import ch.tutteli.atrium.specs.Feature0 -import ch.tutteli.atrium.specs.Fun1 -import ch.tutteli.atrium.specs.SubjectLessSpec -import ch.tutteli.atrium.specs.adjustName -import ch.tutteli.atrium.specs.describeFunTemplate -import ch.tutteli.atrium.specs.forAssertionCreatorSpec -import ch.tutteli.atrium.specs.forSubjectLess -import ch.tutteli.atrium.specs.lambda -import ch.tutteli.atrium.specs.name -import ch.tutteli.atrium.specs.toBeDescr +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionIterableAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite @@ -31,9 +21,9 @@ abstract class IterableFeatureAssertionsSpec( ) : Spek({ include(object : SubjectLessSpec>(describePrefix, - minFeature.forSubjectLess().adjustName { "$it feature" }, + minFeature.forSubjectLess(), min.forSubjectLess { isGreaterThan(-100) }, - maxFeature.forSubjectLess().adjustName { "$it feature" }, + maxFeature.forSubjectLess(), max.forSubjectLess { toBe(1) } ) {}) @@ -43,93 +33,63 @@ abstract class IterableFeatureAssertionsSpec( max.forAssertionCreatorSpec("$toBeDescr: 20") { toBe(20) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) - val fluent = expect(listOf(4, 3) as Iterable) - val empty = expect (emptyList() as Iterable) - - describeFun("val ${minFeature.name}") { - val minVal = minFeature.lambda + describeFun(minFeature, min, maxFeature, max) { + val minFunctions = unifySignatures(minFeature, min) + val maxFunctions = unifySignatures(maxFeature, max) context("list with 4 and 3") { - it("toBe(3) holds") { - fluent.minVal().toBe(3) + val fluent = expect(listOf(4, 3) as Iterable) + minFunctions.forEach { (name, minFun, _) -> + it("$name - is greater than 2 holds") { + fluent.minFun { isGreaterThan(2) } + } + it("$name - is less than 2 fails") { + expect { + fluent.minFun { isLessThan(2) } + }.toThrow { + messageContains("min(): 3") + } + } } - it("toBe(5) fails") { - expect { - fluent.minVal().toBe(5) - }.toThrow { - messageContains("min(): 3") + maxFunctions.forEach { (name, maxFun, _) -> + it("$name - toBe(4) holds") { + fluent.maxFun { toBe(4) } + } + it("$name - toBe(3) fails") { + expect { + fluent.maxFun { toBe(3) } + }.toThrow { + messageContains("max(): 4") + } } } } context("empty list") { - it("toBe(3) fails") { - expect { - empty.minVal().toBe(3) - }.toThrow { - messageContains(DescriptionIterableAssertion.NO_ELEMENTS.getDefault()) + val emptyIterable = expect(emptyList() as Iterable) + val noElementsDescr = DescriptionIterableAssertion.NO_ELEMENTS.getDefault() + + minFunctions.forEach { (name, minFun, _) -> + it("$name - fails warning about empty iterable") { + expect { + emptyIterable.minFun { toBe(1) } + }.toThrow { + messageContains(noElementsDescr) + } + } + } + maxFunctions.forEach { (name, maxFun, _) -> + it("$name - fails warning about empty iterable") { + expect { + emptyIterable.maxFun { toBe(1) } + }.toThrow { + messageContains(noElementsDescr) + } } } } } - - describeFun("fun ${min.name}") { - val minFun = min.lambda - - context("list with two entries") { - it("is greater than 2 holds") { - fluent.minFun { isGreaterThan(2) } - } - it("is less than 2 fails") { - expect { - fluent.minFun { isLessThan(2) } - }.toThrow { - messageContains("min(): 3") - } - } - } - } - - describeFun("val ${maxFeature.name}") { - val maxVal = max.lambda - checkMax { assertion -> maxVal(assertion) } - } - - describeFun("fun ${max.name}") { - val maxFun = maxFeature.lambda - checkMax { assert -> maxFun().assert() } - } }) - - -private fun Suite.checkMax(testMax: Expect>.(Expect.() -> Unit) -> Unit) { - val emptyIterable = expect(emptyList() as Iterable) - - val filledIterable = expect(listOf(1, 2) as Iterable) - - context("list with 1 and 2") { - it("toBe(2) holds") { - filledIterable.testMax { toBe(2) } - } - it("toBe(1) fails") { - expect { - filledIterable.testMax { toBe(1) } - }.toThrow { - messageContains("max(): 2") - } - } - } - - context("empty list") { - it("fails warning about empty iterable") { - expect { - emptyIterable.testMax { toBe(1) } - }.toThrow { - messageContains(DescriptionIterableAssertion.NO_ELEMENTS.getDefault()) - } - } - } -} From 8a7234b01488324f49c4da65511f878f7f91aacd Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 5 Feb 2020 22:21:13 +0100 Subject: [PATCH 023/142] rename path toNot exist to ... notTo ... this way it resembles notToBe --- .../api/infix/en_GB/jdk8/pathAssertions.kt | 2 +- .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 03dfde03a..b75ffcd0c 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -79,7 +79,7 @@ infix fun Expect.to(@Suppress("UNUSED_PARAMETER") exist: exist): E * * @since 0.10.0 */ -infix fun Expect.toNot(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = +infix fun Expect.notTo(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.existsNot(this)) /** diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index b81d91dee..e1567ce9c 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -8,24 +8,24 @@ import java.nio.file.Path import java.nio.file.Paths class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpec( - fun1(Expect::to).name to ::exists, - fun1(Expect::toNot).name to ::existsNot, + fun1(Expect::to).name to Companion::exists, + fun1(Expect::notTo).name to Companion::existsNot, fun1(Expect::startsWith), fun1(Expect::startsNotWith), fun1(Expect::endsWith), fun1(Expect::endsNotWith), - fun1(Expect::toBe).name to ::isReadable, - fun1(Expect::toBe).name to ::isWritable, - fun1(Expect::toBe).name to ::isRegularFile, - fun1(Expect::toBe).name to ::isDirectory + fun1(Expect::toBe).name to Companion::isReadable, + fun1(Expect::toBe).name to Companion::isWritable, + fun1(Expect::toBe).name to Companion::isRegularFile, + fun1(Expect::toBe).name to Companion::isDirectory ) { companion object { - fun exists(expect: Expect) = expect to exist - fun existsNot(expect: Expect) = expect toNot exist - fun isReadable(expect: Expect) = expect toBe readable - fun isWritable(expect: Expect) = expect toBe writable - fun isRegularFile(expect: Expect) = expect toBe aRegularFile - fun isDirectory(expect: Expect) = expect toBe aDirectory + private fun exists(expect: Expect) = expect to exist + private fun existsNot(expect: Expect) = expect notTo exist + private fun isReadable(expect: Expect) = expect toBe readable + private fun isWritable(expect: Expect) = expect toBe writable + private fun isRegularFile(expect: Expect) = expect toBe aRegularFile + private fun isDirectory(expect: Expect) = expect toBe aDirectory } @Suppress("unused", "UNUSED_VALUE") @@ -33,7 +33,7 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe val a1: Expect = notImplemented() a1 to exist - a1 toNot exist + a1 notTo exist a1 startsWith Paths.get("a") a1 startsNotWith Paths.get("a") a1 endsWith Paths.get("a") From a81495c562d4aaba7a9d2c972edb415b6c98ff46 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 5 Feb 2020 22:57:31 +0100 Subject: [PATCH 024/142] remove suffix from fun0, fun1 etc. and introduce withNullableSuffix --- .../atrium/api/fluent/en_GB/AnyAssertionsSpec.kt | 16 +++++++++------- ...atingPointWithErrorToleranceAssertionsSpec.kt | 5 +++-- .../fluent/en_GB/ListFeatureAssertionsSpec.kt | 9 +++------ .../en_GB/MapEntryFeatureAssertionsSpec.kt | 13 +++++-------- .../api/fluent/en_GB/MapFeatureAssertionsSpec.kt | 4 ++-- .../kotlin_1_3/ResultFeatureAssertionsSpec.kt | 4 ++-- .../kotlin/ch/tutteli/atrium/specs/testUtils.kt | 7 ++++--- 7 files changed, 28 insertions(+), 30 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/AnyAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/AnyAssertionsSpec.kt index 5ce782d8e..34bb7ccb9 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/AnyAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/AnyAssertionsSpec.kt @@ -2,6 +2,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.withNullableSuffix import kotlin.reflect.KFunction2 import kotlin.reflect.KProperty1 @@ -12,16 +13,16 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( fun1(Expect::toBe), fun1(Expect::notToBe), fun1(Expect::notToBe), - fun1(Expect::notToBe, suffix = " nullable"), - fun1(Expect::notToBe, suffix = " nullable"), + fun1(Expect::notToBe).withNullableSuffix(), + fun1(Expect::notToBe).withNullableSuffix(), fun1(Expect::isSameAs), fun1(Expect::isSameAs), - fun1(Expect::isSameAs, suffix = " nullable"), - fun1(Expect::isSameAs, suffix = " nullable"), + fun1(Expect::isSameAs).withNullableSuffix(), + fun1(Expect::isSameAs).withNullableSuffix(), fun1(Expect::isNotSameAs), fun1(Expect::isNotSameAs), - fun1(Expect::isNotSameAs, suffix = " nullable"), - fun1(Expect::isNotSameAs, suffix = " nullable"), + fun1(Expect::isNotSameAs).withNullableSuffix(), + fun1(Expect::isNotSameAs).withNullableSuffix(), "${Expect::toBe.name}(null)" to Companion::toBeNull, fun1(Expect::toBeNullIfNullGivenElse), @@ -43,7 +44,8 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( companion object { private fun toBeNull(expect: Expect) = expect.toBe(null) - private fun isAFeature(expect: Expect): Expect = expect.isA() + @Suppress("RemoveExplicitTypeArguments") + private fun isAFeature(expect: Expect): Expect = expect.isA() private val andImmediate: KProperty1, Expect> = Expect::and fun getAndImmediatePair(): Pair.() -> Expect> = andImmediate.name to Expect::and diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/FloatingPointWithErrorToleranceAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/FloatingPointWithErrorToleranceAssertionsSpec.kt index 281a0ea08..573590536 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/FloatingPointWithErrorToleranceAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/FloatingPointWithErrorToleranceAssertionsSpec.kt @@ -1,10 +1,11 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.adjustName import ch.tutteli.atrium.specs.fun2 class FloatingPointWithErrorToleranceAssertionsSpec : ch.tutteli.atrium.specs.integration.FloatingPointWithErrorToleranceAssertionsSpec( - fun2(Expect::toBeWithErrorTolerance, suffix = " for Float"), - fun2(Expect::toBeWithErrorTolerance, suffix = " for Double") + fun2(Expect::toBeWithErrorTolerance).adjustName { "$it for Float" }, + fun2(Expect::toBeWithErrorTolerance).adjustName { "$it for Double" } ) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt index 8b8d20a69..6247a9a4f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt @@ -1,16 +1,13 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.adjustName -import ch.tutteli.atrium.specs.feature1 -import ch.tutteli.atrium.specs.fun2 -import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.* object ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatureAssertionsSpec( feature1, Int, Int>(Expect>::get), fun2, Int, Expect.() -> Unit>(Expect>::get), - feature1, Int, Int?>(Expect>::get).adjustName { "$it nullable" }, - fun2, Int, Expect.() -> Unit>(Expect>::get).adjustName { "$it nullable" } + feature1, Int, Int?>(Expect>::get).withNullableSuffix(), + fun2, Int, Expect.() -> Unit>(Expect>::get).withNullableSuffix() ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt index 414d12fec..1696afc76 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryFeatureAssertionsSpec.kt @@ -1,20 +1,17 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.adjustName -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.* class MapEntryFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryFeatureAssertionsSpec( property, String>(Expect>::key), fun1, Expect.() -> Unit>(Expect>::key), property, Int>(Expect>::value), fun1, Expect.() -> Unit>(Expect>::value), - property, String?>(Expect>::key).adjustName { "$it nullable" }, - fun1, Expect.() -> Unit>(Expect>::key).adjustName { "$it nullable" }, - property, Int?>(Expect>::value).adjustName { "$it nullable" }, - fun1, Expect.() -> Unit>(Expect>::value).adjustName { "$it nullable" } + property, String?>(Expect>::key).withNullableSuffix(), + fun1, Expect.() -> Unit>(Expect>::key).withNullableSuffix(), + property, Int?>(Expect>::value).withNullableSuffix(), + fun1, Expect.() -> Unit>(Expect>::value).withNullableSuffix() ) { @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt index ad333fc54..86ede5a7a 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapFeatureAssertionsSpec.kt @@ -10,8 +10,8 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA fun1, Expect>.() -> Unit>(Expect>::values), feature1, String, Int>(Expect>::getExisting), fun2, String, Expect.() -> Unit>(Expect>::getExisting), - feature1, String?, Int?>(Expect>::getExisting).adjustName { "$it nullable" }, - fun2, String?, Expect.() -> Unit>(Expect>::getExisting).adjustName { "$it nullable" } + feature1, String?, Int?>(Expect>::getExisting).withNullableSuffix(), + fun2, String?, Expect.() -> Unit>(Expect>::getExisting).withNullableSuffix() ) { @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt index e6ea9a467..bbc9f52f1 100644 --- a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt @@ -7,8 +7,8 @@ import ch.tutteli.atrium.specs.integration.ResultFeatureAssertionsSpec class ResultFeatureAssertionsSpec : ResultFeatureAssertionsSpec( feature0, Int>(Expect>::isSuccess), fun1, Expect.() -> Unit>(Expect>::isSuccess), - feature0, Int?>(Expect>::isSuccess).adjustName { "$it nullable" }, - fun1, Expect.() -> Unit>(Expect>::isSuccess).adjustName { "$it nullable" }, + feature0, Int?>(Expect>::isSuccess).withNullableSuffix(), + fun1, Expect.() -> Unit>(Expect>::isSuccess).withNullableSuffix(), ("isFailure" to Companion::isFailureFeature).withFeatureSuffix(), "isFailure" to Companion::isFailure ) { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index e233314f5..ae34113cc 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -17,6 +17,7 @@ typealias SpecPair = Pair inline val SpecPair.name get(): String = this.first inline val SpecPair.lambda get(): T = this.second inline fun SpecPair.withFeatureSuffix(): SpecPair = "$name (feature)" to lambda +inline fun SpecPair.withNullableSuffix(): SpecPair = "$name nullable" to lambda inline fun SpecPair.adjustName(f: (String) -> String): SpecPair = f(name) to lambda typealias Feature0 = SpecPair.() -> Expect> @@ -190,9 +191,9 @@ inline fun feature0(f: KFunction1, Expect>): Feature0 inline fun feature1(f: KFunction2, A1, Expect>): Feature1 = (f.name to f).withFeatureSuffix() inline fun feature2(f: KFunction3, A1, A2, Expect>): Feature2 = (f.name to f).withFeatureSuffix() -inline fun fun0(f: KFunction1, Expect>, suffix: String = ""): Fun0 = f.name + suffix to f -inline fun fun1(f: KFunction2, A1, Expect>, suffix: String = ""): Fun1 = f.name + suffix to f -inline fun fun2(f: KFunction3, A1, A2, Expect>, suffix: String = ""): Fun2 = f.name + suffix to f +inline fun fun0(f: KFunction1, Expect>): Fun0 = f.name to f +inline fun fun1(f: KFunction2, A1, Expect>): Fun1 = f.name to f +inline fun fun2(f: KFunction3, A1, A2, Expect>): Fun2 = f.name to f //@formatter:on fun notImplemented(): T = throw NotImplementedError() From f4799f95bdbdbe7cea8714aebfd510b9ad9fa2d0 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 5 Feb 2020 23:47:08 +0100 Subject: [PATCH 025/142] no need to show the infix API in the ambiguityTest and in constructor moreover: - move functions out of spec so that they can be reference without prefix and intellij still works (would compile for companion object but intellij does not find it -- yet another Kotlin bug) --- .../infix/en_GB/CollectionAssertionsSpec.kt | 17 +++---- .../en_GB/CollectionFeatureAssertionsSpec.kt | 10 ++-- .../api/infix/en_GB/Fun0AssertionsSpec.kt | 31 ++++++------ .../infix/en_GB/IterableAllAssertionsSpec.kt | 19 ++++---- .../infix/en_GB/ListFeatureAssertionsSpec.kt | 48 +++++++++---------- .../api/infix/en_GB/MapEntryAssertionsSpec.kt | 21 ++++---- .../en_GB/MapEntryFeatureAssertionsSpec.kt | 2 +- .../infix/en_GB/PairFeatureAssertionsSpec.kt | 25 +++------- ...h.tutteli.atrium.reporting.ReporterFactory | 2 +- .../en_GB/jdk8/FileAsPathAssertionsSpec.kt | 3 ++ .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 29 +++++------ .../en_GB/jdk8/PathFeatureAssertionsSpec.kt | 3 ++ ...h.tutteli.atrium.reporting.ReporterFactory | 1 + .../integration/IterableAllAssertionsSpec.kt | 1 + .../AsciiBulletPointReporterFactory.kt | 4 +- 15 files changed, 100 insertions(+), 116 deletions(-) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory rename {apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB => misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs}/testutils/AsciiBulletPointReporterFactory.kt (94%) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt index 6c83d9016..f20c0bb7b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt @@ -1,22 +1,16 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.reporting.ReporterFactory import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented - class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionAssertionsSpec( - fun1, Empty>(Expect>::toBe).name to Companion::isEmpty, - fun1, Empty>(Expect>::notToBe).name to Companion::isNotEmpty + fun1, Empty>(Expect>::toBe).name to ::isEmpty, + fun1, Empty>(Expect>::notToBe).name to ::isNotEmpty ) { - companion object : WithAsciiReporter() { - - fun isEmpty(expect: Expect>) = expect toBe Empty - fun isNotEmpty(expect: Expect>) = expect notToBe Empty - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -35,3 +29,6 @@ class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionA star notToBe Empty } } + +fun isEmpty(expect: Expect>) = expect toBe Empty +fun isNotEmpty(expect: Expect>) = expect notToBe Empty diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt index 62a713a9f..5ffd4c4eb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt @@ -1,20 +1,16 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property class CollectionFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionFeatureAssertionsSpec( property, Int>(Expect>::size), - fun1, Expect.() -> Unit>(Expect>::size).name to Companion::size + fun1, Expect.() -> Unit>(Expect>::size) ) { - companion object : WithAsciiReporter() { - fun size(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect size { assertionCreator() } - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt index 9c6f7db72..c96eb1f86 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt @@ -1,27 +1,20 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.reporting.ReporterFactory +import ch.tutteli.atrium.specs.feature0 +import ch.tutteli.atrium.specs.feature1 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.withFeatureSuffix class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpec( - "toThrow (feature)" to Companion::toThrowFeature, - "toThrow" to Companion::toThrow, - "notToThrow (feature)" to Companion::notToThrowFeature, - "notToThrow" to Companion::notToThrow, + ("toThrow" to ::toThrowFeature).withFeatureSuffix(), + "toThrow" to ::toThrow, + feature0<() -> Int, Int>(Expect<() -> Int>::notToThrow), + feature1<() -> Int, Expect.() -> Unit, Int>(Expect<() -> Int>::notToThrow), "- ", "» " ) { - companion object : WithAsciiReporter() { - - fun toThrowFeature(expect: Expect Any?>) = expect.toThrow() - fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = - expect.toThrow { assertionCreator() } - - fun notToThrowFeature(expect: Expect<() -> Int>) = expect.notToThrow() - fun notToThrow(expect: Expect<() -> Int>, assertionCreator: Expect.() -> Unit) = - expect.notToThrow { assertionCreator() } - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE", "UNUSED_VARIABLE") private fun ambiguityTest() { @@ -41,3 +34,9 @@ class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpe val r8: Expect = a2.notToThrow {} } } + +private fun toThrowFeature(expect: Expect Any?>) = + expect.toThrow() + +private fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = + expect.toThrow { assertionCreator() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt index db4b521b1..606753783 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt @@ -1,23 +1,18 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix class IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAllAssertionsSpec( - fun1(Expect>::all).name to Companion::all, - fun1(Expect>::all).name to Companion::allNullable, + fun1(Expect>::all).name to ::all, + fun1(Expect>::all).withNullableSuffix().name to ::allNullable, "* ", "(!) ", "- ", "» ", ">> ", "=> " ) { - companion object : WithAsciiReporter() { - fun all(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect all assertionCreator - - fun allNullable(expect: Expect>, assertionCreator: (Expect.() -> Unit)?) = - expect all assertionCreator - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -35,4 +30,8 @@ class IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAl } } +private fun all(expect: Expect>, assertionCreator: Expect.() -> Unit) = + expect all assertionCreator +private fun allNullable(expect: Expect>, assertionCreator: (Expect.() -> Unit)?) = + expect all assertionCreator diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt index 03f3f9fd0..f4fd936c2 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt @@ -1,41 +1,20 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.ListGetStep -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.feature1 -import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix import kotlin.reflect.KFunction2 class ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatureAssertionsSpec( - feature1, Int, Int>(Expect>::get).name to Companion::get, + feature1, Int, Int>(Expect>::get), getIndexPair(), - feature1, Int, Int?>(Expect>::get).name to Companion::getNullable, + feature1, Int, Int?>(Expect>::get).withNullableSuffix(), getIndexNullablePair() ) { - - companion object : WithAsciiReporter() { - fun get(expect: Expect>, index: Int) = expect get index - fun getNullable(expect: Expect>, index: Int) = expect get index - - fun getIndexPair() = getIndexFun.name to ::getIndex - private val getIndexFun: KFunction2>, Index, ListGetStep>> = - Expect>::get - - private fun getIndex(expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit) = - expect get Index(index) assertIt { assertionCreator() } - - fun getIndexNullablePair() = getIndexNullableFun.name to ::getIndexNullable - private val getIndexNullableFun: KFunction2>, Index, ListGetStep>> = - Expect>::get - - private fun getIndexNullable( - expect: Expect>, - index: Int, - assertionCreator: Expect.() -> Unit - ) = expect get Index(index) assertIt { assertionCreator() } - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -54,3 +33,20 @@ class ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatur star = star get Index(1) assertIt { } } } + +private val getIndexFun: KFunction2>, Index, ListGetStep>> = Expect>::get +private fun getIndexPair() = getIndexFun.name to ::getIndex + +private fun getIndex(expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit) = + expect get Index(index) assertIt { assertionCreator() } + +private val getIndexNullableFun: KFunction2>, Index, ListGetStep>> = + Expect>::get + +private fun getIndexNullablePair() = getIndexNullableFun.name to ::getIndexNullable + +private fun getIndexNullable( + expect: Expect>, + index: Int, + assertionCreator: Expect.() -> Unit +) = expect get Index(index) assertIt { assertionCreator() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt index 9455bcfc0..ad3660463 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt @@ -1,22 +1,17 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.withNullableSuffix class MapEntryAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryAssertionsSpec( - fun1(Expect>::isKeyValue).name to Companion::isKeyValue, - fun1(Expect>::isKeyValue).name to Companion::isKeyValueNullable + fun1(Expect>::isKeyValue).name to ::isKeyValue, + (fun1(Expect>::isKeyValue).name to ::isKeyValueNullable).withNullableSuffix() ) { - companion object : WithAsciiReporter() { - fun isKeyValue(expect: Expect>, key: String, value: Int) = - expect isKeyValue (key to value) - - fun isKeyValueNullable(expect: Expect>, key: String?, value: Int?) = - expect isKeyValue (key to value) - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -39,3 +34,9 @@ class MapEntryAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryAsser star isKeyValue (null to null) } } + +private fun isKeyValue(expect: Expect>, key: String, value: Int) = + expect isKeyValue (key to value) + +private fun isKeyValueNullable(expect: Expect>, key: String?, value: Int?) = + expect isKeyValue (key to value) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt index 2c79d3b73..6c2776d8d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt @@ -1,6 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/PairFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/PairFeatureAssertionsSpec.kt index d7d201fc6..9dad34b8e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/PairFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/PairFeatureAssertionsSpec.kt @@ -1,35 +1,22 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class PairFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PairFeatureAssertionsSpec( property, String>(Expect>::first), - fun1, Expect.() -> Unit>(Expect>::first).name to Companion::first, + fun1, Expect.() -> Unit>(Expect>::first), property, Int>(Expect>::second), - fun1, Expect.() -> Unit>(Expect>::second).name to Companion::second, + fun1, Expect.() -> Unit>(Expect>::second), property, String?>(Expect>::first), - fun1, Expect.() -> Unit>(Expect>::first).name to Companion::firstNullable, + fun1, Expect.() -> Unit>(Expect>::first), property, Int?>(Expect>::second), - fun1, Expect.() -> Unit>(Expect>::second).name to Companion::secondNullable + fun1, Expect.() -> Unit>(Expect>::second) ) { - companion object : WithAsciiReporter() { - fun first(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect first { assertionCreator() } - - fun second(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect second { assertionCreator() } - - fun firstNullable(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect first { assertionCreator() } - - fun secondNullable(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect second { assertionCreator() } - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory index 5a5897fe2..111322a35 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory @@ -1 +1 @@ -ch.tutteli.atrium.api.infix.en_GB.testutils.AsciiBulletPointReporterFactory +ch.tutteli.atrium.specs.testutils.AsciiBulletPointReporterFactory diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt index 247a8fb02..9a5a520f2 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt @@ -2,11 +2,14 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import java.io.File class FileAsPathAssertionsSpec : ch.tutteli.atrium.specs.integration.FileAsPathAssertionsSpec( Expect::asPath ) { + companion object : WithAsciiReporter() + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var a1: Expect = notImplemented() diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index e1567ce9c..00d1d0d4a 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name @@ -8,25 +9,18 @@ import java.nio.file.Path import java.nio.file.Paths class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpec( - fun1(Expect::to).name to Companion::exists, - fun1(Expect::notTo).name to Companion::existsNot, + fun1(Expect::to).name to ::exists, + fun1(Expect::notTo).name to ::existsNot, fun1(Expect::startsWith), fun1(Expect::startsNotWith), fun1(Expect::endsWith), fun1(Expect::endsNotWith), - fun1(Expect::toBe).name to Companion::isReadable, - fun1(Expect::toBe).name to Companion::isWritable, - fun1(Expect::toBe).name to Companion::isRegularFile, - fun1(Expect::toBe).name to Companion::isDirectory + fun1(Expect::toBe).name to ::isReadable, + fun1(Expect::toBe).name to ::isWritable, + fun1(Expect::toBe).name to ::isRegularFile, + fun1(Expect::toBe).name to ::isDirectory ) { - companion object { - private fun exists(expect: Expect) = expect to exist - private fun existsNot(expect: Expect) = expect notTo exist - private fun isReadable(expect: Expect) = expect toBe readable - private fun isWritable(expect: Expect) = expect toBe writable - private fun isRegularFile(expect: Expect) = expect toBe aRegularFile - private fun isDirectory(expect: Expect) = expect toBe aDirectory - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -45,4 +39,11 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe } } +private fun exists(expect: Expect) = expect to exist +private fun existsNot(expect: Expect) = expect notTo exist +private fun isReadable(expect: Expect) = expect toBe readable +private fun isWritable(expect: Expect) = expect toBe writable +private fun isRegularFile(expect: Expect) = expect toBe aRegularFile +private fun isDirectory(expect: Expect) = expect toBe aDirectory + class DummyPath(path: Path) : Path by path diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt index c05359c31..76f0bf16b 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import java.nio.file.Path class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatureAssertionsSpec( @@ -16,6 +17,8 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur property(Expect::extension), fun1.() -> Unit>(Expect::extension) ) { + companion object : WithAsciiReporter() + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { val a1: Expect = notImplemented() diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory new file mode 100644 index 000000000..111322a35 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/resources/META-INF/services/ch.tutteli.atrium.reporting.ReporterFactory @@ -0,0 +1 @@ +ch.tutteli.atrium.specs.testutils.AsciiBulletPointReporterFactory diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt index 823295acf..7bc4ac828 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt @@ -53,6 +53,7 @@ abstract class IterableAllAssertionsSpec( context("empty collection") { it("$isLessThanFun(1.0) throws AssertionError") { + println("////////////////////////") expect { fluentEmpty.allFun { isLessThan(1.0) } }.toThrow { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt similarity index 94% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt index bfd58bc0a..1a5d3fec3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testutils/AsciiBulletPointReporterFactory.kt @@ -1,4 +1,4 @@ -package ch.tutteli.atrium.api.infix.en_GB.testutils +package ch.tutteli.atrium.specs.testutils import ch.tutteli.atrium.assertions.* import ch.tutteli.atrium.domain.builders.reporting.ReporterBuilder @@ -6,7 +6,7 @@ import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.ReporterFactory class AsciiBulletPointReporterFactory : ReporterFactory { - override val id = "ascii" + override val id: String = "ascii" override fun create(): Reporter { return ReporterBuilder.create() From 038a8db947224feae6f32fb6b33f4e315529853b Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 6 Feb 2020 00:02:40 +0100 Subject: [PATCH 026/142] add Comparable assertions to the new infix api --- .../api/infix/en_GB/comparableAssertions.kt | 45 +++++++++++++++++++ .../infix/en_GB/ComparableAssertionsSpec.kt | 22 +++++++++ 2 files changed, 67 insertions(+) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ComparableAssertionsSpec.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt new file mode 100644 index 000000000..80409b017 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt @@ -0,0 +1,45 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl + +/** + * Expects that the subject of the assertion is less than [expected]. + * The comparison is carried out with [Comparable.compareTo]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.isLessThan(expected: T) = + addAssertion(ExpectImpl.comparable.isLessThan(this, expected)) + +/** + * Expects that the subject of the assertion is less than or equal [expected]. + * The comparison is carried out with [Comparable.compareTo]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.isLessThanOrEqual(expected: T) = + addAssertion(ExpectImpl.comparable.isLessOrEquals(this, expected)) + +/** + * Expects that the subject of the assertion is greater than [expected]. + * The comparison is carried out with [Comparable.compareTo]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.isGreaterThan(expected: T) = + addAssertion(ExpectImpl.comparable.isGreaterThan(this, expected)) + +/** + * Expects that the subject of the assertion is greater than or equal [expected]. + * The comparison is carried out with [Comparable.compareTo]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.isGreaterThanOrEqual(expected: T) = + addAssertion(ExpectImpl.comparable.isGreaterOrEquals(this, expected)) + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ComparableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ComparableAssertionsSpec.kt new file mode 100644 index 000000000..e079777ef --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ComparableAssertionsSpec.kt @@ -0,0 +1,22 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented + +class ComparableAssertionsSpec : ch.tutteli.atrium.specs.integration.ComparableAssertionsSpec( + fun1(Expect::isLessThan), + fun1(Expect::isLessThanOrEqual), + fun1(Expect::isGreaterThan), + fun1(Expect::isGreaterThanOrEqual) +) { + + @Suppress("unused") + fun ambiguityTest() { + val a1: Expect = notImplemented() + a1 isLessThan 1 + a1 isLessThanOrEqual 1 + a1 isGreaterThan 1 + a1 isGreaterThanOrEqual 1 + } +} From 05c30727078f53ed5452e24c6bf13553cd181052 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 6 Feb 2020 00:15:15 +0100 Subject: [PATCH 027/142] add anyAssertions to the new infix API - also add `and` without group to infix API - turn notToBeNull() into an infix function with the new helper `o` --- .../atrium/api/infix/en_GB/anyAssertions.kt | 194 ++++++++++++++++ .../atrium/api/infix/en_GB/keywords.kt | 30 ++- .../api/infix/en_GB/AnyAssertionsSpec.kt | 214 ++++++++++-------- .../infix/en_GB/CollectionAssertionsSpec.kt | 8 +- .../atrium/api/infix/en_GB/jdk8/keywords.kt | 10 +- 5 files changed, 348 insertions(+), 108 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt new file mode 100644 index 000000000..17980a924 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt @@ -0,0 +1,194 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.checking.AssertionChecker +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.reporting.Reporter + +/** + * Expects that the subject of the assertion is (equal to) [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.toBe(expected: T) = addAssertion(ExpectImpl.any.toBe(this, expected)) + +/** + * Expects that the subject of the assertion is not (equal to) [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.notToBe(expected: T) = addAssertion(ExpectImpl.any.notToBe(this, expected)) + +/** + * Expects that the subject of the assertion is the same instance as [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.isSameAs(expected: T) = addAssertion(ExpectImpl.any.isSame(this, expected)) + +/** + * Expects that the subject of the assertion is not the same instance as [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.isNotSameAs(expected: T) = addAssertion(ExpectImpl.any.isNotSame(this, expected)) + +/** + * Expects that the subject of the assertion is either `null` in case [assertionCreatorOrNull] + * is `null` or is not `null` and holds all assertions [assertionCreatorOrNull] creates. + * + * Depending on the implementation, it is not much more than a shortcut for + * ```kotlin + * if (assertionCreatorOrNull == null) toBe(null) + * else notToBeNull(assertionCreatorOrNull) + * ``` + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +inline infix fun Expect.toBeNullIfNullGivenElse( + noinline assertionCreatorOrNull: (Expect.() -> Unit)? +) = addAssertion(ExpectImpl.any.toBeNullIfNullGivenElse(this, T::class, assertionCreatorOrNull)) + + +/** + * Expects that the subject of the assertion is not null and changes the subject to the non-nullable version. + * + * It delegates to [isA] with [T] as type. + * + * @return An assertion container with the non-nullable type [T] (was `T?` before). + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +@Suppress(/* less magic */ "RemoveExplicitTypeArguments") +inline infix fun Expect.notToBeNull(@Suppress("UNUSED_PARAMETER") o: o): Expect = isA() + +/** + * Expects that the subject of the assertion is not null and + * that it holds all assertions the given [assertionCreator] creates. + * + * It delegates to [isA] with [T] as type. + * + * @return An assertion container with the non-nullable type [T] (was `T?` before) + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +@Suppress(/* less magic */ "RemoveExplicitTypeArguments") +inline infix fun Expect.notToBeNull(noinline assertionCreator: Expect.() -> Unit): Expect = + isA(assertionCreator) + +/** + * Expects that the subject of the assertion *is a* [TSub] (the same type or a sub-type) + * and changes the subject to this type. + * + * Notice, that asserting a function type is [flawed](https://youtrack.jetbrains.com/issue/KT-27846). + * The actual types are ignored as function types erase to Function0, + * Function1 etc. on byte code level, which means the assertion holds as long as the subject is a + * function and has the same amount of arguments regardless if the types differ. For instance + * `assert({x: Int -> "hello"}).isA Unit>{}` holds, even though `(Int) -> String` is clearly not + * a `(String) -> Unit`. + * + * More generally speaking, the [flaw](https://youtrack.jetbrains.com/issue/KT-27826) applies to all generic types. + * For instance `isA>` would only check if the subject is a `List` without checking if + * the element type is actually `String`. Or in other words + * `assert(listOf(1, 2)).isA>{}` holds, even though `List` is clearly not a `List`. + * + * @return An assertion container with the new type [TSub]. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +//TODO make infix and add `o` as parameter as soon as https://youtrack.jetbrains.com/issue/KT-21593 is fixed +inline fun Expect<*>.isA(): Expect = + ExpectImpl.any.isA(this, TSub::class).getExpectOfFeature() + +/** + * Expects that the subject of the assertion *is a* [TSub] (the same type or a sub-type) and + * that it holds all assertions the given [assertionCreator] creates. + * + * Notice, in contrast to other assertion functions which expect an [assertionCreator], this function returns not + * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TSub]. + * This has the side effect that a subsequent call has only assertion functions available which are suited for [TSub]. + * Since [Expect] is invariant it especially means that an assertion function which was not written in a generic way + * will not be available. Fixing such a function is easy (in most cases), + * you need to transform it into a generic from. Following an example: + * + * ``` + * interface Person + * class Student: Person + * fun Expect.foo() = "dummy" // limited only to Person, not recommended + * fun Expect.bar() = "dummy" // available to Person and all subtypes, the way to go + * fun Expect.baz() = "dummy" // specific only for Student, ok since closed class + * + * val p: Person = Student() + * expect(p) // subject of type Person + * .isA { ... } // subject now refined to Student + * .baz() // available via Student + * .foo() // not available to Student, only to Person, results in compilation error + * .bar() // available via T : Person + * ``` + * + * Notice, that asserting a function type is [flawed](https://youtrack.jetbrains.com/issue/KT-27846). + * The actual types are ignored as function types erase to Function0, + * Function1 etc. on byte code level, which means the assertion holds as long as the subject is a + * function and has the same amount of arguments regardless if the types differ. For instance + * `assert({x: Int -> "hello"}).isA Unit>{}` holds, even though `(Int) -> String` is clearly not + * a `(String) -> Unit`. + * + * More generally speaking, the [flaw](https://youtrack.jetbrains.com/issue/KT-27826) applies to all generic types. + * For instance `isA>` would only check if the subject is a `List` without checking if + * the element type is actually `String`. Or in other words + * `assert(listOf(1, 2)).isA>{}` holds, even though `List` is clearly not a `List`. + * + * @return An assertion container with the new type [TSub]. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +inline infix fun Expect<*>.isA(noinline assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.any.isA(this, TSub::class).addToFeature(assertionCreator) + +/** + * Can be used to separate single assertions. + * + * For instance `expect(1).isLessThan(2).and.isGreaterThan(0)` creates + * two assertions (not one assertion with two sub-assertions) - the first asserts that 1 is less than 2 and the second + * asserts that 1 is greater than 0. If the first assertion fails, then usually (depending on the configured + * [AssertionChecker]) the second assertion is not evaluated. + * + * @return This assertion container to support a fluent API. + * + * @since 0.10.0 + */ +@Suppress("NOTHING_TO_INLINE") +inline infix fun Expect.and(@Suppress("UNUSED_PARAMETER") o: o): Expect = this + +/** + * Can be used to create a group of sub assertions when using the fluent API. + * + * For instance `assert(1).isLessThan(3).and { isEven(); isGreaterThan(1) }` creates + * two assertions where the second one consists of two sub-assertions. In case the first assertion holds, then the + * second one is evaluated as a whole. Meaning, even though 1 is not even, it still evaluates that 1 is greater than 1. + * Hence the reporting might (depending on the configured [Reporter]) contain both failing sub-assertions. + * + * @return This assertion container to support a fluent API. + */ +infix fun Expect.and(assertionCreator: Expect.() -> Unit) = addAssertionsCreatedBy(assertionCreator) + +/** + * Inline property referring actually to `this` and allows to write nicer sub-assertions. + * + * For instance, instead of: + * ``` + * expect("hello world") { + * this startsWith "hello" + * this ends with "world" + * } + * ``` + * You can write + * ``` + * expect("hello world") { + * o startsWith "hello" + * o ends with "world" + * } + * ``` + */ +inline val Expect.o get() : Expect = this diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 33f1e47a6..8f1bbc3b9 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -1,4 +1,5 @@ @file:Suppress("ClassName") + package ch.tutteli.atrium.api.infix.en_GB /** @@ -8,47 +9,58 @@ package ch.tutteli.atrium.api.infix.en_GB * (see toBe). */ interface Keyword -internal const val ERR_KEYWORD_GIVEN_COLLECTION_ASSUMED = "This call will most probably fail at runtime because the given subject is not a collection as you might have assumed. If you really want to compare the subject against the keyword, then cast the keyword to Any" + +internal const val ERR_KEYWORD_GIVEN_COLLECTION_ASSUMED = + "This call will most probably fail at runtime because the given subject is not a collection as you might have assumed. If you really want to compare the subject against the keyword, then cast the keyword to Any" /** * Represents a helper construct which allows to express emptiness. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ -object Empty: Keyword +object Empty : Keyword /** * Represents a helper construct which allows to express blankness. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ -object Blank: Keyword +object Blank : Keyword /** * Represents the pseudo keyword `contain` as in [to] `contain`. */ -object contain: Keyword +object contain : Keyword /** * Represents the pseudo keyword `case` as in [ignoring] `case`. */ -object case: Keyword +object case : Keyword /** * Represents the pseudo keyword `entries` as in [grouped] `entries`. */ -object entries: Keyword +object entries : Keyword /** * Represents the pseudo keyword `group` as in [within] `group`. */ -object group: Keyword +object group : Keyword + +/** + * Represents a filler, a pseudo keyword where there isn't really a good keyword. + * A reader should skip this filler without reading it. For instance, `contains o atleast 1...` should be read as + * `contains at least once...` + * + * @since 0.10.0 + */ +object o : Keyword /** * Represents the pseudo keyword `only` as in [and] `only`. */ -object only: Keyword +object only : Keyword /** * Represents the pseudo keyword `order` as in [inAny] `order`. */ -object order: Keyword +object order : Keyword diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt index 899e3abc2..b96d9c2d6 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt @@ -1,100 +1,130 @@ package ch.tutteli.atrium.api.infix.en_GB -//class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( -// fun1(Expect::toBe).name to Companion::toBe, +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.integration.AnyAssertionsSpec +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.withNullableSuffix +import kotlin.reflect.KFunction2 - //TODO adjust the following lines -> also use `fun1<...>(...).name to Companion:...` => see CollectionAssertionsSpec - //we use `fun...` do distinguish between potential overloads but want to see the infix API in action +class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( + fun1(Expect::toBe), + fun1(Expect::toBe), + fun1(Expect::toBe), + fun1(Expect::toBe), + fun1(Expect::notToBe), + fun1(Expect::notToBe), + fun1(Expect::notToBe).withNullableSuffix(), + fun1(Expect::notToBe).withNullableSuffix(), + fun1(Expect::isSameAs), + fun1(Expect::isSameAs), + fun1(Expect::isSameAs).withNullableSuffix(), + fun1(Expect::isSameAs).withNullableSuffix(), + fun1(Expect::isNotSameAs), + fun1(Expect::isNotSameAs), + fun1(Expect::isNotSameAs).withNullableSuffix(), + fun1(Expect::isNotSameAs).withNullableSuffix(), -// fun1(Expect::toBe), -// fun2(Expect::toBe, suffix = " nullable").name to Companion::toBeNullableInt, -// fun2( -// Expect::toBe, -// suffix = " nullable" -// ).name to Companion::toBeNullableDataClass, -// fun1(Expect::notToBe), -// fun1(Expect::notToBe), -// fun1(Expect::notToBe, suffix = " nullable"), -// fun1(Expect::notToBe, suffix = " nullable"), -// fun1(Expect::isSameAs), -// fun1(Expect::isSameAs), -// fun1(Expect::isSameAs, suffix = " nullable"), -// fun1(Expect::isSameAs, suffix = " nullable"), -// fun1(Expect::isNotSameAs), -// fun1(Expect::isNotSameAs), -// fun1(Expect::isNotSameAs, suffix = " nullable"), -// fun1(Expect::isNotSameAs, suffix = " nullable"), -// -// "${Expect::toBe.name}(null)" to Companion::toBeNull, -// fun1(Expect::toBeNullIfNullGivenElse), -// "isA" to Companion::isAFeature, -// "isA" to Companion::isAStringToInt, -// "isA" to Companion::isAStringToInt, -// "isA" to Companion::isAString, -// "isA" to Companion::isACharSequence, -// "isA" to Companion::isASubType, -// "isA" to Companion::isAIntLess, -// "notToBeNull" to Companion::notToBeNull, -// Companion::notToBeNullLess, -// Companion::notToBeNullGreaterAndLess, + "${Expect::toBe.name}(null)" to ::toBeNull, + fun1(Expect::toBeNullIfNullGivenElse), + "isA" to ::isAFeature, + "isA" to ::isAStringToInt, + "isA" to ::isAStringToInt, + "isA" to ::isAString, + "isA" to ::isACharSequence, + "isA" to ::isASubType, + "isA" to ::isAIntLess, + "notToBeNull" to ::notToBeNull, + ::notToBeNullLess, + ::notToBeNullGreaterAndLess, -// getAndImmediatePair(), -// getAndLazyPair() -//) { + getAndImmediatePair(), + getAndLazyPair() +) { -// companion object { + companion object : WithAsciiReporter() -// private fun toBe(expect: Expect, a: Int): Expect = -// expect toBe a + @Suppress("unused") + fun ambiguityTest() { + val a1: Expect = notImplemented() + val a1b: Expect = notImplemented() - //TODO adjust the following to infix API as well -// private fun toBeNullableInt(expect: Expect, a: Int?): Expect = -// expect.toBe(a) -// -// private fun toBeNullableDataClass(expect: Expect, a: DataClass?): Expect = -// expect.toBe(a) -// -// private fun toBeNull(expect: Expect) = expect.toBe(null) -// -// private fun isAFeature(expect: Expect): Expect = expect.isA() -// -// private val andImmediate: KProperty1, Expect> = Expect::and -// fun getAndImmediatePair(): Pair.() -> Expect> = andImmediate.name to Expect::and -// -// private val andLazyName: KFunction2, Expect.() -> Unit, Expect> = Expect::and -// fun getAndLazyPair(): Pair.(Expect.() -> Unit) -> Expect> = -// andLazyName.name to Expect::and -// -// private inline fun isA( -// expect: Expect<*>, -// noinline assertionCreator: Expect.() -> Unit -// ) = expect.isA(assertionCreator) -// -// //TODO get rid of different overloads as soon as https://youtrack.jetbrains.com/issue/KT-19884 is fixed -// private fun isAStringToInt(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = -// isA(expect, assertionCreator) -// -// private fun isAString(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = -// isA(expect, assertionCreator) -// -// private fun isACharSequence(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = -// isA(expect, assertionCreator) -// -// private fun isASubType(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = -// isA(expect, assertionCreator) -// -// private fun isAIntLess(expect: Expect, number: Int) = expect.isA { isLessThan(number) } -// -// private fun notToBeNull(expect: Expect, assertionCreator: Expect.() -> Unit) = -// expect.notToBeNull(assertionCreator) -// -// private fun notToBeNullLess(expect: Expect, number: Int) = -// expect.notToBeNull { isLessThan(number) } -// -// private fun notToBeNullGreaterAndLess(expect: Expect, lowerBound: Int, upperBound: Int) = -// expect.notToBeNull { -// isGreaterThan(lowerBound) -// isLessThan(upperBound) -// } -// } -//} + a1 toBe 1 + a1 toBe 1.2 + a1 notToBe 1 + a1 notToBe 1.2 + a1 isSameAs 1 + a1 isSameAs 1.2 + a1 isNotSameAs 1 + a1 isNotSameAs 1.2 + a1.isA() + a1.isA {} + + a1b toBe 1 + a1b toBe 1.2 + a1b notToBe 1 + a1b notToBe 1.2 + a1b isSameAs 1 + a1b isSameAs 1.2 + a1b isNotSameAs 1 + a1b isNotSameAs 1.2 + a1b.isA() + a1b.isA {} + + a1b notToBeNull o toBe 1 + a1b notToBeNull {} + + a1 and o toBe 1 + a1 and { o toBe 1 } + } + + //regression for #298, should compile without the need for E : Any or List + @Suppress("unused") + fun Expect>.firstIs(value: E) = o get Index(0) assertIt { o toBe value } +} + +private fun toBeNull(expect: Expect) = expect toBe null + +@Suppress("RemoveExplicitTypeArguments") +private fun isAFeature(expect: Expect): Expect = expect.isA() + +private fun getAndImmediatePair(): Pair.() -> Expect> = + "non existing in infix" to { e: Expect -> e } + +private val andLazyName: KFunction2, Expect.() -> Unit, Expect> = Expect::and +private fun getAndLazyPair(): Pair.(Expect.() -> Unit) -> Expect> = + andLazyName.name to Expect::and + +private inline fun isA( + expect: Expect<*>, + noinline assertionCreator: Expect.() -> Unit +) = expect.isA(assertionCreator) + +//TODO get rid of different overloads as soon as https://youtrack.jetbrains.com/issue/KT-19884 is fixed +private fun isAStringToInt(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + +private fun isAString(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + +private fun isACharSequence(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + +private fun isASubType(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + +private fun isAIntLess(expect: Expect, number: Int) = + expect.isA { o isLessThan number } + +private fun notToBeNull(expect: Expect, assertionCreator: Expect.() -> Unit) = + expect notToBeNull assertionCreator + +private fun notToBeNullLess(expect: Expect, number: Int) = + expect.notToBeNull { isLessThan(number) } + +private fun notToBeNullGreaterAndLess(expect: Expect, lowerBound: Int, upperBound: Int) = + expect.notToBeNull { + o isGreaterThan lowerBound + o isLessThan upperBound + } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt index f20c0bb7b..a630924a9 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt @@ -1,14 +1,12 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionAssertionsSpec( - fun1, Empty>(Expect>::toBe).name to ::isEmpty, - fun1, Empty>(Expect>::notToBe).name to ::isNotEmpty + "toBe ${Empty::class.simpleName}" to ::isEmpty, + "toBe ${Empty::class.simpleName}" to ::isNotEmpty ) { companion object : WithAsciiReporter() diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt index 3174b5a4a..48de145f4 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt @@ -1,3 +1,9 @@ +@file:Suppress( + /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */ + "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE", + "ClassName" +) + package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.api.infix.en_GB.Keyword @@ -25,10 +31,10 @@ object aDirectory : Keyword * A helper construct to allow expressing assertions about a path being a readable. * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ -object readable: Keyword +object readable : Keyword /** * A helper construct to allow expressing assertions about a path being a writable. * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ -object writable: Keyword +object writable : Keyword From 2de0ad1a0a571f064c1bb4cde74b62d83319ca31 Mon Sep 17 00:00:00 2001 From: Berry Semexan Date: Thu, 6 Feb 2020 05:51:41 -0500 Subject: [PATCH 028/142] WIP create sample project for Atrium + MPP (#327) needs to be done in addition: - revert changes made in samples/spek - revert changes on gradle wrapper - add android target --- .github/workflows/java-windows.yml | 3 + .travis.yml | 1 + gradle/wrapper/gradle-wrapper.properties | 5 +- samples/jvm/spek/gradlew.bat | 168 ++++++++-------- samples/multiplatform/.gitattributes | 6 + samples/multiplatform/.gitignore | 10 + samples/multiplatform/build.gradle | 41 ++++ samples/multiplatform/gradle.properties | 2 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 58702 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + samples/multiplatform/gradlew | 183 ++++++++++++++++++ samples/multiplatform/gradlew.bat | 100 ++++++++++ samples/multiplatform/settings.gradle | 10 + .../src/commonTest/kotlin/SmokeTest.kt | 116 +++++++++++ .../src/jsTest/kotlin/ch/tutteli/SmokeTest.kt | 70 +++++++ .../src/jsTest/kotlin/testSetup.kt | 4 + .../jvmTest/kotlin/ch/tutteli/SmokeTest.kt | 65 +++++++ 17 files changed, 703 insertions(+), 86 deletions(-) create mode 100644 samples/multiplatform/.gitattributes create mode 100644 samples/multiplatform/.gitignore create mode 100644 samples/multiplatform/build.gradle create mode 100644 samples/multiplatform/gradle.properties create mode 100644 samples/multiplatform/gradle/wrapper/gradle-wrapper.jar create mode 100644 samples/multiplatform/gradle/wrapper/gradle-wrapper.properties create mode 100755 samples/multiplatform/gradlew create mode 100644 samples/multiplatform/gradlew.bat create mode 100644 samples/multiplatform/settings.gradle create mode 100644 samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt create mode 100644 samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt create mode 100644 samples/multiplatform/src/jsTest/kotlin/testSetup.kt create mode 100644 samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt diff --git a/.github/workflows/java-windows.yml b/.github/workflows/java-windows.yml index 08c5ed83f..775eb07e3 100644 --- a/.github/workflows/java-windows.yml +++ b/.github/workflows/java-windows.yml @@ -24,3 +24,6 @@ jobs: - name: Build sample atrium+junit5 project run: samples\jvm\junit5\gradlew -p samples\jvm\junit5 build + + - name: Build sample atrium+mpp kotlin project + run: samples\multiplatform\gradlew -p samples\multiplatform build diff --git a/.travis.yml b/.travis.yml index bbc60f7a9..5ce60df49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ jobs: script: - samples/jvm/spek/gradlew -p ./samples/jvm/spek build - samples/jvm/junit5/gradlew -p ./samples/jvm/junit5 build + - samples/multiplatform/gradlew -p ./samples/multiplatform/ build before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4b7e1f3d3..5e58a1b50 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue Jan 21 11:00:06 EST 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/samples/jvm/spek/gradlew.bat b/samples/jvm/spek/gradlew.bat index 0f8d5937c..6d57edc70 100644 --- a/samples/jvm/spek/gradlew.bat +++ b/samples/jvm/spek/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/multiplatform/.gitattributes b/samples/multiplatform/.gitattributes new file mode 100644 index 000000000..00a51aff5 --- /dev/null +++ b/samples/multiplatform/.gitattributes @@ -0,0 +1,6 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf + diff --git a/samples/multiplatform/.gitignore b/samples/multiplatform/.gitignore new file mode 100644 index 000000000..2156c08d8 --- /dev/null +++ b/samples/multiplatform/.gitignore @@ -0,0 +1,10 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build + +#ignore .idea stuff +.idea +out +*.iml diff --git a/samples/multiplatform/build.gradle b/samples/multiplatform/build.gradle new file mode 100644 index 000000000..7b4a3fd61 --- /dev/null +++ b/samples/multiplatform/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'org.jetbrains.kotlin.multiplatform' version '1.3.61' +} +repositories { + mavenCentral() +} +group 'com.atrium' +version '0.0.1' + +apply plugin: 'maven-publish' + +kotlin { + jvm() + js { + nodejs { + } + } + sourceSets { + commonTest { + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + implementation('ch.tutteli.atrium:atrium-fluent-en_GB-common:0.9.1') + } + } + jvmTest { + dependencies { + implementation kotlin('test') + implementation kotlin('test-junit') + implementation("org.junit.jupiter:junit-jupiter-api:5.3.1") + implementation("ch.tutteli.atrium:atrium-fluent-en_GB:0.9.1") + } + } + jsTest { + dependencies { + implementation kotlin('test-js') + implementation("ch.tutteli.atrium:atrium-fluent-en_GB-js:0.9.1") + } + } + } +} diff --git a/samples/multiplatform/gradle.properties b/samples/multiplatform/gradle.properties new file mode 100644 index 000000000..a3293d9a8 --- /dev/null +++ b/samples/multiplatform/gradle.properties @@ -0,0 +1,2 @@ +kotlin.code.style=official + diff --git a/samples/multiplatform/gradle/wrapper/gradle-wrapper.jar b/samples/multiplatform/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..cc4fdc293d0e50b0ad9b65c16e7ddd1db2f6025b GIT binary patch literal 58702 zcma&OV~}W3vL#%;<*Hk@ZQHhO+qTVHwr$(CZQFL$+?np4n10i5zVAmKMC6WrGGd+F zD|4@NHj-D$z)bJV;MYNJ&!D%)v-fQ%q0JG$_z5GVUJTPg0MHPf1TvicY#6DXYBBQ4M`$iC~gA;06+%@0HFQPLj-JXogAJ1j+fRqw^4M` zcW^RxAfl%+w9SiS>QwBUTAfuFAjPXc2DHf6*sr+V+jLQj^m@DQgHTPmAb@F z8%GyCfcQkhWWlT31%4$PtV4tV*LI?J#C4orYI~WU(cSR{aEs^ycxY`1>j1po>yDMi zh4W$pMaecV*mCsOsPLxQ#Xc!RXhpXy*p3S2Hl8t}H7x#p5V6G5va4jV;5^S^+>+x&#zzv4!R}wB;)TyU zE_N~}nN>DTG+uZns%_eI=DL1E#<--Sccx30gvMT}^eu`2-u|{qQZ58(rA2aBYE*ZD zm|*12zg*@J$n|tbH%Mp|d|O9W%VT~xG})R=Ld5z<(z%DOO6=MF3Xh-aF%9Hf$?1N9%8Pkev{wun$jZ2 z^i*EhRt8Ve<7`Wyz~iMZDye+XVn}O%qbhV`wHL+%P+n)K&-UMuZw^RRfeQ)%K=k*m zq5l7mf`4K_WkV5B73~MxajljrjGiJqpiV#>0FkyyrB)@HY!;Ln(7JJ*W(>d5#^ubU zVAkTMs*CHzzvUa^nRu0*f-(ek+VZw+@P~}a;;(K=|!9Mhv(~y-mlW);J zb&bB=vySHG`u?j&_6dh^*se*l_B3avjlE|!!Cb0pXyEXRbLy*@WEQ4|)M<`p8Q!rfDJ2RI!u1hPzNjy&)(kcY~GaD6?)7#dCbm`NFh?Y_g$#!+Qrie7%<7P}<-+W@{sxi4JYI{iY zk0(>m$DxOI=~-&eXf2bfh^&(U@o)>(iA1_wJ%B(+nFH+ceib%HEck32QL=J(BNFh`f>St1%llF8chX7#cp*;z}& zcTeXkwsXhf+e;##!FS2yi=2cChcYfzm$wQJ z9%4kAq)wLHf5wfcj!A|xDsAiAOHRzf*)Z-|daN9y5jK-*R{Q0?xaSX-3m|WeuZ`BJ z>eTi@uQ{OGSDIJ#Iu@JPtOy!C?q)g*6SHORg)eAJGh8b-I*X_+xNqZ|OXEsQ-RWte ze`zjjeV9PpE3ac2za+Rs=PA;%QZ>T{x(TRzwWLp_X^2yC-DOEMUy5So!npzL&-@}u z#>uK#&`i&c%J$!bsntEJhY@rF(>6eY;6RoI5Qkn!&<80X5+1(x$T|wR-ad?4N1N^a0)nBj#&EkVvQ?I_+8t*%l#VK&I?uo$ERI1HMu4P2rLMeH%m3 zZ|HA^*O^dA$gb$`Cw;z9?G?m3@nH6TNYJ04Fd-M2wp8@(;vAvJ ztFoni)BLwncQ3@cO*^+6u;(&D<;N;RKb)_NQ_Qu&?@h3MWvo>6FHG%%*smTwj3;dG zQJnT7Wb?4!XmV^>N@ZkA7Jv9kAfD-gCHu2i+!A!}y98SO><8g}t;1JOOxj>#l zM!?y|j5fR3WY2(&_HSGjgMa?Zif<M@d8W z)4>Ptm@zj|xX=bbt$=j}@a_s|xdp6-tRlq6D|xb_;`9oJlkYF1AH%?Pzv$eIAogMi zf(_H*5t({Arfs5XAPj46pjiudQw?dulW-=OUqBVa)OW9E;^R+NDr&LES&m_nmP>Ga zPf)7_&Gn(3v1qu_a^qW9w4#XIEfgiHOQ(LDi=E&(-DcUSfuQE0`ULsRvS}fpS@<)3 z|CbQSi49rU{<4|XU;kiV|C7}Gld$}Yh5YXjg^W$~ovobybuZ^&YwBR^=qP3G=wxhT z?C_5Trbu~95mOoIXUmEOY646_j4ZL)ubCM{qFkl1u*%xs%#18a4!(*b<&edy<8t2w z_zUxWS5fypUp9ue+eswoJSyv*J&=*3;2;q9U?j>n^q?)}c8+}4Ns8oToBJgD;Ug=y zOa0>{VFrLJutjR{PJmm(P9lPzoPi{K!I{l)pGwDy59p-uxHB9I&7zl11lkCu(}*A< zh492AmxsgwEondBpB^{`I*L&Ut40fjM^JS8VdAWQMlwc>_RUM5|Mjes!36DGqW`xs z4tU4`CpOk|vew8!(L}fEvv5&-3#GqZ(#1EZF4ekDQ@y*$tMDEeG?nOUiS-KXG=rAZ zHUDlMo@X&yzo1TdE6b6!s#f{*45V-T3`e2)w5Ra3l>JWf46`v?Y6B&7*1$eS4M(3% z9C~G@N@RXm)8~EXL*9IObA+PwD)`%64fON_8}&pqjrg|2LmP{W^<0@W`9s^*i#F}V;E8~`-}(4@R4kz?t(RjA;y-r%s^=)15%C> zbF;NZET~nybEsmUr8sH^Hgq^xc^n$ZP=GcZ!-X-Go7J4nByj8%?aQ`c{88;p15Kf>|0h+5BLkM&@KI-(flp^npO3MC~W@Uyjv* z6Hu!4#(NtZJ0*;_{8^xcLrC4-zK$BVo7S5V=eg?R8P;BOpK3Xwms+Jt-8R6us zf_rUHFYHn~lu!)U$e$#%UBz7d8YS;mq}xx$T1PIi=4={c-_cY6OVc<=){mOVn>~J$ zW*2PB%*40eE^c+d=PP7J@bqIX_h4u6b6#W|ir<;IlR`#s`Q*_Z8Q?*s_&emuu8D;NSiPX9mK?>$CwcbjhCuv zO&u(0)@}8nZe=Fl*0uMri02oYDjs#g$OHCZ6oTXV2Y0TrZ}+o%{%i)OAJBj2xHC|F5o+`Qmq`$`2EaL=uePwq%k<;6S2n=w%_9vj$8NO|{` zTEg*tK8PU#DnQ#dQ2mMJaaL|HV;BCn?eQ%d0vY@S7Pu@7 zsf5u`T=bL7NfyYO?K^PR_|jap@K|qQ zmO8CK+&O3fzgEnp2|_=^K9ln~QhxjgMM>EQqY@k@@#np@FnZq|C{EyEP7^NurUm0q zW5rKmiy%__KE>YItATyMhE({0%ve10la=mUd<^AcB{T_$Y`2_N-x;F#3xTORXvhPZ7psmqhXy?WxxB5w!m*4&Q;?t$4Kt?m_em-htVDxora24&6~5z$MG(RT{trtp(L( zy&VDT{@p9_DGoq+I|abw$E!TyTO7j6dWQ25dqdKV*z3E?n-p|IG42ZUnNok? zY4K{y{27bUT@#|Zcni!tIgjE`j=-0rl(tVlWEn>5x7BJBkt0iw6j^4n1f2i^6ebo; zt^&Yb##}W0$3xhH&Nz*nANYpO$emARR6-FWX;C?(l7+}<97Ay#!y%BI6^st=LaJ>n zu{ORVJ9%`f*oy85MUf@Fek@T_+ML0-0b$lkEE2y8h%#P^X6+cn)IEXa@T7CQ{fV z-{^wJGN*+T!NsAH@VNM3tWG;%y{pVF2m z2*0+i?o40zSKVq_S18#=0RrJIse+;5cv#a`*`wNs+B%Ln8#e0v^I>7a_33h?lHo14 zg)CbDfGMyH2cj%7C`>|Rrg;U?$&y!z(U10>(dHKQsf9*=z)&@9u@w%y+e@*CnUS|E z*O^cQqM*!sD|e!u(yhXPi$Sl<$daf3sq@Iexafxt3F#2R&=cK z!gT-qto{oVdGUIxC0q`tg)B-Zy(pxGx}&svoA}7p=}jb3jEjQ!v6=afKI!2`&M{#tY$~3LR}#G#U2up2L{} zMGSX>Yjg6-^vWgeX0i;Nb0=gQmYa!|r0rRUshm2+z3AlehjfTqRGnRAmGhHY3`R_@ zPh4GAF@=nkRz;xMO3TPh$)9Iq?Fs5B@~)QIntSyeBy^10!ts?9Z@tK&L6xJd9 zNzaaz6zvrtr&MPQ@UD)njFUtFupwB zv+8%r`c@#asm}cKW^*x0%v_k3faHOnRLt7vzVFlqslue32rt(NNXnkS+fMSM&^u)8 zC`p{on>0pf=1id|vzdTnBLB;v%*ta`o_lzj21u+U-cTRXR%sxE%4k<(bU!orfsJ&v z3FLM2UT_*)BJm1^W;Z{0;z^_e=N&QXSO>rdB`*cp>yGnjHJt$ zcJd~52X&k1b<-`2R{bqLm*E(W{=|-)RTB*i$h4TdV12@beTkR&*iJ==ck*QlFiQ52 zBZ|o_LP06C?Sgs3VJ=oZQU0vK6#}f9gHSs)JB7TU2h~}UVe%unJA!URBgJ# zI~26)lGD4yk~ngKRg;(s4f@PccDZaL{Y=%6UKHl&k|M@Zc4vdx-DX4{belQ);URF? zyxW+|Ziv}%Y!sFdY@YO))Z|f34L(WjN*v#EfZHn6m)X@;TzQ@wIjl4B_TieZY}qY`mG}3VL{w?; z&O>sZ8)YnW+eLuW@rhClOOCZe2YP@4YWKN?P{c~zFUj*U?OayavPUo!r{uqA1<8h! zs0=rKKlwJYk~34F9$q6fQ&jnw_|@cTn{_kA8sUZ#2(Lb@R$NL*u>08yYGx{p6OeX~ zr7!lwGqMSury(v5=1_9%#*MORl2apGf(MQIQTMN35yE3l`^OS7r;SKS6&v-5q}Gw* zNWI*4OKBD&2YbCr8c{ifn~-9w-v+mV49W+k)$jjU@WA+Aok01SA#X$Sspj}*r52!- zNqOS<0%uMUZeSp+*i1TEO$KGKn7EwzW=s?(b5X^@3s5k*80ns2I2|bTHU+bWZ$x;j z`k@>)1G#JgT=F!8awgol?DqK^S4R*g?e}2rOYRVMUKKxSudO(hOLnnL zQqpxPNouLiQFYJs3?7!9f6!-#Pi83{q3-GgOA|{btKup4fYDu-JFOK~Q1c3KD@fdJ z?uABYOkHA^Fc~l0gTAy4geF<-1UqdS=b=UM6Xi30mPhy1-f^aQh9H(jwFl5w*X`Mh z=Ee5C?038GEqSVTd!67bn9*zQg-r8RIH3$$ zf8vWEBbOc`_0U{b)t)Toa~~<7c-K_=G%*iTW^?6mj9{#)@|# zku9R^IDzbzzERz~fpxFrU*it;-Iu&m!CAtM&$)6^2rMyV4 z$+e!$(e)!UY(Sc9n6hkr^n&cvqy8}NfZz+AQc8fU9lNczlP>5D3qzWoR55YvH94^* z-S%SVQ96pK3|Yo`75D&85)xij9Dl8AO8{J*{_yhs-KtsLXUYqwieO(nfrkB@%|OyI>yF+1G?m7>X&djb(HBNNw3KX;Ma*oMV)cV0xzxmIy+5>yz>l_LLH)VyRnYYce zw$?q!hJzX0TlE0+o5QJDM~sPrjVCN7#|32#rUkc>?-eN6Q0RqQTAl~`&isrQg)ass z+x5XapaYh{Dj`+V096?w)w2!Cnmh?x1WmFC$jEFY4;V)XAl3*tBS)V)3TbL)g46_g zCw9pl^!3OCTOcaEP!?==guEAw;VZ}fE6K-;@qD-Rx~td+j(N>)Wv$_mqFTH_wVZNEEuDG!0T`HXLsf+_E=X3lw4`_&d5&YMl%H733ckO){vZm znFLS`;5J#^`5~unet`V#*Y5In3yb|Ax z|A6b^F37!_z$_{6h{7l~<{u7{Fx*A*#zw{GD)6e}n6f<|)&7`S-txiz3Jm4S5hV&8 zm|Ncc{j_~`^pQ*I#w21;(jwi8GnH4efO;R|r4$tH~i;Bcmp^sP9) zjhJne@yzU&XvFNoc~i(wQ?nE`o6Hk~!;x(%xh7?zvigH2g`!v8L-vEN0DvV3?m( zSW(TZ%2AWf`rS}GGMqUj!8yCp#|fR--Vxfj=9}YD97Gocdj=S z0zkF-jsO>EcPTB1zRO$++k^bH%O`=UkHdHT^5?{$)ot<-K2XIE7js*4OjF)BsVjCJ z*KN)!FdM*sh=fB$p8*EzZmGJp?B_=a-90$FI{S$LLjBU$(lxUj;9 zIBszmA*129W+YE;Yy{J~3uyOr<2A(`*cu0IJN#tmUfz2jIWQi_h)_-V6o+5CjbX!1$lz6?QYU za&|O#F%~hmGUhil{M+J|*0<3&{a1%ONp-^!Qx*LOTYY}L!r9BbTxCjHMuUR0E(uH` z!b$*ZMdnB{b2vsb<&P6})+%O=%a8@~$fjbtfF@Z>^Q@enTOJ%VT)Rdc!wX|@iq9i}HaFZAeY6g8xGZY7h-r1sy_<#YU6}I?L zwvf0ePE5PKbK>2RiJOFO5xNhMY+kt`Qi?Oxo&@xH$<^Q;Nb(&rjPBAcv;XtmSY90z z;oIFFl%lDq$o&kYQ;aSHZHD@W({Y1hw<-I>7f_X8wc?%hNDlo~Ig;63RlHNhw~#R3 zA*f5D_Qo`4_ajY4Gr{mLs*(Fxh(U%oua_u3r%`H!TI)@R!!iqV8IOhIOzI@=7QJ=G zV$(9mEVL(7DvPn0j%_cOZN|vvNg8*PHma`6+oS;PDz%iOFyo0n0e%$<#A3r~$=I0T zDL*{AREUGx&C2}?I9cVL`UcPyawTqA4j-4%Mr-4`9#8GX1jiJkKGpHVr1~Rj#zFaZ zqmE!<|1JCi!LDG?1^Ys62xz(p;Uu!QZB7!C0#piy1_9=e?^s@-sd1gs!h$;Q`TNtf z3N4Elsgl#={#U`~&}FNvH78MLjjavl1x*4pNVr338>%sfHu>bxo2#eZN2ee9q#*Jg zDk_=OBR;8t6=pBN0aj)&Nj}pzqqUYW(tfk?bXTdKbNQFSUMCyN-!b0#3?Z;ijzx$M z^Eo6Eq*NO!Y8K;84H4MHj_xwBYc|3>+D(PFj7ejhECG@5@Pk&8dG<)HwwO2~j7KV6 z0$s}=*D;ek#8$a*sxVlC_`qFkM0%BQQ@v2H&Aq@G9XCQt^^x<8w*=MbZV)@aPrrn; z`6r*&f`x&1lp)`5>-|-4%l&W4jy~LydfN;iq?Y8Xx>Sh#2Lx@FXo|5{WKp@y-x;)7 zl;;_Y*-Nu3pcH-)p0(tP~3xO_u~>HpCdEfgyq7V-!ZZ{?`6v_b-vx< zuu|gm5mG6c@D{FYMLuzvG+A2T&6&`n>XM%s`+Qtj)5XdpyFOnz3KLSCOxaCEUl()M z3b~FYqA3FT1#SY{p36h%M^gBQpB2QzEdtM9hMBMRMu{|rf}(;S85&|A!|Aj}?fMKaju!y>_AS}#hRe_!&%8V=6+oPPtE zOOJ-Rcrf>hNq@lG{{@$H?6ikt@!A2OePLe{MBIWSPz7{u(I} z$PXzD;leHG?Xl0FnWt+Wrkrk*|e3P~YVF@N$y&L929cc=#-!*k)HZKDo8!#+t|?9p0z1KSDKclB&M6~hN5<9~^DIltXKR$+iK*h9k$|@Qoy9H}PSI;b(v>w`8(k70@sfa4nRweeiwZ-syP3zPSsyK_8Te9*(FQdm+ z84ZDah4PGehH72w=Q8bx;pK5juT67rJKb|ovD#COI^l6z0eBidn$!Y?T2;5sN+vTV z$`%Edb<%-Oq@NPZy<2Z3m;$}!9JzIuVK6;fJi>>m3q!Lr!2xXRq+l0LvZIR_PNYrP57E#sCvD^4UU2GVr*Rx`QcT}yQanF z3i~!-2Vkk4S%4Hd2baDvrM2g(&1jZaA1!vLi!I#5wX6g^&PE`0-TovM(%wuaPXAno z`a&j{ai=TsgKpc1C3|)tY#!4>SPBbMnchi}glCBwaNE(4`gi}JY0;`|m`s{HtaP@& zHxwCt#2&z9A7O+=v>za}LW~}G>_tWo$dsRX)f1L=+tZF5E&RBA#jUC|N9ZPa_&z5= zekCOsIfOh`p(&S8dnkE~9#(;BAh8qzi5JYT0nP7x&Hga3v`XFdRN|$5Ry#mq*AN$J zV)l~LSq}2d{EJ@%{TLnkRVn*sdM{_b|4!x73|Ux9{%S;FPyhfZ{xg;P2ZmMuA*cMG zipYNeI7{u98`22!_phwRk|lyX#49r%Lq1aZAabxs6MP79J3Kxh0z1E>MzLS6Ee5u+ z@od~O#6yMa;R}eI*a|ZB$ar0BT`%X4+kyxqW4s+D3rV176EAsfS**6-swZ9OIPRZ& zlmIH>ppe;l28`Kd0z(alw^r<%RlDpI6hv)6Gs?GIpffKApgx^)2-6jAzjZE0BtPBC z0z8!#C5AP${zTF$-Z^v%^ie8LI*rvR+*xc=>fa;`SRUSLAio?qL;jVFV1Bw4K>D+i zyEQ}vyG2HTx>W?Ul&MhxUXK7n;yfN)QS`foM!4>4-(PGwxW!^^UyKOz(v+1BejI*& zQSkV|m5=JF4T0k*+|h|3dx`ZKBVX7H4{5iakAxnD#J=9igW@LS;HE_8$lZy1l|$wX zn<8-$u=7&li+^MB(1y~Mz7lj7?oYf%1k{wT#?(Mep094qqnPv7*OYkQ#7$pkU5U24 zzPLEwAb<VIp_uUE~+r5)jt(>>Bg48_{)twH$QJDSBrUS!j{lX z)SK$6dfLWt)c9%Cml+sRp*OHXB?e4hbYZQo!@=6 zBPTpi&6&atD*#Cn6f@5<>79Mq7o0^E!NH)bD26g}?@qg%*AYeE6Tec@F?y9Q8i}^s zz`)l`8>;h75!kL!`&*_hsX1%2)(lWr|7!}@gn%MfwY8vN0=pMm3WesCRv5e*5m4z|u(zbYCpuxO9$bY)hkL|}mRj{3dlRgNK)#PJp#vR=ka^TZ(tKVI<>M~ekIfd2 zm3UDUNW*ZvS5L|SF334|YD>LJk(EqgPpVxtzwclUNaH70zWDVt^1+cz|F?RdF4HHn z@4~Gs`lj!0dWi2n#>7C@B$Qf7|t{1!3mtrO1H7 zi{=I#^Oa1jJiFI!j>PualW+ncHJ)TelW$bv2MqUG1xK7R z%TsQfTn)7D3}XYU+{?Hq!I&fqi4>DmryMiO?!aN!T4fnwq2vsuB^s6fPW@u*h-JwG zNniJFR(RI*?5HV=tqO)lv}CRv_eNEBR%z}Vnftv0+DUH^OCODH#&;{+aw^1vR z-c~|Mk+o?j-^Z+rR4s z-gNA5guTuab7N`{Y@eT&)!xF8#AeetvQ6d!W4BlO;0#0TxS_( zMm-A-u+h7-PjmOQHlh{Hxn+J$jh?uEtc8RG8tu->og@ z86A%eUt+P8E3oLXIrq#K(nCF@L12>=DVT3ec6Vn=B^B;>D=O%op+0BT;T)FHZ`I93 z^5|bpJC_kB92`alM40Am>Yz5o1gxkIGRYQ)x^+R|TCK)r;Qyq6+~S9Uy9nr^nkvc- zxw~#_9eBBJcZNK0yFZxUK4h>u$8;4k-KpNTblRgS(y&u~u&J;O!aqAMYJp+(BED*d z^I#F7vPOEADj}Pziprs=a{%qgz#eso$j`At7pN~bDw%&ba-+4pI}T*?w-z^_~DfD~Z3Tg+#M#u{s&uRF^dr5RFZh7<|WNEG;P z-_SzXTbHc^yD$r;WJqqJkA7^(zN`nzQ5V16nG~Zobuy)a)(T@Ik>V!qOfw;e z)?AZXjzDJg%BkIEY&bm&BczLuWY~k}3Zyx#)jxg1A9R`sz!_dCb!|13b*3PiA@(E6 z9HmG2R>-YrW93UMQO}XE4loI(*er9J*wDUd1se!pzdpoB_v6^lQl}+!6e5MS`+bU#_b*a5Pkt;o+lOV4loyn2P z$3;z-cX>$R{6M4q%b}aMBF}6N+0RCE70bB;XwHV~JLO&!EB)Cgo9ta_>>Os1HNfaY z4PNu7BGhw`6}cm>glh6i^)Ja{rpLHix?C?u;(e&GI{?!E7$9hd*5c^iL?;6Kwn z@qbBE|3UMF|F$Ok>7YY?CeMzMes@CZJQ?&|R8v5M@XvW}jjxhjl`gzl;rvy6Nn9$K z;1TKGpUgZs`vR!t-sD~2ar{58-;2k`H(MIWr_cujtSCpjue(R z(a7R{q`G+;8qD8D1e?1zWv+pPFtk=k#>f`yqZo)3KwCBgABgQbq%hu4q}h+Bdyh?* z#Rlr*$38^Ru%m9FUTQL2Xy^j|f%*4H*{zWFRsMbs6@u{JM{48fq;F;QFV%6Dn!6X0 zEAr2G{RmY8;Jlmws#%7Hl_TvQMbLnN0KGK=9)1u=Vb&#V27UwM#U+)$hn#hlXxBxO zM~<3s(W;fe-0%mVWtZ)oN|h-01@5z=u(z!V>)I9-IepH|_q6NR_DA>2hxGKt-QX;H6(^FXwcBndi1s%qn2sH-rsuON7*ARP6Qt$2XIy3d#cn8sLh&7#USTFn3 zQm-o6-Bnofon2V;oq-v1@Ye@NuH$Z~+th}Cs>F7=H#=4PKLp%-!EwR&0`a}XL=br< zF>&?HNr}9ahB-EA7a({^_6`taBwmB~hJG)p>8r^vq0J_+o`sOq<{s2~2t}W&1f5`l zj;E0nmt?YRp{ONhti9{4&rvt5uoS0CO@%+Yv>+}ROQAGP3VLu^S4fe{ZRoGviEXMF zhM=I=Eg2~^5PIwEq{~Wt?inz13!axZU3knx_)Ey9<)z<=!TnCPHvs1l^spF`@INYQ zY|J1RWri-^D9mVY5Z{u+bXg#}3rUwSXX>&@PN+017W@!L5H8CvZf0wZxQ=UrHJ{Um z$Z;~3t6ARGql*O1^YY(h4awy!h_brE6&k9B&5l;ya>jDyW5?o$q~=1iV!t7#8&QOx6P zhQIm55sij*Ef-G_?k^$AjK2j?=QQ?^=r{MDaGZ7`Yo*Kp1uoZ=&5|O)D#xAHL)n9_l6-E!b zVV@8ny;`XU#X2((4cTmv5unmYzUmJ>Hm+Kvht&a+j3nr!sljTHUZn^0w@L|WKw2TO zRO>T!>jutIzNI5U_KL}vd00oi6$aJqPeJwq)lIr(2Gt#52i@sqCFaWC)pS$pYoRCK zd*$)r6FCClYp+n>gCqVF>x)ghAbl+h${~Mc_sQGk@+sR@b(88l zcx?*Usr}v|kV!RPfS%HK>Bn{7tdEV$CB5Z@=uy4>^(o(%@R|_7dq69s1(X_8szPZ! zSS~$LCX>-}F=io=YcY~9!vqo3&dh9_Mosio`zO6i|$&p;-9%+~sdYNrVE?Q8rS+eHx z4O$l|b3FUT#2jb(WU<`oKAjGQUsoCgE1(c>3byBNPhKeJ7f4S-hBRqRyePY)im;>H z)hyFuFTDqx*ZgXo$hn+u>TGs~=Bjqr3bhPmXG)v8){EU;N*58NKU5;EIZl z9%|JomX+b6M#jS2`B%~!+`EStMD{|y^P=`xPbD$o6;|!((h!+y%7Y{DuC!NCKDIN1 zER-J?vZ$2el4y~!-0vWjNRoC|ARB`IX@M&;?ZpULcAIu`zlH9 z&JK#H);Ij~fqoT{59}OI#ViA%!lPYyd@kHg*hyI;iMdCtw2&eLHOd1*N%2Y!BG*H_ zu@E?VbtZlI{7B{C>A^b3njh=KdF!=rQ!)oIjwkP{t^I{2q&emQ-C1&U&fPC_viACTbT;(A3qRJeGINz^!0N26vQ~o|#pmjp-Zq46%+{X9n zLGKqhLh4`-(*oDHqHU~-45_+pe(BICF$*0jD&FW?ED=vn=t?p9X(%AH9+;6NcJ8JF zASkf}LfT7Z3u*#i$ml`gKIS>3jrTla--x##EDM{w{>Iu9qV!x95ECU*W_O`q>hcCa zswU!;H3R{}(A6aQ(B)lImTF$BzF;$V_?It*+8ZeiZa|b8n_DN4jUfI0jIA6Q6*c0f(uq~DxrNm!$~G=Uz=qP*)?qc(}|7MQZT&B=Um zr{Lj_R7QJAlwD=CoYpjQsUyu1)C9p5CE)%3nb)~WtP;@6(qGG`*qDT zS(zM>&R<;Z23V|80%3s!`0QpTt0Ay;*xLJeE|DP5@x?a!1)`g= z-1}G_LxiiO(*?R*{(yH#&yl|Seyx6*+ETayQtv7Htk3WPvI;U!@h-e$)gw9>pyKmB zk8#$3BF-ou%=`9_3)Q`0ttk$cymvULFS`Khmjes=2(-QY@eVjJ)rSD)z)1No&o+dz zrGItPZ$QuD;Nqt~U{J?9VlM0g{kx!4$?!?=o?um>#7tjMzrLfv<@pI&cp*5H>XPPZ zu8Xh&6y7v0pGDiQqd-~tBjK%-SO8$8kG&44|{09|FO5BoNkV6~JX>g{b#NHJW?gmM# zhbcS|M9fDc44(seG%$hK#va#4YL98mddGDi2qr;@CeiWO!!`DrF<%=_^*3JgoZiSj zdEv30G5`7ex`XP4#6cG;AQ}(|>CcCTGiom^pc*j-Mz1_oGp4iP*>N125YeWCw#L4H z*>u2Ih8jVRJ?rOj-7KbU7KXpYs2UZf)Vf}(lsM(oiB>tgqX2tILJitw_x z&7gq;`b}qrL{lEA3DaXDOi~HQ!^?xxjjVW|#Z+Ek&GKA2dYgO@zB2V*eY zx>@D06X)(FUz3xz99V3v*k7x|wxiFxv>=N$1Chfp>CErJq)gnf=P!u-QKrYnulzdQ zP56u!AH2^QVnuxTJjcQtlflq>PSm4C!$^fv4V_XsIO2d=O8|J`4bUDtjBchJ!14~3 z#mgUPYF*Z?k;Y)Igdx3yQg8L)M=c%}p3!P-0KOuXI+{*LXJ&w)$gzxeTyr`)h-Nc! z`$xa<>T2pbuU0VR?#FPEM44XDRw+cM6U1R2aLQpGHX40=4Er=lp&2aN#P1IA3|r+L z?5jaRyCgN)b(KuS+(x9rPLLjY&4^YY{0T2Ai%`f0p}sG*R!}{DSf7GdPJ=C2MT1ND zUJ@#y06`CNc9n?13R2KY1K*SYeV87wG%bjcIbn+AR8*FS<{?wWomTT5@`}~z3bFAJ zLR-wmE$iwwJ-TnVEhl{{?+??DJ?DWk~VaX-L3-RLtprT2%z-GfD{UVBR~T}zymA0 z6VZ;1Qr%5q#+Oz#3)`D(%WVWWS4BW6%ZvAtt!u25FO@e{X`)_LH>p&pFzx(wvNEO- z!2$Z}`iynmY2j&UCmRNB)9Cn3MXRls&PFVHzkzr;)B^BCMY~6lYY>0rsKT zm4}RV`Q7tbn)Aseay%@-I6ZT~PBsO?D|>kG*%(PGo=|gZ#0zsmE})xxtAvaCe&$1? z(7GyH&^jm!cguuMo@CPA&-lrdE&Aq8GIOuUK9jt{K0ldcvJJp7I`ZMx-EYj$)hl~) zFM!U~HxgO+lb$1cIK-nvz<5OPs(@d4tB6DUa3?-bJ98|dv-kIdtMS;9BuLc{a~_wW zO$u`rNymsAeMH9zh(|w=<*V z&&B{&O0Am`<$iBa)>pNZ6cO`d^3B5%=gmsH(HYZw6!U(c@}#)19F}`BT+yOfamJY$ zYOmy2m^k+ADH2klhAJMLq;6>t3)NREUgk*cjJHg{NBkVhDORNK;v5362&NN=y*Ef- z$vxYTG5Ga{SI&C93^Gsu9G-osqbC9PbsC&@xxGlF?o{!rs9|YpEE?P8ix#yS`7JUy z%ez(_Q%I^RwPrW%rFF(+mE}rp#Wtg@^>O7T(@LFA7j{LNrL=XGDyB-|3<*mqLL_UA zUZz?ulF$5O59-WWZ!d@hRxC@4d6?okW%`1$#<5w9eh>4Cyr#xe5%VPG@TBe#HA^O} z1&q{T_TMTr($f<()ah%TXapiGp}`MAC7>0I=Cx*t+bXy+gMyk*#(A~ft=&4YBdQki zQ}I=c;etc@sD4?l`eYaksPtJnx5OUaZ6u;7p64DUuI`omrWjht5$8+cqb6Hw75WNX z@D(fl7tDl2H)H%QYyX3>cL0*DZPv8+ZgaP7+t_W}wr$(CZQHhO+qUig`^@>y%s1~j z6Y)pXii(P=SQS<4iS=aOnR(rqe#b*BR~GN+bMNQSnhcMHxhVf6D7_zYs}@oo$eK9sZig1_lH0|C z&<1W;8dh6lutS+|02t0VqRfh9R+%!~9YsQ>cw-uGi!YMSo?19?Sty(u{GRqmTx8Zv zLz|nph}CNn+4a~dDzMog(j+NForDvDjLwub!b;p@dLHSBO0kjaI0CPZ)8B2(HNL&A zdr8Pw@u(POF1J*groJ~!1|E(GmnR3L6`P*3C;v?R zDw-pBC=u%}<}P_);mn-_cE}am&b1_WlqnWVzFS;*NhwoOb%+#0nI|H*Bw6_0R(=Kj z;7@eEqYkW2OvWkoz|yY1gZAJw8=>KShthS*ANzYdDT61^AK)>0H%LV4q3}hw?bkA$ zF$tz;<5T59v0Zd$)unmJ{vu_7eGDP6+pe(H&n^3E)g^rB?pn?GT9l1gztAUpR*+Kvt=FE~M zq5rZM&9v>ww1mzrK)vx*0;;?tnqA@Q;FBC@$2~=gy#jW$bAJUNIl_YpT)``*9nnkV zF!&XBK8(PeQfnScH*JaYqy{1bN4MwF=&g2)`!Kuo165*d^1Sc_d{I4>6V=>74c%g4 zXE_M`b@syq%jQx9VRp@ba!rY|MRhr!S3bN!1RT}^I(2gXE`KT57Y;maGA&dHM#`4* zy%@6YB0A6Z^?fg!$4Gq0auM47(jE$Y4osH zhydBwQ-S~vMS7)hg;AC=MRf~AHZu|Ue*bk=ff`!Ol1%=|W-a+~l)QH04q^oeMZHj~ z8$8jQn(n1#O!_7sg1hi;{v%?nd&gK7tfN3I{A0j zcg`ISk^Ir4G=(SvV$v}DE(nE+%rgFkT%cu5VR0Qa^H4-xPC*7Y*+E8#xvyepS#xYE+FyIIi0|5$J%mKAB58%MgleT%Zx42e^L`TdA~Ips z=NvgHNpYZju?*J>oNcmd^(nFUc+-bu4*+9)qIwU^g?1_4-&-`uZm&f7F^1?@3IvJc{gnlh?no$E9jFIfJ8i+33;o-!b2hD@}}{o}J4{l{44v z3Cd{3Lj%9^E43SBXmIvwsA2_8sXgRu=4=H{j9R(fYcCzOXriTZ51l+HcXr@)^?rK* zmc89=w8MW+txdobBh`X4rMvY#vuv0GIEO67sgL}mIw$pNW6s8Fd=t z@58{pFs^Oz&g}CPr8EL~QyUjk&}1qyO4;-6m0MRd4J9T2r5_j+YdeKP%Q+jnWNdV| zUJLU&d%m|g&3B83R^8K^WM{0at+=9UdVAzTnL+CqdcT#($38|-fQ|BJbHY4vk=ANj zvX?ek_oYp6t8bQz-T){|-5OGrv`IGd?>X*h(s{MvQ{j>fZbx<^-)&(j8(N+z^sftB z;V$0+Wd0oUR^&)Q+2bHfLt#V~jZT$UPUbkd#vD#zZJ&huG+-;T%sU~ONA?a`Va|T%I0yd%0*Xr3>p#slVg7Y<6o&Bx856S zg;7Q>mCFF?xq_m}VG5`(0fIX(V=yvQ;xjpwNhrLFMui8xdBw2aFOvI3t6-NG3%+d= z>1un%A{1+tFrn2nu2%`-hiqYhXDga3%{ZVkC@ROtTcA;g*E@K4i_G1&^P#Pl_9*m& zwBVKqZhrf4bhw@M)78cm zBMB!;A)H{6h6AjEv&|DGxYRmY|e_ARf_dMIvm*-i4hR#IU_#A_QYP@L|sHs zo@Ky_Bx6e2??_k;7vjibD#pM*T7`h9V&s(moOn_x^N|9{gkOtFY~gDqSo+7meUjBR zK2jiOsA%PwD|1*KC^m(-WZ5j2AWi;81kCi5t)KouHKt|R6m{m!!n|4YN3yyBo0mSZ zN^yj9>I9Y6dI&$!T7&$%3Ccxua0-&DoNJFbCV%1;h^-U&1Q+@47qrKld+QNGOrh{a z27PfD|L06XuL1+ZMc{_7rB7bd&WD%*lbypj>|K|<#2#t+qPXH zTm`5QC)ktLW5+G&4lhvX8DgOK)|mvQ_b^HuJ&=wP%Z6%;E+Bx|#|Q}vOoGR(jK}sD zk9x4A-V%Hs#G>J5XldT-W&|Kv(!mEi;J38jdK>L|Q7~<_no&|~Fdc~yhC~%VqQc2e z2|pva(YaxgaE`xa5=u=WkhtI|f`XRHhA6|>1`)hDgYzt9kByS$l*OQ2O-a#Iq%SLz zV^&-mn{^KrM6&BueyiV}>&)9rr)de2+DkV8##PSmko(<`nqPVr^n_V~UoIi`_yVdB zzcj4`b5QijKNrR%0AYi<`{NDb!y1^#Pv|K2N8<&wlO7-JDa5Yp?eM)pf>PbMq@)Wr zvki0Y1yLr2WfDb`RBPgq^VC(KH;ofR#9^i$TaMi9J6p5TP5F8<&ofnvL|`*(;urRO z?0k?7WiOd&^v);ux~R9Hznc3moOxE+O$lYV0Ku|hENFV~?Lt!QZlMNp1%d#^Rv!pC zfq`*V)n<`Io8N2XGBOjLYB}#{g#>o-?Hmb6$VyvSN@nI?3{y-pdNvcYe%&%CIeh?s zWfdM@$o~R)P|M>ElHW0BAMI=ozdH-Fle#Dvq-bpmPg-!rDY|1*o|1dvDh9{`{gt%n zFemDyrWMrywXJ+rV5r%UR~0T*75`i&rM4=%7}ulJyHu{rZw;C$r+nn@cLyLgh0d-A z(3SS5tW>ZK0in8bOH$vW>HIcipgUXYGUq49#>Ixff27cCfWz$0vR4Dmq}CBw<~4Sh zDe9adM$vVItE_)3FJT5Bgk}V=1g+Qvf5+hpxwh78gHe$<|r1^Nh?B&_~xSq+nVdY+~dc4GJ?e5EpV zXs-H~6poV`Kh5kok2qSUMD?0&WXKs7T0?Z-J8zti^WD-*_fo zhAqM(p+l2*(|b>aZC+?aK~^_VCZkP0>}TxdEC-KcmAx*YS?wTK?cW>PjS+NxM==Wg zg}e_*NcH%2(J=+WVL+;P)kz0c@48^4ZuemowCO=rriJFSD|#7D2oO{}$kCbL0#0%2 zQe&D2wwJ3%d|+L`bE=&9k_~(BOe$ZFap$YMGL$&$D0=mJ9n%He#RRlC3f=|WyrI0L zA_qS=kzzw8f_QiJYg_b?xA6UgBS0tT_Y$!9>(J-Q|m=O+8+wIPlb5i=-aU~kBf=4dD zd6Q8*EoKqRCcMNO5q%nez-osz1XT6PZ+r7r7A_{!vpDIfE$$yCUU66H>HOUO>u7aE zs*>|KS24COy<^3O^xXssCI`2iF%;A&7{j1UDk9dvv< zsUbj2HMoFr%{j!bRrmyt%jM|4UKza#}%Vf*_fEvi$*6J-h}oRdsdinr_W1-)p24zB*p9tfDdUa27+yi5W`#8+~eE_NyvNZgCP48jF8P; zgYS#IP!@sLe^SeCy4jwre}sC*A4Vk3|EzFISR4QEai+j{bL%-B#Nlt4WJN3eh+Uo) zVtaBF&A%PtbaaH`A~$h0I(5#|WARn>4Hbxy+Jn-$LdJWL+&({?oGdxCC?@gw`D44O zZ)fV$Yi@4u-zGU|!cfh6Eq?2C3Nn%TL2ZoA1+5g5O#q6$QGS|1C!;H{)PU?dDlSGU zLGKxOa;zm!C-Zghet4U7l(%LaEQnKF+>ECNt@`F07q-JO?%%X~*k}Yndc#f*iq0`hgW#iOvymYI0Ur}T;8qZ+%f1paM#v7e! zUS~+CMQqEbYZ%Ix+4iKAGa>>DLya7d_5zQo_zm&bP6F_75Qk^L7A%?p74r#_+3V6R z@m)%h$SZlQi)PpLLYyya^FulLkrPuM%+!YnWBCX|f#M*ph-`6S5IH3F;Os;ZZ&cDq z<~WF?be7SQre3OHq63A%t27ee4>e--Q*N)lFkAI_P@Yoq?Bd0s)IIqLY)xtXU`k>x zfQK0;b2n0v{oPhQju4$`uD>)Syw=X_l}YEfVF8)awhULL-sJNdq;z8~(wyAEW&sDx zxqHk8ufaTXHNnIUP~eE&k>D!g#IVt73wHY+ugJwtuy74u* z1qC32jRV4EWbz*0B5d5qGm7FB;V0Z>C63g4n6hW?!BfHU=hqZbuGx&ccdij#|lWok>4#{m^Fy>{`JdOS zjIM(Tuf4sYrJltP%2vW!U)Mt5hd5_vs^{onYW=T{?nF6taSUF>uPLMY@>8Y#vd&fU zJg$MqI>EOkIj}Gpu%?+k{%zvX7zqvMeuMm%YD6eLoHxL?e6eW>J~|~Z&lHB^r_Ag0 z{*SlMeG(r}i;4UY6e1TDhAnY@tyh=*e7>7?vlwq>&py69o*=hIE389P!iE)Fe1v;HN5fVGS&&jBzQk*Q}Rb%{FF5H zt;vL@*J)TU^_AGy%>+&9)+R@9XQHe9%Cr#w>Q$NM0~WAiktZl>9`I-Ypc0UjVU1rn z_FPNg@88w2iz;NHBJ8)vM$%1oe7QzSs;NxSieG5h->Cq6`M#YqU;tx=1hYym@h%fi zzWLOcEgsbZ>jW|mkR)qpxv-Z}J6iTzy?L3sZiv!nbZ3a;A~Hu3j6-^%FcrouBW^*9 zwOO;eD$2J8edza=ZDF&}5X#=B9O(;A4zyM&5yTvxuoqjP+FZY!ZYI`_D=;czTJF-e z1-$=(BE%9~*+c%p5UT&+n27&>tc8D77L`o(F_e)w^~KRuv4^AdNE-D~2I(p(SCPRP zc{V^gm}JdYd(~~{max0nhdPp5j3){eJ z$LuzR9V>9)451K&?27Aps3vsd_bU(1EDOA~g;@vOO2Ty`4MFO9u=`!_wEKPQp>9L& zzuUbCBGHhsuxYBy-^Uw`)=n5pSF5)!a6qfH$^u&=0GA(}B-Ixjj|ce?Bp(~$q^7BqWU|H8 zKU!?5P@+8*_63=^7)|h<=`vW)2%PZF(`Q0Lr0x5QLjWKIQZB9)OOB_ISy!Mx`E{lJ z1=1d&Ic*{{_h#6sNH^Hz)~vB7gCTbuUkVrOm(pCye57-0NUsKiFMeA#@NBB+F5<+s{(H7mQAPQx`OR z8xRz&uf&f&-?8paW&Q%EHCq$Lv~}lCIW%s>Wxj&$Majn9D~*{Yn8jBZ3b9-fuz!82Hn?&ZI2_JZYAy$kb_?7m*?J z7EcrbL2*)gJ(Wl`yg~c)vC1w>dR$LezB90-T0%EZo|KuQOirNpKJAd) zr+w2F#9m@j64vevMEx_$M}ESx!oajKsI7|Q#c-fWRsS7nAgMlxf$l`eoBx6_u1LP` z5wVEEAYNPN*iXKJza7=aP+z_r$z;5})SQGWl0SrU7qL5T>MpzjZPVq~an6pv29s{gIn1Rh z$*Vp>0p=05JN|HRiyOCbpgpZ@;9Xj|o3DNV!%Xn6t3hE>(=2$dFuEx{osGXYv`m73 z@j>86*-gsSS^3mR)HB6Bj1fy+E{@9e{bcRLU_iAqDzdQUqG)+sqNE`h1 z$3w4loJ+!{F4NdK!E7Vu6L}j5d=VnffP!j5b(b5(u}{;?o9PB`YLsrEsOeE8IUM8F zj!}~kYF^$l^i7CS$AnS+a4#EnWySE!?hNnzWe>=ETyc4WCXpNzZ9R&vLWR9n2)aFS zeT`FE>ZzLpjPr*qdk%A3<`U8cpr3K~?abpqM})l-j}Hz+9tJcw;_-BzCtzpYoNVk^ zd4xI@9~_|+Y_6S*Kx+?A$c)OqC718Wiat0Sl%qFMhix0?j{gw1XO9$zQhjjoeDj|S z8hS*$R7Ol=9=Sd-9s*OgZAC1sMC*(iexn}3CMYJdNZu8^S5)5@Bxo7ayS4fG2D@ns z(Y9t_4DB(20CAx~=eL=RM?RRc4|4V{?Qe z=>g3K7H^2nxwHm|*N+zhk9ET-=0ak5wZAxM<)DFY7|^q+@a_=>AXMj@vZG11mH%nQ zn9XfRt7)!V&u0~v+`DaED;5~WX_cQ6~@iQ$)`#bKdk&+uvYtZMGQ??&zRmpw zbc5donS&q;jPQE_7rh5{ONJKBM;cxKH>r!f)K=VDf}bfc1B4Nv3C}__D{B|kU4Q04E((6!W^q+&Xb=m`c#S!$wEEp4py_0 zDJO?v%A16hzF;#-Lt+DUyec?VXUS?%21=wBiJ<}TTQMa&n$+5wnHr4sni_Hb`tFO; z((Kg?Xh0p)JZnUc=-mE(Ls`z5)+Qr8;F0R92sj9yEJx1kK&wQ8S2S`)h+Qk?^jShBw0n z^g^Pht7xCZvs&|5W95{bypf4acXhX`O_>*QyEk183j48^Ws>JcasVrhs5G9;&2dyi z%>jCf;J1W^x5i(=Cvt|^PAWSdNG}XTJ@;UD+R!_#xn5!VD8@`C$I>Ipes@q*x>0`l z)z8=i*VF~+bxTYjaCr)lzaDau^|9V&q!IlGwQu0TKbn4oBljDL$D`d(xUR1D_M2H5 z_D)E{)YMOgPe9j&Ta=X`w!K8L8Fz1tOon!uWan9)huounS4Mh4dF)BRXPW~rZ){=b z8GKrX8h<5U_7;gkNu2?Vha=mHR?g_-tDJ7e(~;kBqw^DncZb0-heR1$Eu84i7(X`&aR*AQIwovW z>fz)N@L0uBeI%!;>fF*(y?aB?LspSl*h;#V3|hH@lSBCC>z%=##r4vBD?~% zIcaMD#Ep&MMR|QloYSVm4m`6&D~o=K)KUR!2dn`e7}AFYi4ni=M| zwlXp`cKoTc{O?pVGTu@effshzIQL;~Uran3$O8b$6lS*o0sT!BoyZd(zz&P7axA%@Nz)_qI zkD$LWxQoOtM=CJA^aux0eMxT|$TTV{XcUf%R6YWWWpb~~Wr+7tk~!$o(-O!M!{#H? z)jCw2taNz0WO)=*Gud3!7Hi9?DqB;9JQ_pLDASj_PC!c^M|om%q>Zz+S3oK5Y^V&l+!?6vHO@6@c? z%)vqVE`pRD|ItbFC1kt4ApdNC)&9im8NW=RUr>

@up^y4&I8N>~wvL%f(S2W%NN zf&x46sN${5Gh+I9cd>g-O|x3@x#@hdvU54zx*WtnC#5%quWk43w{;_G!4&;N;wy-O z?urjbDnKfp2u4gknf&*wBJS`YfdzBa#pf^Lo9ei}Z)MCk6MP}h0OYrd8`jVipqsRTq}lh>h#|o4yiA zbPQLKXatZ+L=I$?XEGfd7x*_lf|=3xKLi)yj}jQ9pD+OPrv;Mqe+~uywe$sD4D}uV z4@_J6*&E>)?K_L=^f9)ZpbIb0tyI>qF^OuZ;8LrA_T9JRowWUXNjyBVFxj7 zcFv)I!ZI!9%3&ro1=#}qZ!W@`!*%Do@xlC)>lS-KJPYY3@3mXj^ZUgyXXo8DiZ)0M z@ORv8NQ5xIiv%yy7WuvM3l7ZnaX8M-u4s`LZ2-*e2V%BIin4U@4b=3ps|#~L^v#DXv3GDk8H#;lK%qAV<%I5Z8dd3-sIMfqq2WY52;$Y7| zC@8Z_G%EJ3tOhCq_Ad3l4=IN9=Ee$7k#R%^@JPd7SnqL~*a3EWdfPj^Ft)B}bgnkr zBT1I)!g2ha@JU#wQW1op@1SkuaGVJcEJVhstebVvoHV+n`EI?;^p~M~tfk#K1CBi- zF<+3FQvDXkoVE)E6Bj9T)Vlo9rjgCj>S}EH&DnJgn49L@7ZaI=v&F?OY*>NLOQ-u43cR-0P{LGZCyKsW{^hNC8iDiqJ{~) zNqU!S?7Gb=jXSc_T>xTosLbq!#)VKVs^hKlReb|!_v(O0B(=A8tA0Fic+K)>Lc!(J zge-eb*cuWjJCE_q)D}kLQ`X73XAD=didg`EDAk|uw*rjJ1Yj*bj<;`v&pOnps=(g<^CaeJRd*q!NQ`O zTAcA*KCphxtD>M<0l)OpWo@|W=Vs)XFpM7C;96VQR+W3~AXoqC9@yN@7J9kuboR-H zHL8|U?V*D#Jg&`hR95a1#ByH}mfw|kcIP#b2%C}r_nxhIoWdo%k*DB;N)%#~P458H zR&1-?mh?}HxGi(-dh@nkK_H45IB{y)%qwup^p85vZeUpqh|G;9wr%q$_*4*|PS(bw z3$<2M;y;*(WAtHSM--PRyA1<)1Xe^(yuRRaZX9nR0oP5%Wg)P(ak|_q$^7Cd)NP#f zFt*;;hP)je2EkvO_Juc*@6Fd}(xbH@+`c?h1(9yjJzcLY^!{hs3;2?q^IfrF`+D{7 zeAjrrb~tUbxms|met4=I%jCVN6O3DEeY8_%NiNb1EvTu>AI1J!n@36jd$2##c}B>0 z4L;|^v$`6=K#^tk;MTA+ji{smQT)gaODj-((|WI%X2JbpJ46#0RZ&FMJeh+Z<&>04 z)cI;7Dm)CZ1Q9H0Ge@zDXKAsB9dZbg4?1joh3}_)K2k;c^(s6)kl-$}hLll_T0$(y z-4SgpruNv#}%R(l@3!%tj5l!d~Np>{BXo}gF5QWAP7*n?JW-N~>|I~-Sokci&_Ho87f;meu+(2@Yz45X{^W92m`3_^%9FadE5^cGO72ffn`$&G} zGOIPIF?FsLh^0eater8)<@~LjNIyP(W7F~ackhd7ase+Gfo@-RBG6$Q+CeDbE-eiO! z66k;0^Ze3P9kEj(yiZ!_vx)K5>+Jrl2af_iKMbiG*Z6y})9{?`w@LyvBpEEC99HEm z94J&4%248p>c%Nb+Y?Mm9%w8P;5(?F8nINf&_*-><^LeQ6{hj_UPeUhLmtxd+Vmgt zX+WF*G|x;d1!gF0D5?$*b6|tDV#m<_?(f{b+Jd?J92?)y8t>gZ+-KQ+Bj*PJW__xR zdf03Su)GBsi{L~F7m?zTiiu`Wk!YO=QO{H#)PP2?loJ6bfRs0oKxO3+aYm9`#}5V$ z`x646$5C08JvW-c>mV&jy+a+V^zH9IQ#Inj?BmB?I0~jhx7qLD!cSQ9{<) zCB(xvh>|7z&?P1A6fTeZ=vH4`HaRJenyQMrBMl$uNuOX#!uWTr0YsU$pvq9H4wY>t zl^X-E=|ppy073iT6Xv?zU&~*SOz)S{s$uTKR(W@_aAsUm!9UD9D`~`uK!3`Buc{%2B4{J%ioRlMx&#kB{e!Avb zJrlj#<)~p=4r6CfO9_3Cn1xhg=x7nk+LY}yn%fvBEBY;q4p`CSxj7WfX^CU5+@tJWJi(W&KcO*jj5x;xDLZ*AxFvIAYA@P8yW`o)9#pos(U zSgS*I-N9vd=^11lccI*yNQxzMgJ!_I?64MNHZL9-U_DIfm>8g{k^fj)WeFHM8I_z& zZ3l@3<|n0jQSo~R0*Qcqvf~?+vNohOl*bzy=)XeN;2a3p1~0V$$gAWoVuI=*iPkyO z;E~luur&+0{@(mshrT+g9pcf!^T48w$vch$Nigsv6ylw&q=E-ICa#nDgi$8vmBC($ z=yLuLM0U-^2^S`{_ZwTz$|kB|ZzUr`AM@J;{X1nZJEj`$4skl+fss?6#-GZt`JdU# zvVUW}%8!tF0rBe>`+r}#|FsnVkBs^MUX+ze>dHSpWnWVCqdl~T@Zci3NHq%q1q0&Z zjiRz*rIA75MSd&j>=Hq=uts|mK)cc}S884FYT9`Ym2Gbq-?zNU&7M-!u<)j1^s21K z7oJaB$L#M;cjw#E-oI~{yJTr2o((;6binRCTJm*%J0nrPf%?1jgigQI5bI~2dsFN451~NyCYYvfVfu5!YwE`!Uv%`& zB-2spw{|p}vcNP<;@k3}sV|3_r|H|Z4JC9~&KtI*)@JhM?U=mg#m3PjRVoE+M zVYM5uWSO==K5bE81EEz2?F$jdRB^ec45FWK&Dz+e}E=Op=h#{z^;qey2Dx+2Q2qzwA-MpAB% z6U&685w0+}tjouEmcVXOF$U)7w=8u*B7piVzASTr-X|xfrQR1uvc@IZr$CD4MUVF| zMre!R*v|cBT}rB>9#r~c4@(}lBCp$9)X`O$7f_9s)8|{>$Da!Go_qr=;4rtnr7TgXUpffMV9akHEvEw*Z&g!2Env6(!b;)$Zkq!j9UGy>Zopi zUQ<$5Ex<;BxM?&1+E#8>B$er2c?TqH!q^=LX)1lV=@=!xtMbm`$gt70@|} z8AM$V_n1o@=*E15EncO@{DFc)hEBSA@Nbk=GkNsF#}_mBtmF20k$-)eOP+G`q*EAP^>>5d@ea zg6^gb37{ol+=uYC3->5=jbqd}&J|19Oh}yYviQ}E@&>94`r85c>mo=XKA{q~2C*8q z1(8IqD#!fuWdW8DT^RfX)ssdyOzHq^sC=mmY``qcE8^g-o852h1`FBL)_0fHqqzW%Y(brO+X5H!1sl*7|2>*^XZQ^Um1qp- zj{+=uY~SxwTj1)2rmt7luK=kSptJDqqF#W3sech+R{=RBs5U1mcd@_EU~~8?dsmUjsf7tKBg%yZYVwFEDFu zWWQwnb~$%v)IaYXT;h~afPZz{4^@br zn($GS68Obz0BZLqKb0MyvEEp-F z%XZOu9nt29ll>hIY!o7Ulpi znv6Q&d-;x1Q#smNV37IAjmqJ`f>4;j)zs}@5Ggb8NHQ&r9}YcFk1=s0qSmfDIT zL}IzQfY+Hb7z3YWw>3^;vPtIw+@lL;+6f0j=R`K1?Rs$3&Ft1)@NM5zV1L&`Vbl&7 zswRx&Edg?U7fqYMBpWQ6jO&vI*KI5odc0(9&B?LUS$lNhs$&T-QLab-p|8suK`a9N zU;>Q)dneC-M2!FT|4RScQqNRUcScY|-Hb2FWK7ixX)w*zIKVgM!)R>CsoYSb9@Lsy zLJk9)H;@1=N~KM;fxCA80PT1w>bSwB_El6JKa7XzdPVs_qfTy_HegHLC>RgUxX-lj zs_$O^k~(_!_WADl_zRBtc0-mj? zs$_XlVRk8UA;TzI%p`NZo^_F0EiGU(u~@&bF!!jgly!a1es#9LBez7Usio}j;#J*M zYwchj{qF*wFL`?T^AP-=5n(>kT+$T_0iGHp4PM3Z+@Rs&k(ghDz;|7e>IBW%Q&>Q* z*|!8m`k0#8(2SfZzjS1JdAS)iL*a3Q>Tt-uHB0^>6;1Ac&)lXvA#A+^~TF&^<-Px{Arzw?$8;b z6(xcC)ary#!{#M(-LV!}WvwJ94Y}p+dl+)^9$xeZPD9+g#b-y4E)=6{dZvMSy(4bs zQqd@m1o^6YxMp0{hxGGmxj9Cv;|d+QcXE|*vQbI!0Pil2SOuAXlwDZl!rN-01kujv z`f06S5M~gsjn6G_ql(Z9v;Hz>hvm)t+G*Reo}Oz2DoZC~IJYFxV3=*1bcDI#V-ehb z`yS4?O;M_uUKUWRm9-0*%jA%+L}L(ouJ)NW*6>k4H0cLNq(fNgHv4Jnoecj0zTR!} zd#20Z0rVivt#5;(=aRdjZc}W37m&` zO8hf+O$5W$AK*8A8`$z*=vRHy=*QmoFlAg=(s#RhNTHVYC1}1K@hC|GVLZ=F6-*0x z{+sO$vPen^=y*Dt6A!PzJ!}(6LIqT()R5jys9m(YH-ka(Nn?~~Rtl-H*pP{zU-MQ? zlXus*&2qLymA^@KO>Y@ZjhbR)e1(|kVQ~2STn}zH$Hv*3wWt5KBjg$eN#@{G$fcMS8-`5K^IA7m_aM6 z`$)$n`bVh3x<&!)d?X1WLQ9uG9!?;qPGiS*BaH;RE}RifZm9eNEHWtim)l0DD^SyZww8iac z7r6e^#bzT+IQYWSF&Kq!LAalh*r_;Wzi*>jtu~LuXq%d^sr49_?y34lr!u2w+EXxL ztvGKYoa^y*IC%Ypz%YnJV8{reNW^fpBHc9m`O*l>0iqm+au0Ze=X^~VrnQF?&PU+5 zvDnPzI3)KOpigkw6k+Ys(1~ggta{l}hmoJQoMZf-VJ+IOf#vtk(!25;+d@FGwm{aR zAx2bT?D_&PU}I*Rt}$?_UtrnE;npz+3Wm#cQDminaPZX-ZsD&rZgNMlOP>~lPs)5- z1VY9g@uu8tU)@>Vy33Lo9Nkp)j+fdu6g^!Frwn87+^Rz~KEqIZNvGPU)wR*jLB$B}I$TO*f~!7t4654oLO6t8V2r?1+T_Q&0K0 z4682u*_{u6j(?P@{;`Y5=-T~Y%Kr<77Z}0&gZ+aQ{5EN9gm5}+3o-ZC$|VI0^CJnl zlu@4piaXoYaQOv8RMg_I3w0k1bN&6lEJ=n~1W@$^LZ*+5?6;J{!0RU%BNqm{<~-t- zYBiVcsKMtWrxI-wsbMy>B;oLhCnBi?O$~EZ4$9!UcL&30S4}6G<>y$P0t(I%#Lna} zX_$_w@IIB}3veH9GP|^0P;_>@eR7vav@g)kd8j3{^_~v_K#JRObGNy!PKV z%zyngxUd z^s@D@xs>D?9|0^XQSe9+5fMBr9-1rL2ipylxZmKI{+KWoVU3B__h9-y+tCNq0iyqW8C?N<_=wTWv36hc-;u6_5$-8<-iG^wVX{rs#%*o<0 zP`zZD%9FKz8kA)Pi`QrR2c(!`3^|x4*s*D2BB*E3p1pCB6wSJ(K~r=?GY2zKWbkSM zk97>~}>cv zb$Jz&BN$J`J1%`SPSlD!*ydwZh|}u@DspA$4$sz zuve=&^SCLUwSd_bGS|G?7q|}mlM8;PN?3s*Qn`LoL_I|_0v+g4G5lm(&>D&~sR6?l znI)Ws=bL^}57Jk}tm&JypgNPrn=57ljDoPx5vC%_rIdlHBI-9tCQd3ccs7 z8t-*ywH72aUrR7)OSDPqV2JeQ%}`Fj)8^<7+S({A|0d~}AU_#mFK*xIuPXctHbR_6 z0>4#tdv;L;zy3>@ngEyuC~{UEld$Xby%R!P6GeG0aQ`p@>*JR7p_5+YHPKN^V4fk3 zP=|o0bY4goP@xf7HieU5*Pudrp}QZK@B~{n6cMl7DMdWz@t^;~@D^eU<>!6(45Z(_ zk$+hp^uOOo|9MRR!MG0pHBKn;ANR0%BC@7!gZmJPZJXt>$m&mX8a!}cI&=T z^1$X1PVvlD`DVXD#eo%T9Hq`v^hcCB+%v=fj3To3%ZWn%=JZC_ zoex%j4J+ zbQX)n1VtYQf2U6; zl+lO7)ctA65@v(JWy3f!Jhj+syx9tcQ)P2qi3?*W-Zw#Ork|#Fs{k`fVV_!Mn!xL3 zIk}JIQwGd7Ve?#cLD_l3;B&IP`k1Ad;eT4RS=pW5A1i9B3J!lo3 z!WN4Denb)1o>9tu9*MQeIgR3$ z0rD%TiSRC-!526-Q_<1bGYn58#9j%95VT-muFHVK2w+EN#G8i;i`sA@UJgGpB~}7x zXT$xV`dKsMX!X;9Ku-Kvd`_&(SCYV;p<-2TVNbPS!mBJ-Wd&_+BDCO7!-ztt23Z4X=cs@kswD@}xU^1g^h~pu=^6pW ze8CszeDle6mmn7p6^EWdfD|dyNB$Hf%@?7eA4}|ajD2dyBKnD5ou30#)271<>qDF}GnvD)t$ z2fj&M*=&%VGF>YIAwtb!y?Ie|YWR?x(XuT5a+5#3i=W?qc_A~KjWxnJccu=Xz$PiiuHzL7#&Jt#VEx6v~-8J%V@+^q|MYi z{c+eNd4k(vCCT3b1G%D0UknFNZ?%lsqRm{_Bk#15n|;|H)9O&HOroVE-FG(hc4&ZE z(2P$V`Y^c7#KE)tx3Id<0tT%cp7~`AFs#cqf_JH!mS_Fm3^W1T!JXma96S=IrQy{} zb0%%7OB-G)J8g)5WpUWTd10Kg^gMRt${vh%)nB};`vmNAbL>TCRA6}wIE<1qWykbg zPcCUTMV-!d>owCDM3^BD{hCpJcQE*pH$gV#ErC;Wx|Pm9SnipSi4GEzX%cltZ8sf0 z4GJEGTyuxoh}YL_^g{rSCj(Mn9xB&ZpEqiyz-a5H?)=3b8E8s zNV4xhy4dT&cqJb_1$w&<_Ly*)afAyxX!#R8gU)gG)(#SXrbXZnoP4uq5;X(XFv+a6 zX>3lBn@9^3=&!a@Iy7C*kVuccxvO@qV6GM z%IEWSgV;mL3SA>lp*KOzvB5IVgDpwgX_;?gI5YK6==zNjtGgy=}3pI7Ml z*K=k&-d*&zJ{n?u+*PW8qBhLLy>UlMZiEIK|oHw$2rs9WFwD^(_d8L4@aT5=s?a8c%PT*VUVg&tO4QDy2SY zjm2bF%vg0dwTFqL)$eqaDox6HxHo5b zNFgp5r*h$E+lpT*h%KuH+&3V2#-tv2SyzkL$JGiwZeF>fbV(hQ2BwSr_!rt3?1T{# z3+p)Tl>z*Z!>MQQ>u0C#>Grq9WuFghUm2<38IZ<^qz{5X#CQaF zf*+9#(YJ9s#v$mL$-q)RasrGY`j8?J&3!QZLlA<|;QEREfPSG;1T6Zobq2^_0kt5q z09VRDG;Z8JCf6j{ENFc;@3BBW=)L0zw=Nv`9rTWlU%SG*pCtHSWjNhK_eeShOUWc1 zguBW=S8?nd=TBUyH^szUGwHcZ_085TFwz#|m8>-DLDz_i63t}Q{&1Hz4#&BBM00Rg zVBLmTo3$&AFIBXyzJFV$-LXKdTj9!w1s4u$sTtwJ%L#eIW7Q-qMV*+xeM-%y0(?Xu zYf$T);aSqS%JCFk#=-}_oMlbLI6SL(vsS@VW3P{axttW?Aj^|nTNjt{WwB<@*PDZT z83dbE=PjR;JkTlb_0}gc$vw%DL8IuHL48?t7bk-p_2$2S%@_`iYL2H6r(tbXtG6$H zi1#UpOr)gY$kAjz^D_2qA(d?Drx*fE7ciOz|S65GQ?@VtM-pB2z zI4+D&hV8ICIAo>$0u9M+c}S*w#r~(Y`X!*Ot*s<>_$|Jy`Jtq%-UyXuOq-?62R=8(;>I?z9KdCKML;#{YLY$;T>XZm?=UMn_|2rJTDP1Hb8tg|jxd^v+7b=!NmtTqBeh&ZS#8&>3NHz5w>{Y4R_ zO^gPq`R-cbRMDwPNbP_#R>)zaj_`d(XF|e#kUT~iLdsnipk{POw`}Y61ZAD0nZ%DK z`9$<-)~~Drk;!X=k_bh1nq3~u>-~rbzMYZ?_?z4aK6~P}R|Rp=V)u!VrbLFxIW+2b z>QCbRY0tN4TkELh&c0Z?EZk3qPr_Z~pM`RmqbUOkJ-FMoK2VOdHC4y-G}8eV+DZWk zX6jN-&=s0$n)ykYm32Cz^-9AHW)kRCfBXP_Rx{TG3mN7#g=+BS3*~Hwshl1}_t0Tr z@>%){i8cncHw7ld83d}Tbd$lY)kp&6w=djR4OnT|iOe!>@!}5DO!8*$5^bG9=g)2C zhntFe*FYJuTv6y}J@zbU^Oo(_A470wLp;z+iI}Hu+#FvD9GC*|JoXx#vUsEWFMWzs zrZu`29dr4^OWAsvC}BUpF4b3865d`bCI=`twM+)7OHA!s+~FKJo5g*Z3)bGBekB6l z{^OH$w2KEi*_gGoh!}k-;;t>d zONzdN&YtPqo8~CDbOb*JqmAK3!_<^zKpEMCm1_Aw;5Ap z5mLu5wB~x0{)K=s#@QHe4QB^QHDEk8EK5WS~XtNf1f;f+>NG|?7@i{z{;oEixJ8NF5> zqrFoEMY^>gJf2r0h7)7!AZa0;Q)Gm-_udiHd6-r+nLkdP8Idjb7YZHg0a|P*pi7*?SHZmWTU_)ek9rzu5jNMxZ1-PQ*8;dpg0KMZ+ zvg<$xcKwT1PCU?+SNM$wAHJ2tf2-A$Hg|CNMu7i3u;2Rm|Lb+l{H9sv<-UiSxL|KC zp<+^oL`w;+0@uOD5|ltr1!It<>CyM9qAyLPU7^`<<=sZwJj}lcAO#Jed;j1|xZP-) z_$diC9(R?o{+&~-z0B_J_6ANFjEe%X=ZqU66Q?A1(h!AWTU?EZ3$shuPcfd!pqaK8 z!fD0;=)T-Z(rPPKxoI++8v5w=@#2 zMjXbSXl5Z|#_JGO8fUn|tFn|N+D7@TQwqfCT14gR8eKfo(XD8)29;&w))lNX3C4^C z4_yvO`*Vokel4~CYWw|m?mdP`6}1AN$VtBqzG;7rd!*;vK*TA97s|PqHCZ{xFnm)~ z9s2x4@urFRS56_BvH!qM3*$k#n1pR|IB6|zmWY+93=<3xqmsN1=9s}qAI$)aN{!JH zA_;b-#~mdM`1_d@qW?<#VVuI_28>DS-W;HRhS3j+m07d#0Xp|#ZnIhhr8t)5s_EE` zT3JNF4UnQUH9EOWEO^G^5&wflY#veqIXg;kE-My3<3l<9gfNQkP1q**CvbxQNd9i4 z?}rC`rg%nf{cI18sklEK1$F*5M?}!fAVS$8bbE-G#XWNyeA8y{>>3X2v0d-+Oj2Nm zDM~hDkKQMEUONW4)V08yH^lSkurW|St2O-qg*X|7z@2eK@Q#PRzc^?S&VF!iHkZ9r zQ|_p96s8ueJgP3de8T?u*X4X7*PB1c+u43Z4}DJ|zhVoT0A8Fiv)KyX%2cjV8ZN3c ztL25YZ~Q;dWu@}E_5AmW*7O3qy%ypGR;@9T0t)F($+h1UowgLH!l=2w zK!qu7u!lkB2db9ff@F80U3Y&HLxo6uuR{t-k=~4>KaMap`91+%-=X4x zPIjb`(iwV6mt`gQh|&>5t)M7K(0ED|DJt@k5JMGy`CcbL;4X9eMpYv9y3t4yjy&B0 zXf?}(|7;DEY^&|$+8O=?lHh`ed24Gb-U*!6TTaZ0@pw}Q7YzJ;?~UHyTPQ)J#Zvh? z@zWJEmhvLkp>o(em;{^vHcBnExu;CTR9eB;(I!)lr!hG6E{)ZFyun7Nb=JW@0qs@d zEkQlh4xOnd+KSSjO@HD@I=o=|<+>iix{rdun$Lsk$f(=9m_IWJCWN&~H&6?b*q;D~ z_z1*N#2($~+O|WY^B2XDwT~$_Z>S36GLjfaX(W-3%cth0B?O@ffccd9nP^2UYXi03 z4uGbbTuq5S1&7(wk?e{h zVAQ9y(!U+Xu-73g-D=uy!XCaY0}{*g46Aw(uj3Y^`bK2@ecVX7t+Z{Sba#VZYI$;U za)t(vXQ(p)x&2Z1>e|kteyh;gzRHrGHZFI%Py~Mt0qoEdxHKWd^)3)GmjLTWKW3do zAjEvy9GP>k;}a@@mp%Hf?5FySdRRTR601M)xPFMIdDtwb#x(F{<^lxbF(}O2M7WWp zl2Z1I|46W47x`fC9WM8*U=}&;9?~EtEz$n{MNV}jhKm(Yw$~vO&R{W4Hb*>XipJ>;XH2Jpx|a+wMXI;lt6wo3Z)Ljs`DHXyJ)$LIq``b zD^gxc6cys%uUQ7+5cWzYV*7mU@Rfg|8&gPjCfdIbLD}~qVEcDktbY!{zmfonO8n{L7g&g|Bl-aN0_nVe5{2&8e+`xB zMjki8%CJ(Aq9@AD?tZ1GGLZ5Aq1*=~L5L@!tSX&ponNexPDz*N=h8YKH9L-P81rF9{!7(z-F7_b$_>=@tomyjdThM!y<6Bae zY{vdG=_1{p8)N}8ioS;C@(dr@R_)}T5C%c>V|b~c;5LhRi;iAu8)R}ulL@=&s@Zk6 z>}ySWoQ>vDwvcTPx>kHaVbZ+SX}@rki*GH~J4+^t9PC z=u|fHt=14)lle{6cYvOX)mZ&GBJ2{g$@KN8b~e?65RAYOh7N;tzih~EAExjN@1q+I z%{fZHMf2P&Y=78aW10S)9?~lu7_`s|<`1A++aoC^NWXxm+jurhppAHvH?dRhvT4g} zhq=&!vD%Yows`SWp3OsVWit8a_qg>5DDv6w@3>Lm9=CAtDXgJv-m&d;~GjW^oz$Nk(#o z1@_a2@uE@10q#}vxN(esT?KbwBA8PA?NrPEpYyT)cg5-dgKbER+m`sAk2Ta?uU_9) zg!RR|*tAsgGaqGH!bakI{!w92PLLRFM>=soXI*OIYUm4;7fv+@-Rlppk~yYy-;f~Y zcJ%Gk`t85CQyCv0$GhmhL<<5aHHdw~BEFM9lm%|p%#Hbwp&mQodTollzGque(8vY{ zR52gtrQ4dcCO!$xA&Ru#v!AX@CL$(HRaHtn!s|1duc@egD!o=UGEWK_r5cS7tNhs` zXU)qVDM>CVNreLwc-GFA*S^Fo;8zo42_DKC(|j8o_}K(;FZ+tK^h}zcEzqyTWWgS@ zh9q-VNo7ZrCv?L8M>F4XBPFc`LGn%7C|ap&BD@1pRflYD?8kcG=Bv?7FhDcF#Y3#* zBRajkVLtbCw0g{{;BLZUXNXE4Z14wHVE*azZ*o4JS@ma$C)d8`c`ZbJk2~_fGvavN z!>{FFkFc8!sb3(TVQQgHCSQ14xZrpu4#;GuWJm0@kuVUqKsRotYGY2ARIOEe##N}v zbX>=47@whw*!`#5H)A98{>QVNI>*K~_FtOT@KY!+UcqjB1B4c-kBRlkrvGYy$QybV zF8{s^o4$h=|CZeN&(Hsd7yXB2N>uui`3|dpKDi%`*(GRz2+1RcH;9hQ4`lzsvXF{^ zASDO;(yU6hckQ&eg3FKILw=zn1_~wR^}Q~zbJj$#j2DQXx|*2syq}!7`gpznAoJzm zJ{9JZ${c8jVh$6aDWuQe$D)R<=VV3+B8O&3?z7tEs@|;vc)&p7En(D+ufG#Db6+i2 zG_pH>tN{ti&V+3C6i?=zx8Hu>Rb89an+j^Ca#Z|_`WR}?UZ%#yU8jLIFGa^8Qht-2 zPIzqsHkga93Dl`Ym)3uh-Nbi}_SsrnFPardtK(KG0R0Alo=5;j>-W%a zv;YBaW_n*32D(HTYQ0$f1D}mzt}0b00pREwqaDs63=9t4-W0$vOrgWA$;f-Z?&gN` z#Y@8Jh((?U{Aty(@Y^H#kv>kR!#)il7cQQrqnK(M8+N!FX;TKysz_yWVeZyih+bxz zPFhwq*I9wiJQZaX@R@Fd zhm)M^g4J!ocM&Sr#Je(})eKrZfmJTtsBOj#%QhS~p?;xq0xat>K!`S6yqJ+fOHe7RiPEXH z=n0VtGLibuH)7tE89ep3(GVosQpm zp|j;a@eEz7Rpe-uw=-^hN9oU9&rT-Yo*rL_J%lQb4~8PawCJ#I-}SFFF?tvaaBG!b zTBym%9f;9t*5>+-4c`T6gEj75YQhMztT$#gMLkh}wXQgjGilvp^{t|I(d@IA0>GVn zVpcietfni2yDnL&wq|Q@girp$h%7qMbnk`ys)1-$xqmNOeHiRAOobh0h4dia@LIh{ zy#XGd*48bZ$YIF~Nt-&b2;LJ)iLy;M0aw48LMd|`3NK3}exvO%Kva$Hkbmypq|qc`#aotE2e&8Cg`toXsxK7lp#v2NQs4T)#v(*T` z4V-l$BJ&{B?HBmT8)3|K-ss)Yn$YH3|v82T4{qFo{drP++b-XdQ8sW`iIaxs@bhmv(W2Fxcau^uSMsEK>Rj z73{pi-93B=GkRE^q(gv}Me`lRD$4u##NtahUMW~WV<_G(mZgpxEkT>ktO&T}AiKv) zYPQQC9FaFTI5u-gy3R1+TJ&fCfwY)wTXYdcPDt(be=m1EX>Vna?{aVX*1{P79o+jr zI=)23ZJRl{?>rL)3bcdo`T_?kA{z$wVkc$8Dd{}$~`4ejC5hO@{QnXc#T z0QlFBFY^6Xn)J?tY@wU`ojVNF&?|( zbnfCK%xS|Q_1F^Kz7K?C~u(8lI(naxFtb;QU!&?z02`H&FF z!mkS)m6y@=PwvK@>EsMeD+WefGIOsvHuV@0?F+bwogS6kg5}ae=zx=nP;tE?I({Q9 zVRtg!inDjc7#8DG$VPEZA`5Im)BVEC9nv_2iK;;wK}ioH&CPgGbexUQ@(Sj9_!r)kvXCJ%encU1>SYu&bJCU4kM% zu&#jOS{6FHo~6ie5+zx|y)N0k&eb>APMu|luTQ!uedH$Hsv?C|)pDP8od%Zf@L%DB z?d11_^zWLo_?E2r{+*gqwzl}c2v(iS;|kx#LLQem@jm+B5D2$HA>`r^fywY7wJ~#Z zlu(rd>NV}eigu2Sg3_d8bT4$Y1!1Cz(0o0K*t*bc)*B~uYRT4w>&?@r zUBxz}*FN1|;CfKaECVr%Gk{uFjmY}Z+SHu@@koWD{1&W1mY!%e<_Q}MIwi={u_m2rB<#9V4J9>?*vl5oRZfXJTmY|e!7f;(GLTw$3dyXdC-ur& zs_ZQKr0CpVi2L-7ErFzqvnpB^fdXWKiYzKQQQ2%ZnB1O5i8%H>MR9pfj2#q3(f2sp zVrO!56^9YP@>1p*qBZ4b(z8B}iwWo#QPzJfZ2n5J5;l5WWJQI2))jQh@YnAnpn|kj!GlSHn`h1%4Pf10 z#$`L|cVl)t_`K}u(j}W>gTh}T{@E_S>wj}-5oWCtG&&=!2_|H?_mnV%zl1v9mRA+J zCMJ^31?>7-WTFszA&y6w3_lSx!8<+n4o@pN{Lvn?<(T0BQ29+UM7(g`QwA~LQZnP4 zU<-r)B?xOkj>kLd9>>fmqNQU{&&ZyHsS0l7`|r20kw*Fg+V}Ep%kOXy>A!Ju{=wRr z>gIY{gR!3yX{l`P-^*cF>v;4mcY)877@BGh6?uPPO0p)^#==jixyOm%O^2i+HnD$i ze?W{vh|)s_^3w|j@ozPP_FI*1=|dX1LRy)u(_anX@r5O@{4qT2{jrrkJ8^;;`Yz`p z>!R$W?6kPNC|ix|@r2;3ey4=Td0YGEQ?Ht>j(7H!;}2=V^6W0W$^`7 zI4ep!?~O!v5~B<=*F@yi7{w_Ts5@e*KyKL4voF&)g4EC{VF$Szr8e2F46~Y@w1hMV zB%|OUt0FB_LN@$5!IPUVer2bGG~Q`Jtd_L+EQLyuIkjw*8Ta0}ElPt!T7GJ#Kxo*& zonOLfp)?We+vTM-Y)^7ym3oj22{2xeP&!pdpt(j%`AtU70i5Ar?K>M$lchY5>M(Uj~|*+YrLz+Z9N3Kui`=?Fe|1= zh!)mB7k+gDHRK;^CKd1GKRWJjSI>*YMszDj=op$RO-x?XI{$YHU5cHrjt6NIvle|B z#L$juDFK31N_xp**g>|YiJyMW_!Wp>UXUE`c*Np>XD~WQ6<0EWeTxkBn;XiVq$xQnv48#Lm*K9f1Q8ZhUc3t@ zaByP4iMp@`I;U1fwS$bkGAwxxx!D;{Fr(r!oG;(WaktP|&V_b?=8BQmip6Luj5$0| zhc~53_*^ZlbQ-2(Y8FF)29@X0^xnMcQ5Se~#b*hLhQt+n2DLTSmsT`OMuM0oSz=k* zm^XohSF%XMksLI`ycclL8ia^bIX9+^&a4uqXvT>sPv0wq!P{{4E3DjB=sm@V$Y7%! zC+sm1RYq9hN$~{yN{e7VltX_cA)c|!n;*q?dYXczgf!fg(noPLrnnxesgD==To z8kL8^Xe6-n;aMKLfz8PlRF#MSv?4>??F%vaeY|2;u^2((FqEY{<}^6LdJYlC1ZqB3 z2{oA5)w({3mp4GtYs<#=m=-G}^`WExESws{F`1^KHG35pCaemZYTNP4S&coDVz1)h z8*Z79OCNUVzXp0;MeWe`E?DxliQF|%2gv+p-JXPDdv`g^VtVM@?JFJ?P6J_C73sK& z0ASccOU!}Lgai6b!cl)%Gh6~G=;U>AUOIwkc2>p3YGZLOhFEDwM3HA02;!~cRX5T<+xEU;Np547z(7REiT>>AxDj?=02(=YF7$%UbodGTeWgW)mhUq%ohVGsscH}xZ zFvAmi7P59!*J~lG8ifrnwf6T!fOnxnfy+8QVkBu4a81qdeDepEiW>$<4BTR0#DoQW#Xh48w zkOr5#77d`5aa;OS*H+0?*2SoI*}r^XC-_7qOqyh=csx#Lg>hkQ;q_?!}lL-SJD0?H4&BRTO`(T7`&1=fH z0g9@7?8b;wGwu11oSm{o@(2a)+v}dEcFaqdFJr`Tp%QNrqmIDFSa17nefwd?;NaEU z(#gt`FJTu}HP<`XFin|1%8^^}AmpUB1EQQ$c0SzBm)=_Eg<(8417DwupI)rljtaNr zZ!AN8cyEV!L^3VFlg#OVE8?Kq_gdBKK8{@L9YI6kM5O`k4C2vLnrurQ>zRO>*pd){ zz3B0|ccsUkB^<*IiL?N3Kcj2iHMHJbD41!e)8V1H5xSTc=e~^O90+yHjLh1Wa+A!h zsoiZ6;mE2e)6``%fiuL#d5-M={fwoxF9fU!#-A*n=IWKM&w6fl-e<0p zdsn$Tzxt~Hkl3`0vvVNwF?#PRg}gj1OfgXZX(wfV=*t!t0bR$4n!F}W{m&0LlNF>A&2Jm-taK&Yln0GU5z zg!R9P+|Jc4c&$~?;e0^r=y@EmV%*K6r^IyM+Jo+v?U}Zaph@_=ol40*wb0{(PeHbw z>xTsnVu8b9`43^L!`Rw3ZM>{%%-%P=J3nCihI4UopHu_=f*oEV;eU>t>SB?$kzDv;~WH^`S`elYG z*-6@0jA_omI-bj}^^@vts~0>)LPgL8s+ErVUw*UB zn`>FfTXiWa>Yw|TgrdG!mqU0}+vBytAJ2b>*|<^jXExZ(40s1!Ut^ay;5%C{%nu$2 zbZvhO{fsa>86G*RgW~X&k394u-+}H!zIo7Z&};6f5()C}?n}|IG45FpuWdi9^=+;x zLEm@I&%xhMM?DW5^0LP-2JU1xXOkf`?vdP!_h6`9Lce+3LqXD#@fSzqSMJfQsX>po z@MJYcqzFT;M4JJ6KWrV@<4Ke*#febLn_ z>w@cZkC(cLHm<6wz6*Xncuo@WbSZYya>K>a#F$Q|dc{UKB&?WBzW0e+N)Jg&82PLQ zj>?XA{Sm?dxM?5gAqP{{fM{M1+0cp!ZwQS$68d&|B}{jputRd}xdt{nA9Q$@l1OjN zwPBRPEZM+OjDqt}$}*WW&=}cSj4W?1h_)37eOx+ZRA=B&{?i+b>yYDNWV}UbYk=)Q zP>aH+hvg2lDxPoOodbaFV4spi`Gh}cc6QhgZ_BsdPLKH=`oZCekYCCWnS}93Y+G@} za!L0GzeR8iHDvG>isJs$IH~dIu+43%6sAgXN?`AKa`S4wTD&sOfq!yL+ooa`CK*a5zP0v<5_Vz--GC62C>eyW3Jv6(Yq3-K%NWL6Xy!!|CEm|)Mz%W>E z8o}p}6cv@1RSD1*Et%D)=A1BlM=CzT0YvvVP&fOXK}KZ{D8k`P?nVeeRZiT)*pEM% z=FU_qeKs+p%;7KvQdJQe#e{H?@5!Jesxq)<)e46sH(6w?SKJ)^FkwkxQ^6~{Jy>!L z?-0%cPaPB9Qg7@EGm^=Q4d9)a>IGPIM!an+Kj=s0)XsqsL{vM{mxvH33e!z(xV#6{ z`Ke{~DFS`$k{wC!l};Mz_P4M{A9wg2cg30(J!DExlI6~DOy0jNOTs*m^C+sdVS>|8 zKQbY|-cZxXWaaYAPh&a(6n8nMC$E#4Ax1dG1^7U`kbyP)eNt<$z# zeKqf8_zvmg@OpT5%}K7@-KjUNJ3r7^Rf>FD;loeDy{U_?lNQ`5X zXHyC%i3!D^8iGWLS`tcKhJXqJ60@d+&adg%I-N)y%VpG8B@euw1mA7gj8|K2kPH>G~2^m))x1XKx$48W}sSyxP{S^wVRF|HV zSk#xKrLp;$DhJ9vDqaY%EILEM2Ie>ubBPA(l^rv|ENJbGe@9V+j@`0`*N(IrXNb+t z205{qs|n4g|1uYbn6-A<23RGq1$3V8EW-~7xP9?syH(BlAPhezomNa`j4br9Fz z)=~FT)xlItaCuX3-KK2-mJdlf2&(s_-7;NWiW66eC_FeWNyhAkMMLJM8Npo?+Ozl3 zBevk_Vd?ByzGrXwCsVhv6s(Tp+}Ppw3y4LwYlS3-2BbkP8R^(QNOla#O~s?%vbkoe zBg7QnQr#UJByEJVsd2iM+}^v!s~Q^P|b?a;Rxpn}(?tsFwEWKETpFp4?3BvCi5gy4)HQYE#UD<7N|{(C=aHd(2(eQrshhDxlelF8qM>` z?!0>eag8!)0GMz9P1*xxHa$t6>2EWBNqBCD`#9Y24Ad)Tu`6xK*_p{(M;4Dbj0LQy z%O9jFpEv&AJWr7I^R~32?HCc~v6<%wf!D(hX9T6A8GT&3cqG%Ov}t_I^NJRnkCk?) z40aie{3tP3S-krhh($@gBH7JJs$BGY!0`02RLo%7Lxm;5!mS%1%yUC9v`4f>ieE4H z#l!OqX^|s43*g(cuhNd>V;JW(jq>3?_#5Zu!R`cQIIF)&sZ$kIb0@Y*8LZGeMsTds znrK>jN8=W3HoVhJ8%0!N;w!@&QL5YHfg-HJ%tTy__Huju0)K2$Wl{|%)5`w*z1p=m zqk(I6-12zJ=u`GR8QMYSslPAtZ@0EflK#cS$XoUTvUzAD5C{~PM{Op$pD8|ftE~PX z{g+?P+@KCOnx(#?cP%8e!)k;X?=ysdA>^SgL=k26OVx%=wa~L|(d(mYv!{8dcze6j z_h|LI<1^Y z5rl?QRzUbq<^7^<3Nrw4iZW@%LvB%uj&Gr+rJ~GIy%hkFrYABRAUnS$q%D0>;?e0F z*YC*NTZCx#;`B%J6dANYbnJuKuiyJ@rPo1!W(yoV9-N|E*bi?ZPSQpCp{sJ6NZ*CU zkKUycUA-@@e-CT-x2UC~bWalsYqBGg!6ArFWmEw1t)0(NT zZ%ah9P*p#+ogxb4pG<{n=s1{w6yf)5Pnc7k->i4J$D=#oy!(LeDbH6emaBR=LFm?bmTzLCYIaUSX9i+(Np3Ech~* zZHTPZ`qMW7@!C0m)ySk|8>=iz9uk3a={c)1BmX_(iy>YbGwBzbB70ITRD;4)n5Re3 zv3feudeh@Wv$Z^3LRkfij>W8`O&Xe0GmItv={wtBH*eWd&MAov7wPat zRX+eoZInHV$FwzpEE#?ASl&^}UDi!0=un=cDFEG_WE^xJtRnhKeVAkBcPLe5t$F(B zdMxkAZQBM_DexyTjp?KgPItFnTep?d7nJi;%7+2_B3wz#V@$6<-6N=m@0Eb_ma<*2 ztl1m5s--y1ew_AvXWGOBMlS{P^oSw+WJ3-`l?LTUxly?Y@u^I6d#dM}QeckO61;u5 z*oLSY({aV(R;c;E4J-16B^vd3ZXp@#!TXInjaahq0>{!8;$%ZPqW!!dTfeZcQFyZ1 z>`NnKReAcFyh{VoCo(Ecg&r#L7$AT&J50!dWuZCSI$7O;2*rs6tQS_bbKP5x$#Btj|uuR!tp8n*%I3T z#I*o#zgxZ75dLNmV{k-117H-Xi89zDKYCfrph%G{*9i8aW)#fi>{Od&bOn&EF~ftt z+7Pq>z)@g8x%{iNrNriHjL8#Tcz|$oqk6D3K2kKbzn0Hlx!8MjN0IXyEo3x@M3g3*q)7 zf=$>mM3McVz#U|myVoDXx{f+xFGNmwCa95_dZ&z|Bvtyn?%{DPH&dD&SoE3s&_z0x z;~M43AnS-z%h+87s-#;(dqrM5{(uxI-x``q{p*WxUWkEWpcdlud)Nt*NWi7ZdDIrC z_*E;|%V30~wZFY1*p<%OpJEBchiO-F5;>!XwzZz1kddp zLZ#w8zx>=scB@Ztd0c#j?z|9PpBNz*-EK)g4%Ib=AD#i#u%c_fz|}vELP1yJH;%_G zBIz&kcdB@=G(LXklqV+FuusvJHyD%Dgh&vGat^kil{edhO2WkgZP$cFd57ALEfGEm zA{ooH`(!1zw_6z}?LjLUIq8nv7yXTl)rjW5#`YLa&C~01FLasqF-bD~i?@MUFJQU& zSK^=jJ}|QE;-6WsfAZ7xKB+J(n3l$B6d_yYh*tf=XlZKuwE1eZmsuk&H(f!fH*$*- z=8VRBrHYD*9hKoEhI<&FNX$4HtbcL+-fc8Vrj^C=axFkI+|CN6am>_(t&OL%n-LR| zXL0(#i=SzkCh-Z&b)93uyM`NMyhTR&m(~3<4n_DN8BWx=fa0lu|1Wo@HZ_;#WnRA` zFqhUtg=`xdz#g5)lATxmS6KhH?*TGIn9kY;$7BRg7*A5X&9B*MBPkOrMH%aA`I`Ybng+8#5_=~W4X{{&s zp|@|-*oP4uBv0IA7toH!!d(J7dy@Ny_DjwVaC~P;D|)N5{HHp?{K9H-kn(a+Nk${B z{~CaG+Xi)9`xa=0zdbJ0|5IlAA7J1gd)GgZAo4rry6_u?XS4cB)X(^@9Ed(@ps{>e z$;(f|5Hm3q2K9j6W_=e0u=dNMOQhZ68_T_L_>>Y5@dZ<#gj*R+J$2&S-1*dXk7=Ic zjqk;++de;1`r?`E$jeg1i2Mzpa9gs94gq1K#1G6!EvdaUQY3boUDqWoRNM3Rt;Ks? z|EIDufroPId>lu~1>khSb`Z}t=!`zW%eR6~<(n0XDNNTWf@b}bdxZX%T;np@o~ z(jpSKP@+_Hy(&v?mP+^bo{8~rj4|)&GoP_^zP~ePd(Lw_=l4G;fL^t`kw|tiVN}*L z&USsIm7Jk{c%)>R9*x(!@`lVOub%65yrN#sRP#t;S$u}Rid7@pCX|9Mh#q$0D>wVy z`ks^`e)vp6hryw}6~U=;H&Wd3y($#i=Gfb3f0I37m4Co6CP43!Z(x-N`X5osp1tms ze%c3}6kDxdVi;xvDg5Kk=TLkvqlYWfL@LvboWsVW+U`h~6rz383{`x@j1I34O>A9u z(OF!w(7xw%ab7W5$HpM}K%Mf9$YGm+jk=D;r>mTjH9CcgYjXwbLtab1OI>AUy5g{C zP+qH{X$!n|DOCvC7Z1h zLb#ijLmCEVemlBALG`lx+>j-CJM z{h@xv#Js&KqkRhBOy1ko*g1^9E1Qrp(!v^?%anZ^SMoN$#p>Wa#eciXlWFTD1ES($ zH&V4-ltR*P33%k}#G;=mJh;o#As5=>+aU21_EK|k|9@jb19hYPwg}ym-xdxYfL#h6fHhzqHN zYkcGRSE)zjf>t}WM{V$3mj0`ekRsBM<`vXf`EFyewPD2G@^lO3*a69qCC@P{(GljB zE`En-IER~AWiM9AR!j4{Uk=#yOt;C+#-Op<(;EA!y|FJxLO9WFXBeaS><3EcaP&*( zzo~{Dmbt3xpYxQDABzsC^mB-j_Y4fixsHDJ@(yo#wk?L1;9ELcW8OHntM9o~DYh@8 zuPLcd@fq&(3&k|dQ~tzN!->&}k}9$L;?Dn7wRQCA2?Hg$*v-@qnn$E{Tf&&2xYXs+ z_LD(>AN;Ua#b*3^n-u!hwIU%`r>>7{oU5eb3t#wbl-7!T;3rgjJ92pfS?_rEApy7Y zS9*>cy#}|gS#39hFKYTV!#^#)X~5`sPNONB&!GZCky=_LR?Jg)3KK5)P-{=pn-RD7 z|KV4UFm2h_XU&_LWA-qv&zCnd!%S81{Fg%;N=8@A{_{GzSaQPzz=BLBF>Q^P|%BeNnwjwq79i}r|@D4J&`6WOqN zeY4?>G@M^Cmc%VrU_17)(9zUH(3Np8iJwT-!F6ng7(=exsw5C*3 z$^`UBU)w+AjcY3CzPctu1(Qyh&@|3*@)ERG>GdpMP7qb49B)w7x`l3AJg7h}x;0XH zOs6_OLo-O7?~z)8VTm_**C=p9U)bW;@Ae%!8vjrG)&fz`lo;@0df-oa--Bn=Is4xK z#g*H=;%p+BqtiVPugD@`558mx$YcUuh-p4BSDQ-0sDU59vNdxwQMcM|u4!j8JDY#` z79(TupPA21fk;WyiB1KNgrKIg*_v#(GB2B@A%#i?(d?zypHcFT)lO%(98W6yOD8?n5M)czS{wx5WqGz2>X%9Wh`BayD&NpQEt}Go42UWTnwA<_|%>>Wwvn$^e4>v zR$*TaG$)R%LWU<(G(D&=EHM@W|V)P*a|Qn z4hw+b3E`aZ&|L|Ph28KG?7aw1*qPfsFcbDhMwm-!oR~lMl;&Nk!8XJQb&MP8{HDZk z@nIuXL@4_N7sa1zs|pLiwv~uL@+mF^IG9+%O0bI^qVyq&3ni{R?O;vVhz!xpO5sA2 zlPwu61)H)UQWF_mNO7=eft6tY3qjn5ACL*xp{QoJiP>sQd;1H>C zumXmzaWkg(sYz|Yx`GcxA$*%sF8G{}N5KsPpCLiSqRSQ*W8W6=(*p?eRqY(+kLsBF zECF0j_>T|>v%g_sCZ}r@ymgC^g`4J*x!=fzKLNa*i0Hg+o}&Y=W@mJx1uo<878fG( z+vDkl-FzEfaG9BzS*t|m?iMT2se)iLW5(_odEUJ)I~zW5%Y{PefPe47&D?g75rz66 D613UA literal 0 HcmV?d00001 diff --git a/samples/multiplatform/gradle/wrapper/gradle-wrapper.properties b/samples/multiplatform/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..94920145f --- /dev/null +++ b/samples/multiplatform/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/multiplatform/gradlew b/samples/multiplatform/gradlew new file mode 100755 index 000000000..2fe81a7d9 --- /dev/null +++ b/samples/multiplatform/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/samples/multiplatform/gradlew.bat b/samples/multiplatform/gradlew.bat new file mode 100644 index 000000000..9618d8d96 --- /dev/null +++ b/samples/multiplatform/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/multiplatform/settings.gradle b/samples/multiplatform/settings.gradle new file mode 100644 index 000000000..4c283e3c5 --- /dev/null +++ b/samples/multiplatform/settings.gradle @@ -0,0 +1,10 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/6.0.1/userguide/multi_project_builds.html + */ + +rootProject.name = 'multiplatform' diff --git a/samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt b/samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt new file mode 100644 index 000000000..407a5e559 --- /dev/null +++ b/samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt @@ -0,0 +1,116 @@ +import ch.tutteli.atrium.api.fluent.en_GB.* +import ch.tutteli.atrium.api.verbs.AssertionVerb +import ch.tutteli.atrium.api.verbs.assert +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic.IS +import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE +import kotlin.test.Test + +class SmokeTest { + @Test + fun toBe_canBeUsed() { + assertThat(1).toBe(1) + } + + @Test + fun assertionFunctionWithoutI18nCanBeUsed() { + assertThat(2).isEven() + } + + @Test + fun assertionFunctionWithI18nCanBeUsed() { + assertThat(4).isMultipleOf(2) + } + + + @Test + fun assertWithinAssert() { + expect { + assert(1) { + @Suppress("DEPRECATION") + assert(2).toBe(1) + } + }.toThrow { + messageContains( + "${AssertionVerb.ASSERT.getDefault()}: 1", + "${AssertionVerb.ASSERT.getDefault()}: 2", + "${TO_BE.getDefault()}: 1" + ) + } + } + + @Test + fun assertThatWithinAssertThat() { + expect { + @Suppress("DEPRECATION") + assertThat(1) { + assertThat(2).toBe(1) + } + }.toThrow { + messageContains( + "${AssertionVerb.ASSERT_THAT.getDefault()}: 1", + "${AssertionVerb.ASSERT_THAT.getDefault()}: 2", + "${TO_BE.getDefault()}: 1" + ) + } + } + + @Test + fun expectWithinExpect() { + expect { + @Suppress("DEPRECATION") + expect(1) { + expect(2).toBe(1) + } + }.toThrow { + messageContains( + "${AssertionVerb.EXPECT.getDefault()}: 1", + "${AssertionVerb.EXPECT.getDefault()}: 2", + "${TO_BE.getDefault()}: 1" + ) + } + } + + @Test + fun assertAnExceptionOccurred() { + assertThat { + throw IllegalArgumentException() + }.toThrow() + } + + @Test + fun assertAnExceptionWithAMessageOccurred() { + assertThat { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun assertNotToThrow() { + assertThat { + + }.notToThrow() + } +} + + +fun Expect.isEven() = createAndAddAssertion(IS, RawString.create("an even number")) { it % 2 == 0 } + +fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) + +private fun _isMultipleOf(expect: Expect, base: Int): Assertion = + ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} diff --git a/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt b/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt new file mode 100644 index 000000000..dc73b532f --- /dev/null +++ b/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt @@ -0,0 +1,70 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.* +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.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic +import kotlin.test.Test + +class SmokeTest { + @Test + fun isLessThan_canBeUsed() { + assertThat(1).isLessThan(2) + } + + @Test + fun toBe_canBeUsed() { + assertThat(1).toBe(1) + } + + @Test + fun assertionFunctionWithoutI18nCanBeUsed() { + assertThat(4).isEven() + } + + @Test + fun assertionFunctionWithI18nCanBeUsed() { + assertThat(4).isMultipleOf(2) + } + + @Test + fun assertAnExceptionOccurred() { + assertThat { + throw IllegalArgumentException() + }.toThrow() + } + + @Test + fun assertAnExceptionWithAMessageOccurred() { + assertThat { + throw IllegalArgumentException("oho... hello btw") + }.toThrow{ + messageContains("hello") + } + } + + @Test + fun assertNotToThrow() { + assertThat { + + }.notToThrow() + } +} + +fun Expect.isEven() = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } + +fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) + +fun _isMultipleOf(expect: Expect, base: Int): Assertion = + AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} diff --git a/samples/multiplatform/src/jsTest/kotlin/testSetup.kt b/samples/multiplatform/src/jsTest/kotlin/testSetup.kt new file mode 100644 index 000000000..deb1129d0 --- /dev/null +++ b/samples/multiplatform/src/jsTest/kotlin/testSetup.kt @@ -0,0 +1,4 @@ + import ch.tutteli.atrium.fluent.en_GB.dependOnAtrium + + @Suppress("unused") + private val establishDependencyToAtrium = dependOnAtrium() diff --git a/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt b/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt new file mode 100644 index 000000000..2d554a801 --- /dev/null +++ b/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt @@ -0,0 +1,65 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.* +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.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic +import kotlin.test.Test + +class SmokeTest { + @Test + fun toBe_canBeUsed() { + assertThat(1).isLessThan(2) + } + + @Test + fun assertionFunctionWithoutI18nCanBeUsed() { + assertThat(2).isEven() + } + + @Test + fun assertionFunctionWithI18nCanBeUsed() { + assertThat(4).isMultipleOf(2) + } + + @Test + fun assertAnExceptionOccurred() { + assertThat { + throw IllegalArgumentException() + }.toThrow() + } + + @Test + fun assertAnExceptionWithAMessageOccurred() { + assertThat { + throw IllegalArgumentException("oho... hello btw") + }.toThrow{ + messageContains("hello") + } + } + + @Test + fun assertNotToThrow() { + assertThat { + + }.notToThrow() + } +} + +fun Expect.isEven() = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } + +fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) + +fun _isMultipleOf(expect: Expect, base: Int): Assertion = + AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} From cd76a617dc81e7d7f4bea18e78629f10810cb51b Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 6 Feb 2020 11:56:24 +0100 Subject: [PATCH 029/142] Revert changes to gradlew unrelated to samples/mpp This reverts part of commit 2de0ad1a --- gradle/wrapper/gradle-wrapper.properties | 5 +- samples/jvm/spek/gradlew.bat | 168 +++++++++++------------ 2 files changed, 86 insertions(+), 87 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5e58a1b50..4b7e1f3d3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Jan 21 11:00:06 EST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/jvm/spek/gradlew.bat b/samples/jvm/spek/gradlew.bat index 6d57edc70..0f8d5937c 100644 --- a/samples/jvm/spek/gradlew.bat +++ b/samples/jvm/spek/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega From 7c6c960bd4557ed19eda77e01afe3fa80f1743ee Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Thu, 6 Feb 2020 12:59:03 +0200 Subject: [PATCH 030/142] feat(infix-api): local date assertions --- .../infix/en_GB/jdk8/localDateAssertions.kt | 105 ++++++++++++++++++ .../jdk8/LocalDateFeatureAssertionsSpec.kt | 37 ++++++ 2 files changed, 142 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateFeatureAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt new file mode 100644 index 000000000..f3d58a428 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt @@ -0,0 +1,105 @@ +@file:Suppress( + "FINAL_UPPER_BOUND" /* remove once https://youtrack.jetbrains.com/issue/KT-34257 is fixed */, + "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */ +) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.localDate +import java.time.DayOfWeek +import java.time.LocalDate + +/** + * Creates an [Expect] for the property [LocalDate.year][LocalDate.getYear] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.year: Expect + get() = ExpectImpl.localDate.year(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDate.year][LocalDate.getYear]of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDate.year(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.month: Expect + get() = ExpectImpl.localDate.month(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDate.month(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [LocalDate.getDayOfWeek] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.dayOfWeek: Expect + get() = ExpectImpl.localDate.dayOfWeek(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDate.getDayOfWeek] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDate.dayOfWeek(this).addToInitial(assertionCreator) + + +/** + * Creates an [Expect] for the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.day: Expect + get() = ExpectImpl.localDate.day(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDate.day(this).addToInitial(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateFeatureAssertionsSpec.kt new file mode 100644 index 000000000..7355cb2e7 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateFeatureAssertionsSpec.kt @@ -0,0 +1,37 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.property +import java.time.DayOfWeek +import java.time.LocalDate + +class LocalDateFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.LocalDateFeatureAssertionsSpec( + property(Expect::year), + fun1.() -> Unit>(Expect::year), + property(Expect::month), + fun1.() -> Unit>(Expect::month), + property(Expect::day), + fun1.() -> Unit>(Expect::day), + property(Expect::dayOfWeek), + fun1.() -> Unit>(Expect::dayOfWeek) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect = notImplemented() + + a1.year + a1 = a1 year { } + + a1.month + a1 = a1 month { } + + a1.dayOfWeek + a1 = a1 dayOfWeek { } + + a1.day + a1 = a1 day { } + } +} + From e4794deffca6b7375126eca15387aaea3ae5de55 Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Thu, 6 Feb 2020 13:07:39 +0200 Subject: [PATCH 031/142] feat(infix-api): LocalDateTime assertions --- .../en_GB/jdk8/localDateTimeAssertions.kt | 105 ++++++++++++++++++ .../LocalDateTimeFeatureAssertionsSpec.kt | 36 ++++++ 2 files changed, 141 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateTimeFeatureAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt new file mode 100644 index 000000000..0ef63dd7e --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt @@ -0,0 +1,105 @@ +@file:Suppress( + "FINAL_UPPER_BOUND" /* remove once https://youtrack.jetbrains.com/issue/KT-34257 is fixed */, + "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */ +) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.localDateTime +import java.time.DayOfWeek +import java.time.LocalDateTime + +/** + * Creates an [Expect] for the property [LocalDateTime.year][[LocalDateTime.getYear] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.year: Expect + get() = ExpectImpl.localDateTime.year(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDateTime.year][LocalDateTime.getYear] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDateTime.year(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue] + * of the subject of the assertion, so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.month: Expect + get() = ExpectImpl.localDateTime.month(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue]of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDateTime.month(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek] + * of the subject of the assertion, so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.dayOfWeek: Expect + get() = ExpectImpl.localDateTime.dayOfWeek(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek]of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDateTime.dayOfWeek(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] + * of the subject of the assertion, so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.day: Expect + get() = ExpectImpl.localDateTime.day(this).getExpectOfFeature() + +/** + * Expects that the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.localDateTime.day(this).addToInitial(assertionCreator) + diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateTimeFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateTimeFeatureAssertionsSpec.kt new file mode 100644 index 000000000..02a2a8f60 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/LocalDateTimeFeatureAssertionsSpec.kt @@ -0,0 +1,36 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.property +import java.time.DayOfWeek +import java.time.LocalDateTime + +class LocalDateTimeFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.LocalDateTimeFeatureAssertionsSpec( + property(Expect::year), + fun1.() -> Unit>(Expect::year), + property(Expect::month), + fun1.() -> Unit>(Expect::month), + property(Expect::day), + fun1.() -> Unit>(Expect::day), + property(Expect::dayOfWeek), + fun1.() -> Unit>(Expect::dayOfWeek) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect = notImplemented() + + a1.year + a1 = a1 year { } + + a1.month + a1 = a1 month { } + + a1.day + a1 = a1 day { } + + a1.dayOfWeek + a1 = a1 dayOfWeek { } + } +} From 488b1fd94edaea72ff9dcde692099e296864fdcd Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 6 Feb 2020 12:15:45 +0100 Subject: [PATCH 032/142] simplify tests in all samples --- .../test/kotlin/ch/tutteli/SampleJsTest.kt | 44 +++++++ .../src/test/kotlin/ch/tutteli/SmokeTest.kt | 68 ---------- .../test/kotlin/ch/tutteli/SampleJsTest.kt | 44 +++++++ .../src/test/kotlin/ch/tutteli/SmokeTest.kt | 68 ---------- .../test/kotlin/ch/tutteli/SampleJvmTest.kt | 45 +++++++ .../src/test/kotlin/ch/tutteli/SmokeTest.kt | 66 ---------- .../src/commonTest/kotlin/SampleTest.kt | 42 +++++++ .../src/commonTest/kotlin/SmokeTest.kt | 116 ------------------ .../jsTest/kotlin/ch/tutteli/SampleJsTest.kt | 39 ++++++ .../src/jsTest/kotlin/ch/tutteli/SmokeTest.kt | 70 ----------- .../kotlin/ch/tutteli/SampleJvmTest.kt | 39 ++++++ .../jvmTest/kotlin/ch/tutteli/SmokeTest.kt | 65 ---------- 12 files changed, 253 insertions(+), 453 deletions(-) create mode 100644 samples/js/jasmine/src/test/kotlin/ch/tutteli/SampleJsTest.kt delete mode 100644 samples/js/jasmine/src/test/kotlin/ch/tutteli/SmokeTest.kt create mode 100644 samples/js/mocha/src/test/kotlin/ch/tutteli/SampleJsTest.kt delete mode 100644 samples/js/mocha/src/test/kotlin/ch/tutteli/SmokeTest.kt create mode 100644 samples/jvm/junit5/src/test/kotlin/ch/tutteli/SampleJvmTest.kt delete mode 100644 samples/jvm/junit5/src/test/kotlin/ch/tutteli/SmokeTest.kt create mode 100644 samples/multiplatform/src/commonTest/kotlin/SampleTest.kt delete mode 100644 samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt create mode 100644 samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SampleJsTest.kt delete mode 100644 samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt create mode 100644 samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SampleJvmTest.kt delete mode 100644 samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt diff --git a/samples/js/jasmine/src/test/kotlin/ch/tutteli/SampleJsTest.kt b/samples/js/jasmine/src/test/kotlin/ch/tutteli/SampleJsTest.kt new file mode 100644 index 000000000..e648735f6 --- /dev/null +++ b/samples/js/jasmine/src/test/kotlin/ch/tutteli/SampleJsTest.kt @@ -0,0 +1,44 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.messageContains +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.translations.DescriptionBasic +import kotlin.test.Test + +class SampleJsTest { + @Test + fun toBe() { + expect(1).toBe(1) + } + + @Test + fun assertAnExceptionOccurred() { + expect { + throw IllegalArgumentException() + }.toThrow() + } + + + @Test + fun assertAnExceptionWithAMessageOccurred() { + expect { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun useOwnFunction() { + // isEven is defined in the common module + assertThat(2).isEven() + } +} + +fun Expect.isEven() = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } diff --git a/samples/js/jasmine/src/test/kotlin/ch/tutteli/SmokeTest.kt b/samples/js/jasmine/src/test/kotlin/ch/tutteli/SmokeTest.kt deleted file mode 100644 index 623a166fb..000000000 --- a/samples/js/jasmine/src/test/kotlin/ch/tutteli/SmokeTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package ch.tutteli - -import ch.tutteli.atrium.api.fluent.en_GB.isLessThan -import ch.tutteli.atrium.api.fluent.en_GB.messageContains -import ch.tutteli.atrium.api.fluent.en_GB.notToThrow -import ch.tutteli.atrium.api.fluent.en_GB.toThrow -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.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic -import kotlin.test.Test - -class SmokeTest { - @Test - fun toBe_canBeUsed() { - assertThat(1).isLessThan(2) - } - - @Test - fun assertionFunctionWithoutI18nCanBeUsed() { - assertThat(2).isEven() - } - - @Test - fun assertionFunctionWithI18nCanBeUsed() { - assertThat(4).isMultipleOf(2) - } - - @Test - fun assertAnExceptionOccurred() { - assertThat { - throw IllegalArgumentException() - }.toThrow() - } - - @Test - fun assertAnExceptionWithAMessageOccurred() { - assertThat { - throw IllegalArgumentException("oho... hello btw") - }.toThrow{ - messageContains("hello") - } - } - - @Test - fun assertNotToThrow() { - assertThat { - - }.notToThrow() - } -} - -fun Expect.isEven() = - createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } - -fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) - -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} diff --git a/samples/js/mocha/src/test/kotlin/ch/tutteli/SampleJsTest.kt b/samples/js/mocha/src/test/kotlin/ch/tutteli/SampleJsTest.kt new file mode 100644 index 000000000..e648735f6 --- /dev/null +++ b/samples/js/mocha/src/test/kotlin/ch/tutteli/SampleJsTest.kt @@ -0,0 +1,44 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.messageContains +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.translations.DescriptionBasic +import kotlin.test.Test + +class SampleJsTest { + @Test + fun toBe() { + expect(1).toBe(1) + } + + @Test + fun assertAnExceptionOccurred() { + expect { + throw IllegalArgumentException() + }.toThrow() + } + + + @Test + fun assertAnExceptionWithAMessageOccurred() { + expect { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun useOwnFunction() { + // isEven is defined in the common module + assertThat(2).isEven() + } +} + +fun Expect.isEven() = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } diff --git a/samples/js/mocha/src/test/kotlin/ch/tutteli/SmokeTest.kt b/samples/js/mocha/src/test/kotlin/ch/tutteli/SmokeTest.kt deleted file mode 100644 index 623a166fb..000000000 --- a/samples/js/mocha/src/test/kotlin/ch/tutteli/SmokeTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package ch.tutteli - -import ch.tutteli.atrium.api.fluent.en_GB.isLessThan -import ch.tutteli.atrium.api.fluent.en_GB.messageContains -import ch.tutteli.atrium.api.fluent.en_GB.notToThrow -import ch.tutteli.atrium.api.fluent.en_GB.toThrow -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.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic -import kotlin.test.Test - -class SmokeTest { - @Test - fun toBe_canBeUsed() { - assertThat(1).isLessThan(2) - } - - @Test - fun assertionFunctionWithoutI18nCanBeUsed() { - assertThat(2).isEven() - } - - @Test - fun assertionFunctionWithI18nCanBeUsed() { - assertThat(4).isMultipleOf(2) - } - - @Test - fun assertAnExceptionOccurred() { - assertThat { - throw IllegalArgumentException() - }.toThrow() - } - - @Test - fun assertAnExceptionWithAMessageOccurred() { - assertThat { - throw IllegalArgumentException("oho... hello btw") - }.toThrow{ - messageContains("hello") - } - } - - @Test - fun assertNotToThrow() { - assertThat { - - }.notToThrow() - } -} - -fun Expect.isEven() = - createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } - -fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) - -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} diff --git a/samples/jvm/junit5/src/test/kotlin/ch/tutteli/SampleJvmTest.kt b/samples/jvm/junit5/src/test/kotlin/ch/tutteli/SampleJvmTest.kt new file mode 100644 index 000000000..348631ee2 --- /dev/null +++ b/samples/jvm/junit5/src/test/kotlin/ch/tutteli/SampleJvmTest.kt @@ -0,0 +1,45 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.messageContains +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.translations.DescriptionBasic +import org.junit.jupiter.api.Test + +class SampleJvmTest { + @Test + fun toBe() { + expect(1).toBe(1) + } + + @Test + fun assertAnExceptionOccurred() { + expect { + throw IllegalArgumentException() + }.toThrow() + } + + + @Test + fun assertAnExceptionWithAMessageOccurred() { + expect { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun useOwnFunction() { + // isEven is defined in the common module + assertThat(2).isEven() + } +} + +fun Expect.isEven() = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } + diff --git a/samples/jvm/junit5/src/test/kotlin/ch/tutteli/SmokeTest.kt b/samples/jvm/junit5/src/test/kotlin/ch/tutteli/SmokeTest.kt deleted file mode 100644 index 9313e380d..000000000 --- a/samples/jvm/junit5/src/test/kotlin/ch/tutteli/SmokeTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -package ch.tutteli - -import org.junit.jupiter.api.*; - -import ch.tutteli.atrium.api.fluent.en_GB.* -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.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic - -class SmokeTest { - @Test - fun toBe_canBeUsed() { - assertThat(1).isLessThan(2) - } - - @Test - fun assertionFunctionWithoutI18nCanBeUsed() { - assertThat(2).isEven() - } - - @Test - fun assertionFunctionWithI18nCanBeUsed() { - assertThat(4).isMultipleOf(2) - } - - @Test - fun assertAnExceptionOccurred() { - assertThat { - throw IllegalArgumentException() - }.toThrow() - } - - @Test - fun assertAnExceptionWithAMessageOccurred() { - assertThat { - throw IllegalArgumentException("oho... hello btw") - }.toThrow{ - messageContains("hello") - } - } - - @Test - fun assertNotToThrow() { - assertThat { - - }.notToThrow() - } -} - -fun Expect.isEven() = - createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } - -fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) - -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} diff --git a/samples/multiplatform/src/commonTest/kotlin/SampleTest.kt b/samples/multiplatform/src/commonTest/kotlin/SampleTest.kt new file mode 100644 index 000000000..bf825cee6 --- /dev/null +++ b/samples/multiplatform/src/commonTest/kotlin/SampleTest.kt @@ -0,0 +1,42 @@ +import ch.tutteli.atrium.api.fluent.en_GB.messageContains +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.translations.DescriptionBasic.IS +import kotlin.test.Test + +class SampleTest { + + @Test + fun toBe() { + expect(1).toBe(1) + } + + @Test + fun assertAnExceptionOccurred() { + expect { + throw IllegalArgumentException() + }.toThrow() + } + + + @Test + fun assertAnExceptionWithAMessageOccurred() { + expect { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun useOwnFunction() { + assertThat(2).isEven() + } +} + + +fun Expect.isEven() = createAndAddAssertion(IS, RawString.create("an even number")) { it % 2 == 0 } diff --git a/samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt b/samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt deleted file mode 100644 index 407a5e559..000000000 --- a/samples/multiplatform/src/commonTest/kotlin/SmokeTest.kt +++ /dev/null @@ -1,116 +0,0 @@ -import ch.tutteli.atrium.api.fluent.en_GB.* -import ch.tutteli.atrium.api.verbs.AssertionVerb -import ch.tutteli.atrium.api.verbs.assert -import ch.tutteli.atrium.api.verbs.assertThat -import ch.tutteli.atrium.api.verbs.expect -import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.builders.ExpectImpl -import ch.tutteli.atrium.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic.IS -import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE -import kotlin.test.Test - -class SmokeTest { - @Test - fun toBe_canBeUsed() { - assertThat(1).toBe(1) - } - - @Test - fun assertionFunctionWithoutI18nCanBeUsed() { - assertThat(2).isEven() - } - - @Test - fun assertionFunctionWithI18nCanBeUsed() { - assertThat(4).isMultipleOf(2) - } - - - @Test - fun assertWithinAssert() { - expect { - assert(1) { - @Suppress("DEPRECATION") - assert(2).toBe(1) - } - }.toThrow { - messageContains( - "${AssertionVerb.ASSERT.getDefault()}: 1", - "${AssertionVerb.ASSERT.getDefault()}: 2", - "${TO_BE.getDefault()}: 1" - ) - } - } - - @Test - fun assertThatWithinAssertThat() { - expect { - @Suppress("DEPRECATION") - assertThat(1) { - assertThat(2).toBe(1) - } - }.toThrow { - messageContains( - "${AssertionVerb.ASSERT_THAT.getDefault()}: 1", - "${AssertionVerb.ASSERT_THAT.getDefault()}: 2", - "${TO_BE.getDefault()}: 1" - ) - } - } - - @Test - fun expectWithinExpect() { - expect { - @Suppress("DEPRECATION") - expect(1) { - expect(2).toBe(1) - } - }.toThrow { - messageContains( - "${AssertionVerb.EXPECT.getDefault()}: 1", - "${AssertionVerb.EXPECT.getDefault()}: 2", - "${TO_BE.getDefault()}: 1" - ) - } - } - - @Test - fun assertAnExceptionOccurred() { - assertThat { - throw IllegalArgumentException() - }.toThrow() - } - - @Test - fun assertAnExceptionWithAMessageOccurred() { - assertThat { - throw IllegalArgumentException("oho... hello btw") - }.toThrow { - messageContains("hello") - } - } - - @Test - fun assertNotToThrow() { - assertThat { - - }.notToThrow() - } -} - - -fun Expect.isEven() = createAndAddAssertion(IS, RawString.create("an even number")) { it % 2 == 0 } - -fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) - -private fun _isMultipleOf(expect: Expect, base: Int): Assertion = - ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} diff --git a/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SampleJsTest.kt b/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SampleJsTest.kt new file mode 100644 index 000000000..c20325605 --- /dev/null +++ b/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SampleJsTest.kt @@ -0,0 +1,39 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.messageContains +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import isEven +import kotlin.test.Test + +class SampleJsTest { + @Test + fun toBe() { + expect(1).toBe(1) + } + + @Test + fun assertAnExceptionOccurred() { + expect { + throw IllegalArgumentException() + }.toThrow() + } + + + @Test + fun assertAnExceptionWithAMessageOccurred() { + expect { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun useOwnFunction() { + // isEven is defined in the common module + assertThat(2).isEven() + } +} diff --git a/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt b/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt deleted file mode 100644 index dc73b532f..000000000 --- a/samples/multiplatform/src/jsTest/kotlin/ch/tutteli/SmokeTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -package ch.tutteli - -import ch.tutteli.atrium.api.fluent.en_GB.* -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.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic -import kotlin.test.Test - -class SmokeTest { - @Test - fun isLessThan_canBeUsed() { - assertThat(1).isLessThan(2) - } - - @Test - fun toBe_canBeUsed() { - assertThat(1).toBe(1) - } - - @Test - fun assertionFunctionWithoutI18nCanBeUsed() { - assertThat(4).isEven() - } - - @Test - fun assertionFunctionWithI18nCanBeUsed() { - assertThat(4).isMultipleOf(2) - } - - @Test - fun assertAnExceptionOccurred() { - assertThat { - throw IllegalArgumentException() - }.toThrow() - } - - @Test - fun assertAnExceptionWithAMessageOccurred() { - assertThat { - throw IllegalArgumentException("oho... hello btw") - }.toThrow{ - messageContains("hello") - } - } - - @Test - fun assertNotToThrow() { - assertThat { - - }.notToThrow() - } -} - -fun Expect.isEven() = - createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } - -fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) - -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} diff --git a/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SampleJvmTest.kt b/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SampleJvmTest.kt new file mode 100644 index 000000000..c6ad03c88 --- /dev/null +++ b/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SampleJvmTest.kt @@ -0,0 +1,39 @@ +package ch.tutteli + +import ch.tutteli.atrium.api.fluent.en_GB.messageContains +import ch.tutteli.atrium.api.fluent.en_GB.toBe +import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import isEven +import kotlin.test.Test + +class SampleJvmTest { + @Test + fun toBe() { + expect(1).toBe(1) + } + + @Test + fun assertAnExceptionOccurred() { + expect { + throw IllegalArgumentException() + }.toThrow() + } + + + @Test + fun assertAnExceptionWithAMessageOccurred() { + expect { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + messageContains("hello") + } + } + + @Test + fun useOwnFunction() { + // isEven is defined in the common module + assertThat(2).isEven() + } +} diff --git a/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt b/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt deleted file mode 100644 index 2d554a801..000000000 --- a/samples/multiplatform/src/jvmTest/kotlin/ch/tutteli/SmokeTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -package ch.tutteli - -import ch.tutteli.atrium.api.fluent.en_GB.* -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.reporting.RawString -import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.translations.DescriptionBasic -import kotlin.test.Test - -class SmokeTest { - @Test - fun toBe_canBeUsed() { - assertThat(1).isLessThan(2) - } - - @Test - fun assertionFunctionWithoutI18nCanBeUsed() { - assertThat(2).isEven() - } - - @Test - fun assertionFunctionWithI18nCanBeUsed() { - assertThat(4).isMultipleOf(2) - } - - @Test - fun assertAnExceptionOccurred() { - assertThat { - throw IllegalArgumentException() - }.toThrow() - } - - @Test - fun assertAnExceptionWithAMessageOccurred() { - assertThat { - throw IllegalArgumentException("oho... hello btw") - }.toThrow{ - messageContains("hello") - } - } - - @Test - fun assertNotToThrow() { - assertThat { - - }.notToThrow() - } -} - -fun Expect.isEven() = - createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } - -fun Expect.isMultipleOf(base: Int) = addAssertion(_isMultipleOf(this, base)) - -fun _isMultipleOf(expect: Expect, base: Int): Assertion = - AssertImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { - it % base == 0 - } - -enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { - IS_MULTIPLE_OF("is multiple of") -} From 2c4bc27e5d4c2fda61f946f8e5d62a82527dc1b0 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 6 Feb 2020 21:49:24 +0100 Subject: [PATCH 033/142] fix(verbs): return RootExpect instead of Expect this allows that one can use withOptions afterwards (though experimental usage only). --- .../src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt | 6 ++++-- .../main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt | 6 ++++-- .../src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt index 9b4669ebe..982bb5269 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt @@ -3,6 +3,8 @@ package ch.tutteli.atrium.api.verbs import ch.tutteli.atrium.api.verbs.AssertionVerb.ASSERT import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.FeatureExpect +import ch.tutteli.atrium.creating.RootExpect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.reporting.ExpectBuilder import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions @@ -15,7 +17,7 @@ import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions * @return The newly created assertion container. * @throws AssertionError in case an assertion does not hold. */ -fun assert(subject: T): Expect = +fun assert(subject: T): RootExpect = ExpectBuilder.forSubject(subject) .withVerb(ASSERT) .withoutOptions() @@ -41,5 +43,5 @@ fun assert(subject: T, assertionCreator: Expect.() -> Unit): Expect = "ch.tutteli.atrium.api.fluent.en_GB.feature" ) ) -fun Expect.assert(newSubject: R): Expect = +fun Expect.assert(newSubject: R): FeatureExpect = ExpectImpl.feature.manualFeature(this, ASSERT) { newSubject }.getExpectOfFeature() diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt index 75ff304a5..db5462c90 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt @@ -3,6 +3,8 @@ package ch.tutteli.atrium.api.verbs import ch.tutteli.atrium.api.verbs.AssertionVerb.ASSERT_THAT import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.FeatureExpect +import ch.tutteli.atrium.creating.RootExpect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.reporting.ExpectBuilder import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions @@ -15,7 +17,7 @@ import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions * @return The newly created assertion container. * @throws AssertionError in case an assertion does not hold. */ -fun assertThat(subject: T): Expect = +fun assertThat(subject: T): RootExpect = ExpectBuilder.forSubject(subject) .withVerb(ASSERT_THAT) .withoutOptions() @@ -41,5 +43,5 @@ fun assertThat(subject: T, assertionCreator: Expect.() -> Unit): Expect Expect.assertThat(newSubject: R): Expect = +fun Expect.assertThat(newSubject: R): FeatureExpect = ExpectImpl.feature.manualFeature(this, ASSERT_THAT) { newSubject }.getExpectOfFeature() diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt index b1bf56063..82af9c080 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt @@ -3,6 +3,8 @@ package ch.tutteli.atrium.api.verbs import ch.tutteli.atrium.api.verbs.AssertionVerb.EXPECT import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.FeatureExpect +import ch.tutteli.atrium.creating.RootExpect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.reporting.ExpectBuilder import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions @@ -15,7 +17,7 @@ import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions * @return The newly created assertion container. * @throws AssertionError in case an assertion does not hold. */ -fun expect(subject: T): Expect = +fun expect(subject: T): RootExpect = ExpectBuilder.forSubject(subject) .withVerb(EXPECT) .withoutOptions() @@ -41,5 +43,5 @@ fun expect(subject: T, assertionCreator: Expect.() -> Unit): Expect = "ch.tutteli.atrium.api.fluent.en_GB.feature" ) ) -fun Expect.expect(newSubject: R): Expect = +fun Expect.expect(newSubject: R): FeatureExpect = ExpectImpl.feature.manualFeature(this, EXPECT) { newSubject }.getExpectOfFeature() From 0328cb19ccdd95bd753b77f561d4acf506bd0968 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 6 Feb 2020 23:33:14 +0100 Subject: [PATCH 034/142] use withRepresentation also for subject based representations moreover, use the same signature for ExpectBuilder as in FeatureExtractorBuilder, i.e. ExpectOptions requires a type parameter T in addition (this is a breaking change but to an experimental feature) Moreover: - improve KDoc - fix forgiving tests in DeprecationSpek2ExecutionListener --- .../api/fluent/en_GB/expectExtensions.kt | 68 +++++++++++++++---- .../changers/FeatureExtractorBuilder.kt | 30 ++++---- .../featureextractor/OptionsChooserImpl.kt | 2 +- .../builders/reporting/ExpectBuilder.kt | 60 ++++++++-------- .../reporting/impl/verb/OptionsChooserImpl.kt | 15 ++-- .../reporting/impl/verb/defaultImpls.kt | 11 +-- .../lib/creating/featureAssertions.kt | 2 +- .../robstoll/lib/creating/fun0Assertions.kt | 4 +- .../creating/resultAssertions.kt | 4 +- .../integration/IterableAllAssertionsSpec.kt | 1 - misc/tools/atrium-bc-test/build.gradle | 2 +- .../DeprecationSpek2ExecutionListener.kt | 4 +- 12 files changed, 117 insertions(+), 86 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt index fcbcef7dd..5afdcfcf6 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.fluent.en_GB +import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.coreFactory import ch.tutteli.atrium.creating.* import ch.tutteli.atrium.domain.builders.creating.changers.FeatureExtractorBuilder @@ -15,19 +16,37 @@ import ch.tutteli.atrium.reporting.reporter annotation class ExperimentalWithOptions /** - * Uses the given [textRepresentation] as representation of the subject instead of the current representation - * (which defaults to the subject itself). + * Wraps the given [textRepresentation] into a [RawString] and uses it as representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ @ExperimentalWithOptions -fun RootExpect.withOptions(textRepresentation: String): Expect = - withOptions(ExpectOptions(representation = RawString.create(textRepresentation))) +fun RootExpect.withRepresentation(textRepresentation: String): Expect = + withOptions { withRepresentation(textRepresentation) } + +/** + * Uses the given [representationProvider] to retrieve a representation which can be based on the current + * subject where it is used as new representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * 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. + * If your text does not include the current subject, then we recommend to use the other overload which expects + * a `String` and does the wrapping for you. + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + */ +@ExperimentalWithOptions +fun RootExpect.withRepresentation(representationProvider: (T) -> Any): Expect = + withOptions { withRepresentation(representationProvider) } /** * Uses the given [configuration]-lambda to create an [ExpectOptions] which in turn is used * to override (parts) of the existing configuration. */ @ExperimentalWithOptions -fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser.() -> Unit): Expect = +fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser.() -> Unit): Expect = withOptions(ExpectBuilder.OptionsChooser.createAndBuild(configuration)) //TODO #280 get rid of AssertionChecker, that's one root of a bug (which is more a nice to have but still) roadmap#11 @@ -37,23 +56,43 @@ fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser.() */ @ExperimentalWithOptions @UseExperimental(ExperimentalExpectConfig::class) -fun RootExpect.withOptions(options: ExpectOptions): Expect = coreFactory.newReportingAssertionContainer( +fun RootExpect.withOptions(options: ExpectOptions): Expect = coreFactory.newReportingAssertionContainer( ReportingAssertionContainer.AssertionCheckerDecorator.create( options.assertionVerb ?: this.config.description, this.maybeSubject, - options.representation ?: this.config.representation, + options.representationInsteadOfSubject?.let { provider -> + this.maybeSubject.fold({ null }) { provider(it) } + } ?: this.config.representation, //TODO #280 reporter should be configurable as well coreFactory.newThrowingAssertionChecker(options.reporter ?: reporter) ) ) /** - * Uses the given [textRepresentation] as representation of the subject instead of the current representation - * (which defaults to the subject itself). + * Wraps the given [textRepresentation] into a [RawString] and uses it as representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ @ExperimentalWithOptions -fun FeatureExpect.withOptions(textRepresentation: String): Expect = - withOptions { withTextRepresentation(textRepresentation) } +fun FeatureExpect.withRepresentation(textRepresentation: String): Expect = + withOptions { withRepresentation(textRepresentation) } + +/** + * Uses the given [representationProvider] to retrieve a representation which can be based on the current + * subject where it is used as new representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * 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. + * If your text does not include the current subject, then we recommend to use the other overload which expects + * a `String` and does the wrapping for you. + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + */ +@ExperimentalWithOptions +fun FeatureExpect.withRepresentation(representationProvider: (R) -> Any): Expect = + withOptions { withRepresentation(representationProvider) } /** * Uses the given [configuration]-lambda to create an [ExpectOptions] which in turn is used @@ -74,10 +113,9 @@ fun FeatureExpect.withOptions(options: FeatureOptions): Expect options.representationInsteadOfFeature?.invoke(subject) ?: config.representation } - ) + options.representationInsteadOfFeature?.let { provider -> + this.maybeSubject.fold({ null }) { provider(it) } + } ?: this.config.representation ), getAssertions() ) diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/FeatureExtractorBuilder.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/FeatureExtractorBuilder.kt index 7c7283f76..8f32d2315 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/FeatureExtractorBuilder.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/FeatureExtractorBuilder.kt @@ -239,31 +239,27 @@ interface FeatureExtractorBuilder { fun withDescription(description: Translatable) /** - * Wraps the given [representation] into a [RawString] and uses it as representation of the subject - * instead of the so far defined representation (which defaults to the subject as such). - */ - @Suppress("PublicApiImplicitType" /* fine withSubjectBasedRepresentation defines it */) - fun withTextRepresentation(representation: String) = withRepresentation(RawString.create(representation)) - - /** - * Uses the given [representation] as representation of the subject in case the is defined instead of - * the so far defined representation (which defaults to the subject as such). + * Wraps the given [textRepresentation] into a [RawString] and uses it as representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). * - * Notice, if you want to use text (e.g. a [String]) as representation, - * then use [withTextRepresentation] instead. + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ - @Suppress("PublicApiImplicitType" /* fine withSubjectBasedRepresentation defines it */) - fun withRepresentation(representation: Any) = withSubjectBasedRepresentation { representation } - + fun withRepresentation(textRepresentation: String): Unit = + withRepresentation { RawString.create(textRepresentation) } /** - * Uses the given [representationProvider] which provides the representation for a given subject wrapped in - * [Option] instead of the so far defined representation (which defaults to the subject as such). + * Uses the given [representationProvider] to retrieve a representation which can be based on the current + * subject where this provided representation is used as new representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). * * 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. + * If your text does not include the current subject, then we recommend to use the other overload which expects + * a `String` and does the wrapping for you. + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ - fun withSubjectBasedRepresentation(representationProvider: (R) -> Any) + fun withRepresentation(representationProvider: (R) -> Any) companion object { fun createAndBuild(configuration: OptionsChooser.() -> Unit): FeatureOptions = diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/OptionsChooserImpl.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/OptionsChooserImpl.kt index 268d77a3b..3b716b5d7 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/OptionsChooserImpl.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/OptionsChooserImpl.kt @@ -12,7 +12,7 @@ class OptionsChooserImpl : FeatureExtractorBuilder.OptionsChooser { this.description = description } - override fun withSubjectBasedRepresentation(representationProvider: (R) -> Any) { + override fun withRepresentation(representationProvider: (R) -> Any) { this.representationInsteadOfFeature = representationProvider } diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/ExpectBuilder.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/ExpectBuilder.kt index da812737a..7cf9404b8 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/ExpectBuilder.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/ExpectBuilder.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.domain.builders.reporting +import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.core.Some import ch.tutteli.atrium.creating.Expect @@ -71,13 +72,13 @@ interface ExpectBuilder { * * The function usually start with `with...` and are sometimes overloaded to ease the configuration. */ - fun withOptions(configuration: OptionsChooser.() -> Unit): FinalStep = + fun withOptions(configuration: OptionsChooser.() -> Unit): FinalStep = withOptions(ExpectOptions(configuration)) /** * Uses the given [expectOptions]. */ - fun withOptions(expectOptions: ExpectOptions): FinalStep + fun withOptions(expectOptions: ExpectOptions): FinalStep /** * States explicitly that no optional [ExpectOptions] are defined, which means, `build` will create @@ -102,7 +103,7 @@ interface ExpectBuilder { * * Calling multiple times the same method overrides the previously defined value. */ - interface OptionsChooser { + interface OptionsChooser { /** * Wraps the given [verb] into an [Untranslatable] and passes it to the overload @@ -120,29 +121,27 @@ interface ExpectBuilder { fun withVerb(verb: Translatable) /** - * Wraps the given [representation] into a [RawString] and uses it as representation of the subject - * instead of the so far defined representation (which defaults to the subject as such). + * Wraps the given [textRepresentation] into a [RawString] and uses it as representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ - @Suppress("PublicApiImplicitType" /* fine withRepresentation defines it */) - fun withTextRepresentation(representation: String) = withRepresentation(RawString.create(representation)) + fun withRepresentation(textRepresentation: String): Unit = + withRepresentation { RawString.create(textRepresentation) } /** - * Uses the given [representation] as representation of the subject instead of using the subject as such to - * represent itself. + * Uses the given [representationProvider] to retrieve a representation which can be based on the current + * subject where it is used as new representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). * * 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 withRepresentation(representation: Any) - - /** - * Use the given [representation] as custom representation for `null`. + * If your text does not include the current subject, then we recommend to use the other overload which expects + * a `String` and does the wrapping for you. * - * 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. + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ - //TODO #279 remove - fun withNullRepresentation(representation: Any) + fun withRepresentation(representationProvider: (T) -> Any) /** * Uses the given [reporter] instead of the default reporter. @@ -150,8 +149,8 @@ interface ExpectBuilder { fun withReporter(reporter: Reporter) companion object { - fun createAndBuild(configuration: OptionsChooser.() -> Unit): ExpectOptions = - OptionsChooserImpl().apply(configuration).build() + fun createAndBuild(configuration: OptionsChooser.() -> Unit): ExpectOptions = + OptionsChooserImpl().apply(configuration).build() } } @@ -174,7 +173,7 @@ interface ExpectBuilder { /** * Either the previously specified [ExpectOptions] or `null`. */ - val options: ExpectOptions? + val options: ExpectOptions? /** * Creates a new [Expect] based on the previously defined maybeOptions. @@ -185,7 +184,7 @@ interface ExpectBuilder { fun create( maybeSubject: Option, assertionVerb: Translatable, - options: ExpectOptions? + options: ExpectOptions? ): FinalStep = FinalStepImpl(maybeSubject, assertionVerb, options) } } @@ -195,29 +194,30 @@ interface ExpectBuilder { * Additional (non-mandatory) options for the [ExpectBuilder] to create an [Expect]. * * @property assertionVerb Defines a custom assertion verb if not null. - * @property representation Defines a custom representation for the subject if not null. + * @property representationInsteadOfSubject Defines a custom representation based on a present subject if not null. * @property reporter Defines a custom reporter if not null. */ -data class ExpectOptions( +data class ExpectOptions( val assertionVerb: Translatable? = null, - val representation: Any? = null, + val representationInsteadOfSubject: ((T) -> Any)? = null, val reporter: Reporter? = null ) { /** * Merges the given [options] with this object creating a new [ExpectOptions] * where defined properties in [options] will have precedence over properties defined in this instance. * - * For instance, this object has defined [representation] (meaning it is [Some]) and the given [options] as well, - * then the resulting [ExpectOptions] will have the [representation] of [options]. + * For instance, this object has defined [representationInsteadOfSubject] (meaning it is not `null`) and + * the given [options] as well, then the resulting [ExpectOptions] will have the + * [representationInsteadOfSubject] of [options]. */ - fun merge(options: ExpectOptions): ExpectOptions = + fun merge(options: ExpectOptions): ExpectOptions = ExpectOptions( options.assertionVerb ?: assertionVerb, - options.representation ?: representation, + options.representationInsteadOfSubject ?: representationInsteadOfSubject, options.reporter ?: reporter ) } @Suppress("FunctionName") -fun ExpectOptions(configuration: ExpectBuilder.OptionsChooser.() -> Unit): ExpectOptions = +fun ExpectOptions(configuration: ExpectBuilder.OptionsChooser.() -> Unit): ExpectOptions = ExpectBuilder.OptionsChooser.createAndBuild(configuration) diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/OptionsChooserImpl.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/OptionsChooserImpl.kt index cac8af1dc..9789d677d 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/OptionsChooserImpl.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/OptionsChooserImpl.kt @@ -5,28 +5,23 @@ import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.Translatable -class OptionsChooserImpl : ExpectBuilder.OptionsChooser { +class OptionsChooserImpl : ExpectBuilder.OptionsChooser { private var description: Translatable? = null - private var representation: Any? = null - private var nullRepresentation: Any? = null + private var representationInsteadOfSubject: ((T) -> Any)? = null private var reporter: Reporter? = null override fun withVerb(verb: Translatable) { this.description = verb } - override fun withRepresentation(representation: Any) { - this.representation = representation - } - - override fun withNullRepresentation(representation: Any) { - this.nullRepresentation = representation + override fun withRepresentation(representationProvider: (T) -> Any) { + this.representationInsteadOfSubject = representationProvider } override fun withReporter(reporter: Reporter) { this.reporter = reporter } - fun build(): ExpectOptions = ExpectOptions(description, representation, reporter) + fun build(): ExpectOptions = ExpectOptions(description, representationInsteadOfSubject, reporter) } diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/defaultImpls.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/defaultImpls.kt index 8182c142d..66c73f681 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/defaultImpls.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/reporting/impl/verb/defaultImpls.kt @@ -22,17 +22,17 @@ class OptionsStepImpl( override val assertionVerb: Translatable ) : ExpectBuilder.OptionsStep { - override fun withOptions(expectOptions: ExpectOptions): ExpectBuilder.FinalStep = toFinalStep(expectOptions) + override fun withOptions(expectOptions: ExpectOptions): ExpectBuilder.FinalStep = toFinalStep(expectOptions) override fun withoutOptions(): ExpectBuilder.FinalStep = toFinalStep(null) - private fun toFinalStep(expectOptions: ExpectOptions?) = + private fun toFinalStep(expectOptions: ExpectOptions?) = ExpectBuilder.FinalStep.create(maybeSubject, assertionVerb, expectOptions) } class FinalStepImpl( override val maybeSubject: Option, override val assertionVerb: Translatable, - override val options: ExpectOptions? + override val options: ExpectOptions? ) : ExpectBuilder.FinalStep { override fun build(): RootExpect = @@ -40,7 +40,10 @@ class FinalStepImpl( ReportingAssertionContainer.AssertionCheckerDecorator.create( options?.assertionVerb ?: assertionVerb, maybeSubject, - options?.representation ?: maybeSubject.getOrElse { + options?.representationInsteadOfSubject?.let { provider -> + this.maybeSubject.fold({ null }) { provider(it) } + } ?: maybeSubject.getOrElse { + // a RootExpect without a defined subject is almost certain a bug RawString.create(SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG) }, coreFactory.newThrowingAssertionChecker(options?.reporter ?: reporter) diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/featureAssertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/featureAssertions.kt index 34f9f16c9..fb9f76289 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/featureAssertions.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/featureAssertions.kt @@ -12,6 +12,6 @@ fun _genericFeature(expect: Expect, metaFeature: MetaFeature): Extr .withDescription(metaFeature.description) .withRepresentationForFailure(representation) .withFeatureExtraction { metaFeature.maybeSubject } - .withOptions { withRepresentation(representation) } + .withOptions { withRepresentation { representation } } .build() } diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt index 1904ff008..f77add4da 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt @@ -1,7 +1,7 @@ package ch.tutteli.atrium.domain.robstoll.lib.creating import ch.tutteli.atrium.api.fluent.en_GB.ExperimentalWithOptions -import ch.tutteli.atrium.api.fluent.en_GB.withOptions +import ch.tutteli.atrium.api.fluent.en_GB.withRepresentation import ch.tutteli.atrium.core.Either import ch.tutteli.atrium.core.Left import ch.tutteli.atrium.core.Right @@ -30,7 +30,7 @@ fun _isThrowing( ) } .getExpectOfFeature() - .withOptions { withSubjectBasedRepresentation { it ?: RawString.create(NO_EXCEPTION_OCCURRED) } } + .withRepresentation { it ?: RawString.create(NO_EXCEPTION_OCCURRED) } .let { ExpectImpl.changeSubject(it).reportBuilder() .downCastTo(expectedType) diff --git a/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt b/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt index 0d0ac745d..a2845a55c 100644 --- a/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt +++ b/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt @@ -1,7 +1,7 @@ package ch.tutteli.atrium.domain.robstoll.lib.kotlin_1_3.creating import ch.tutteli.atrium.api.fluent.en_GB.ExperimentalWithOptions -import ch.tutteli.atrium.api.fluent.en_GB.withOptions +import ch.tutteli.atrium.api.fluent.en_GB.withRepresentation import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -33,7 +33,7 @@ fun _isFailure( val throwableExpect = ExpectImpl.feature .manualFeature(assertionContainer, EXCEPTION) { exceptionOrNull() } .getExpectOfFeature() - .withOptions { withSubjectBasedRepresentation { it ?: RawString.create(IS_NOT_FAILURE) } } + .withRepresentation { it ?: RawString.create(IS_NOT_FAILURE) } return ExpectImpl.changeSubject(throwableExpect).reportBuilder() .downCastTo(expectedType) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt index 7bc4ac828..823295acf 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt @@ -53,7 +53,6 @@ abstract class IterableAllAssertionsSpec( context("empty collection") { it("$isLessThanFun(1.0) throws AssertionError") { - println("////////////////////////") expect { fluentEmpty.allFun { isLessThan(1.0) } }.toThrow { diff --git a/misc/tools/atrium-bc-test/build.gradle b/misc/tools/atrium-bc-test/build.gradle index ba9357166..30f01ab2d 100644 --- a/misc/tools/atrium-bc-test/build.gradle +++ b/misc/tools/atrium-bc-test/build.gradle @@ -370,7 +370,7 @@ createBcAndBbcTasksForApis('0.8.0', 'cc-de_CH', 'cc-en_GB', 'cc-infix-en_GB' ) createBcAndBbcTasksForApis('0.9.1', - 'forgive=^$', + 'forgive=^.* assertion function can be used in an AssertionGroup with an ExplanatoryAssertionGroupType.*$', 'fluent-en_GB' ) //@formatter:on diff --git a/misc/tools/atrium-bc-test/src/main/kotlin/ch/tutteil/atrium/bctest/DeprecationSpek2ExecutionListener.kt b/misc/tools/atrium-bc-test/src/main/kotlin/ch/tutteil/atrium/bctest/DeprecationSpek2ExecutionListener.kt index d1dee6c8e..eb7ab2b60 100644 --- a/misc/tools/atrium-bc-test/src/main/kotlin/ch/tutteil/atrium/bctest/DeprecationSpek2ExecutionListener.kt +++ b/misc/tools/atrium-bc-test/src/main/kotlin/ch/tutteil/atrium/bctest/DeprecationSpek2ExecutionListener.kt @@ -18,8 +18,8 @@ class DeprecationSpek2ExecutionListener( } private fun handleFailure(result: ExecutionResult.Failure, test: TestScopeImpl) { - if (forgiveRegex.matches(test.id.name)) { - println("forgiving $test") + if (forgiveRegex.matches(test.path.toString())) { + println("forgiving ${test.path}") listener.testExecutionFinish(test, ExecutionResult.Success) } else { listener.testExecutionFinish(test, result) From 293279e7c50777575e5e8d2386a0b29ebc7ff429 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 1 Feb 2020 22:16:27 +0100 Subject: [PATCH 035/142] de-activate new infix API for release (cherry picked from commit d9deef82d13be32bc34f170db8b63668e541768c) --- settings.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 3c2e71196..fa3160673 100644 --- a/settings.gradle +++ b/settings.gradle @@ -62,7 +62,8 @@ include { apis('api-') { apiWithExtensions(delegate, 'fluent-en_GB') - apiWithExtensions(delegate, 'infix-en_GB') + //TODO re-activate with 0.10.0 +// apiWithExtensions(delegate, 'infix-en_GB') } domain('domain-') { From 779df12eebcb4d3ead15968d62719110b5dc5171 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 8 Feb 2020 14:55:57 +0100 Subject: [PATCH 036/142] update deploy description and prepare next dev cycle --- build.gradle | 58 +++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index 76c61f68b..27e4d4dc0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - rootProject.version = '0.10.0-SNAPSHOT' + rootProject.version = '0.9.2' rootProject.group = 'ch.tutteli.atrium' def sampleProjectsFun = subprojects.findAll { @@ -519,45 +519,51 @@ configure(subprojects - getJsProjects()) { subproject -> } /* - Release & deploy a commit -------------------------------- -1. change rootProject.version in build.gradle to X.Y.Z -2. update master: - a) point to the tag - 1) search for old version and replace with new, except for samples (gradle, maven and section own assertion verb in README.md) - 2) adjust branch=master manually, use tag=vX.Y.Z except for travis where you need to use branch=vX.Y.Z - 3) search for `tree/master` and replace it with `tree/vX.Y.Z` (README.md) - 4) search for `latest#/doc` and replace with `X.Y.Z/doc` (README.md and differences.md) - 5) Remove the warning in README.md about taking a sneak peak (copy it, well be added afterwards) - b) Update README -> Use own Assertion Verbs -> link to atriumVerbs if it changed - c) commit & push (modified build.gradle, README.md and differences.md) -3. update github pages: +1. update master: + a) change rootProject.version in build.gradle and in example-pom.xml to X.Y.Z + b) search for old version in README.md and replace with new + c) search for `tree/master` in all .md files and replace it with `tree/vX.Y.Z` + d) search for `latest#/doc` in all .md files and replace with `X.Y.Z/doc` + e) use the release badges in README (comment out the ones for master and uncomment the ones for the release) + f) comment out the warning in README.md about taking a sneak peak + g) commit & push (modified build.gradle, README.md, differences.md and example-pom.xml) + +2. update github pages: +assumes you have a atrium-gh-pages folder on the same level as atrium where the gh-pages branch is checked out a) gr ghPages b) change version number in atrium-gh-pages/latest/index.html c) add new version to atrium-gh-pages/README.md d) commit & push changes -4. deploy to bintray: + +3. deploy to bintray: // CI=true is a temporary work around till https://youtrack.jetbrains.com/issue/KT-29069 is fixed: a) java -version 2>&1 | grep "version \"11" && CI=true ./gr clean publishToBintray b) Log in to bintray, check that there are 926 artifacts and publish them c) synchronise to maven central -5. create release on github + +4. create release on github a) git tag vX.Y.Z b) git push origin vX.Y.Z c) Log in to github and create release Prepare next dev cycle ----------------------- -1. change rootProject.version in build.gradle to X.Y.Z-SNAPSHOT -2. point to master - a) search for `tag=vX.Y.Z` and replace it with `branch=master` - b) search for `tree/vX.Y.Z` and replace it with `tree/master` - c) search for `X.Y.Z/doc` and replace with `latest#/doc` -3. update README - a) place the warning about taking a sneak peek back into README - b) update version in the warning to X.Y.Z and update the link as well -4. Use new version in samples (search again for the old-version and replace with new) -5. commit & push changes -6. establish backward compatibility tests for the previous version +1. update samples + a) use newly released version in samples (search again for the old-version and replace with new) + b) commit & push changes + +2. update master: + a) search for `tree/vX.Y.Z` and replace it with `tree/master` + b) search for `X.Y.Z/doc` and replace with `latest#/doc` + c) use the master badges in README (uncomment them in README and comment out release badges) + d) uncomment the warning about taking a sneak peek in README + e) update version in the warning to X.Y.Z and update the link as well + f) change rootProject.version in build.gradle to X.Y.Z-SNAPSHOT + g) commit & push changes + +3. establish backward compatibility tests for the previous version + a) add new version at the end of atrium-bc-test/build.gradle + b) commit & push changes */ From f6c7d0335896838d0ecdcbc296eedc3f300145f9 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 8 Feb 2020 14:56:04 +0100 Subject: [PATCH 037/142] v0.9.2 --- .github/CONTRIBUTING.md | 2 +- README.md | 235 ++++++++++++++++++----------------- apis/differences.md | 8 +- misc/maven/example-pom.xml | 2 +- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 6 files changed, 131 insertions(+), 124 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9577075ee..a8c1fe5e9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/master/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/v0.9.2/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index 76bff6fc6..2a9aa8df8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ + + + +[![Download](https://img.shields.io/badge/Download-0.9.2-%23007ec6)](https://bintray.com/robstoll/tutteli-jars/atrium/0.9.2 "Download 0.9.2 from Bintray") +[![EUPL](https://img.shields.io/badge/%E2%9A%96-EUPL%201.2-%230b45a6)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-11-12 "License") +[![atrium @ kotlinlang.slack.com](https://img.shields.io/static/v1?label=kotlinlang&message=atrium&color=blue&logo=slack)](https://kotlinlang.slack.com/messages/C887ZKGCQ "See invitation link under section FAQ") [![Newcomers Welcome](https://img.shields.io/badge/%F0%9F%91%8B-Newcomers%20Welcome-blueviolet)](https://github.com/robstoll/atrium/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 "Ask in slack for help") # Atrium @@ -20,12 +28,11 @@ Atrium currently provides two [API Styles](#api-styles): pure fluent and infix where both of them have their design focus on usability in conjunction with code completion functionality provided by your IDE. See [Examples](#examples) below to get a feel for how you could benefit from Atrium. ----- + **Table of Content** - [Installation](#installation) @@ -79,7 +86,7 @@ but can also be retrieved directly from [bintray](https://bintray.com/robstoll/t *gradle*: ``` buildscript { - ext { atrium_version='0.9.0' } + ext { atrium_version='0.9.2' } } repositories { mavenCentral() @@ -110,7 +117,7 @@ dependencies {

click to see how the setup for the infix API looks like -The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.9.0. +The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.9.2. [Your help](https://github.com/robstoll/atrium/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22good+first+issue%22++new+infix) in bringing the new infix API forward is appreciated. @@ -135,9 +142,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/v0.9.2/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/v0.9.2/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -147,7 +154,7 @@ That is all, you are all set. Jump to [Examples](#examples) which shows how to u ``` buildscript { - ext { atrium_version='0.9.0' } + ext { atrium_version='0.9.2' } } repositories { mavenCentral() @@ -166,24 +173,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/master/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/master/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/v0.9.2/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/v0.9.2/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/master/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/v0.9.2/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -200,7 +207,7 @@ dependencies { click to see how the setup for the infix API looks like -The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.9.0. +The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.9.2. [Your help](https://github.com/robstoll/atrium/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22good+first+issue%22++new+infix) in bringing the new infix API forward is appreciated. @@ -241,11 +248,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.2/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -260,7 +267,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -273,7 +280,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -302,7 +309,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -334,7 +341,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -365,7 +372,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -400,7 +407,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -420,7 +427,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -443,7 +450,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -463,7 +470,7 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1 Notice that stacks are filtered so that you only see what is of interest. Filtering can be configured via [`ReporterBuilder`](#reporterbuilder) by choosing an appropriate -[AtriumErrorAdjuster](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). +[AtriumErrorAdjuster](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). Stack frames of Atrium and of test runners (Spek, Kotlintest and JUnit for JVM, mocha for JS) are excluded per default. [Create a Feature Request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]) in case you use a different runner, we can add yours to the list as well. @@ -496,7 +503,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -548,7 +555,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -598,7 +605,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -628,7 +635,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)
@@ -650,7 +657,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -696,7 +703,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -782,7 +789,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -803,7 +810,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -831,7 +838,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -844,7 +851,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -864,7 +871,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -880,7 +887,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -915,7 +922,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -934,7 +941,7 @@ This is reflected in the output, which tells us that we expected that the `numbe Exactly, what about the expected value `2`, why do we not see anything about it in the output? The output does not show anything about the expected value `2` because the predefined assertion verbs have configured [`ReporterBuilder`](#reporterbuilder) -to use an [Only Failure Reporter](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) +to use an [Only Failure Reporter](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) which shows us only assertions (or sub assertions) which failed. Back to the shortcut functions. @@ -955,7 +962,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -994,7 +1001,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1010,7 +1017,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1028,7 +1035,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1057,7 +1064,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1107,7 +1114,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1131,7 +1138,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1147,7 +1154,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1167,7 +1174,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1189,7 +1196,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1215,7 +1222,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1246,7 +1253,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1265,7 +1272,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1301,7 +1308,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1325,7 +1332,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) `isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry`. There are more assertion functions, a full list can be found in -[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). +[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). In case you should miss an assertion function, then please [open a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]). @@ -1342,7 +1349,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1357,7 +1364,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1379,7 +1386,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1416,7 +1423,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1450,7 +1457,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1490,7 +1497,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1508,11 +1515,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.2/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/master/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/v0.9.2/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1546,7 +1553,7 @@ We try to provide a workaround whenever possible._ There is, but IntelliJ will not show it to you due to [this bug](https://youtrack.jetbrains.com/issue/KT-24836) (please upvote it). You should be able to see the KDoc of other functions without problems. -But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). +But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). @@ -1619,7 +1626,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1661,7 +1668,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1678,7 +1685,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1754,7 +1761,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1769,9 +1776,9 @@ Let us see how we actually defined `isMultipleOf`. the assertion to itself (creating alone is not enough, it needs to be added in order that it is evaluated). The method `createAndAddAssertion` returns itself (the same `Expect`) making it easy for you to provide a fluent API as well. - The method [createAndAddAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) + The method [createAndAddAssertion](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) expects: - - a either a `String` or a [Translatable](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) + - a either a `String` or a [Translatable](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) as description of your assertion. - the representation of the expected value. - and the actual check as lambda where you typically use `it` which refers to the subject of the assertion. @@ -1794,7 +1801,7 @@ fun Expect.isEven() = ``` -We are using a [RawString](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) +We are using a [RawString](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) here so that `"an even number"` is not treated as a `String` in reporting. Its usage looks then as follows: @@ -1803,7 +1810,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1902,7 +1909,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1934,7 +1941,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1975,7 +1982,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2036,7 +2043,7 @@ fun >> Expect.sameInitialsAs( There are a few additional methods which you can call after `mapArguments`. -See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). +See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). In case you want to provide your own implementation it suffices to create an extension function for `ArgumentMapperBuilder`. @@ -2046,21 +2053,21 @@ extension function for `ArgumentMapperBuilder`. Yet, sometimes we would like to create functions which have a better error reporting than the one we get when we compose assertion functions. -[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) is the entry point in this case. Its a builder and thus lets you find the functions you need via code completion. Following a quick overview what it provides: - all assertion functions on the domain level (what you have seen in [Compose-assertion-functions](#compose-assertion-functions) was the API level) so that you can reuse and compose them in other ways. -- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). +- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/master/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2072,7 +2079,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/master/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/v0.9.2/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2086,7 +2093,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/master/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/v0.9.2/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2127,7 +2134,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2159,8 +2166,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/v0.9.2/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2190,24 +2197,24 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
💬 Using a TranslationSupplier Next to providing translations via code you can also use a -[TranslationSupplier](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) -based [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) +[TranslationSupplier](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) +based [Translator](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) by configuring the [`ReporterBuilder`](#reporterbuilder) accordingly (e.g. use `withDefaultTranslationSupplier` instead of `withoutTranslations`). Atrium supports a properties files based `TranslationSupplier` for JVM (a supplier for JS will follow) which is more or less what [ResourceBundle](https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html) provides out of the box. Yet, a `Translator` uses a more enhanced fallback mechanism compared to a `ResourceBundle`. -For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). +For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). Notice though, that we plan to move away from the `ResourceBundle`-inspired approach due to enconding problems and missing implementations on other platforms than JVM. @@ -2266,15 +2273,15 @@ fun _isMultipleOf(container: Expect, base: Int): Assertion = Notice that the impl-function is not an extension function as before because we do not want to pollute the API of `Expect` with this function. -In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) +In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) (`createAndAddAssertion` does the same under the hood) with a test which defines whether the assertion holds as well as a description (`IS_MULTIPLE_OF`) and a representation (`base`). -[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) helps you in writing own assertion functions. We suggest you use it as entry point (rather than memorizing different class names), it guides you to existing assertion function implementations for different types -as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) +as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) which in turn helps you with creating assertions. In the API module we define the extension function and call the impl-function: @@ -2326,17 +2333,17 @@ Both have their design focus on interoperability with code completion functional -- so that you can let your IDE do some of the work. Atrium is -[built up by different modules](https://docs.atriumlib.org/latest#/doc/) +[built up by different modules](https://docs.atriumlib.org/0.9.2/doc/) and it is your choice which implementation you want to use. However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.2/apis/differences.md) for more information and to see how the API styles differ. @@ -2351,15 +2358,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2413,13 +2420,13 @@ expect(sequenceOf(1, 2, 3)).feature { f(it::asIterable) }.contains(2) ## Where do I find a list of all available functions? Atrium provides KDoc for all APIs - have a look at their KDoc: -- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) -- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) Deprecated APIs: -- [atrium-api-cc-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-api-cc-en_UK](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) -- [atrium-api-cc-de_CH](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) +- [atrium-api-cc-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-api-cc-en_UK](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) +- [atrium-api-cc-de_CH](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) ## Problems in conjunction with `feature` @@ -2498,7 +2505,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/master/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/v0.9.2/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 1663e47f6..6104959af 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,14 +14,14 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/0.9.2/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) +- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.2/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/v0.9.2/README.md#installation) for the rest): ``` dependencies { diff --git a/misc/maven/example-pom.xml b/misc/maven/example-pom.xml index bff9e0ae4..b1abbf6fc 100644 --- a/misc/maven/example-pom.xml +++ b/misc/maven/example-pom.xml @@ -5,7 +5,7 @@ com.example.artifactId - v0.9.0 + 0.9.2 diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 888ac9bb2..1d64fa77a 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index 35fcd84a6..01c692242 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From c43e420a8468821f414f2f1d968d84f6f6988b94 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 9 Feb 2020 14:50:43 +0100 Subject: [PATCH 038/142] update Atrium version in samples --- samples/js/jasmine/build.gradle | 2 +- samples/js/mocha/build.gradle | 2 +- samples/jvm/junit5/build.gradle | 2 +- samples/jvm/spek/build.gradle | 2 +- samples/multiplatform/build.gradle | 12 ++++++------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/js/jasmine/build.gradle b/samples/js/jasmine/build.gradle index 87f76ecae..376ab9b1c 100644 --- a/samples/js/jasmine/build.gradle +++ b/samples/js/jasmine/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { atrium_api = 'atrium-fluent-en_GB-js' - atrium_version = '0.9.0' + atrium_version = '0.9.2' } repositories { maven { url "https://plugins.gradle.org/m2/" } diff --git a/samples/js/mocha/build.gradle b/samples/js/mocha/build.gradle index 0699c5163..ff8e2c105 100644 --- a/samples/js/mocha/build.gradle +++ b/samples/js/mocha/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { atrium_api = 'atrium-fluent-en_GB-js' - atrium_version = '0.9.0' + atrium_version = '0.9.2' } repositories { maven { url "https://plugins.gradle.org/m2/" } diff --git a/samples/jvm/junit5/build.gradle b/samples/jvm/junit5/build.gradle index e9622e9a9..ed0fdcc3f 100644 --- a/samples/jvm/junit5/build.gradle +++ b/samples/jvm/junit5/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { kotlin_version= '1.3.41' atrium_api= 'atrium-fluent-en_GB' - atrium_version='0.9.0' + atrium_version='0.9.2' junit_version= '5.3.1' } diff --git a/samples/jvm/spek/build.gradle b/samples/jvm/spek/build.gradle index a6244603c..1b6b5d369 100644 --- a/samples/jvm/spek/build.gradle +++ b/samples/jvm/spek/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { kotlin_version = '1.3.41' spek_version = '2.0.0' - atrium_version='0.9.0' + atrium_version='0.9.2' } repositories { diff --git a/samples/multiplatform/build.gradle b/samples/multiplatform/build.gradle index 7b4a3fd61..02196e329 100644 --- a/samples/multiplatform/build.gradle +++ b/samples/multiplatform/build.gradle @@ -10,31 +10,31 @@ version '0.0.1' apply plugin: 'maven-publish' kotlin { + def atrium_version = '0.9.2' jvm() js { - nodejs { - } + nodejs {} } sourceSets { commonTest { dependencies { implementation kotlin('test-common') implementation kotlin('test-annotations-common') - implementation('ch.tutteli.atrium:atrium-fluent-en_GB-common:0.9.1') + implementation 'ch.tutteli.atrium:atrium-fluent-en_GB-common:$atrium_version' } } jvmTest { dependencies { implementation kotlin('test') implementation kotlin('test-junit') - implementation("org.junit.jupiter:junit-jupiter-api:5.3.1") - implementation("ch.tutteli.atrium:atrium-fluent-en_GB:0.9.1") + implementation "org.junit.jupiter:junit-jupiter-api:5.3.1" + implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atrium_version" } } jsTest { dependencies { implementation kotlin('test-js') - implementation("ch.tutteli.atrium:atrium-fluent-en_GB-js:0.9.1") + implementation "ch.tutteli.atrium:atrium-fluent-en_GB-js:$atrium_version" } } } From cb44bb9297655ae7bbcfb8f0fe78f4b45c72f9b1 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 9 Feb 2020 14:53:48 +0100 Subject: [PATCH 039/142] prepare next dev cycle --- .github/CONTRIBUTING.md | 2 +- README.md | 222 ++++++++++++++++++----------------- apis/differences.md | 8 +- build.gradle | 8 +- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 6 files changed, 125 insertions(+), 123 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a8c1fe5e9..9577075ee 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/v0.9.2/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/master/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index 2a9aa8df8..97df60b3b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - + + # Atrium Atrium is an open-source multiplatform assertion library for Kotlin with support for JVM, JS and Android. @@ -28,11 +30,11 @@ Atrium currently provides two [API Styles](#api-styles): pure fluent and infix where both of them have their design focus on usability in conjunction with code completion functionality provided by your IDE. See [Examples](#examples) below to get a feel for how you could benefit from Atrium. - +For instance, the [README of v0.9.2](https://github.com/robstoll/atrium/tree/master/README.md). +---- **Table of Content** - [Installation](#installation) @@ -142,9 +144,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/v0.9.2/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/v0.9.2/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -173,24 +175,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/master/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/v0.9.2/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/master/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/v0.9.2/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/v0.9.2/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/master/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -248,11 +250,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.2/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -267,7 +269,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -280,7 +282,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -309,7 +311,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -341,7 +343,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -372,7 +374,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -407,7 +409,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -427,7 +429,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -450,7 +452,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -470,7 +472,7 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1 Notice that stacks are filtered so that you only see what is of interest. Filtering can be configured via [`ReporterBuilder`](#reporterbuilder) by choosing an appropriate -[AtriumErrorAdjuster](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). +[AtriumErrorAdjuster](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). Stack frames of Atrium and of test runners (Spek, Kotlintest and JUnit for JVM, mocha for JS) are excluded per default. [Create a Feature Request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]) in case you use a different runner, we can add yours to the list as well. @@ -503,7 +505,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -555,7 +557,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -605,7 +607,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -635,7 +637,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)
@@ -657,7 +659,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -703,7 +705,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -789,7 +791,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -810,7 +812,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -838,7 +840,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -851,7 +853,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -871,7 +873,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -887,7 +889,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -922,7 +924,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -941,7 +943,7 @@ This is reflected in the output, which tells us that we expected that the `numbe Exactly, what about the expected value `2`, why do we not see anything about it in the output? The output does not show anything about the expected value `2` because the predefined assertion verbs have configured [`ReporterBuilder`](#reporterbuilder) -to use an [Only Failure Reporter](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) +to use an [Only Failure Reporter](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) which shows us only assertions (or sub assertions) which failed. Back to the shortcut functions. @@ -962,7 +964,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1001,7 +1003,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1017,7 +1019,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1035,7 +1037,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1064,7 +1066,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1114,7 +1116,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1138,7 +1140,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1154,7 +1156,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1174,7 +1176,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1196,7 +1198,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1222,7 +1224,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1253,7 +1255,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1272,7 +1274,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1308,7 +1310,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1332,7 +1334,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) `isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry`. There are more assertion functions, a full list can be found in -[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). +[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). In case you should miss an assertion function, then please [open a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]). @@ -1349,7 +1351,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1364,7 +1366,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1386,7 +1388,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1423,7 +1425,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1457,7 +1459,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1497,7 +1499,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1515,11 +1517,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.2/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/v0.9.2/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/master/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1553,7 +1555,7 @@ We try to provide a workaround whenever possible._ There is, but IntelliJ will not show it to you due to [this bug](https://youtrack.jetbrains.com/issue/KT-24836) (please upvote it). You should be able to see the KDoc of other functions without problems. -But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). +But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). @@ -1626,7 +1628,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1668,7 +1670,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1685,7 +1687,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1761,7 +1763,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1776,9 +1778,9 @@ Let us see how we actually defined `isMultipleOf`. the assertion to itself (creating alone is not enough, it needs to be added in order that it is evaluated). The method `createAndAddAssertion` returns itself (the same `Expect`) making it easy for you to provide a fluent API as well. - The method [createAndAddAssertion](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) + The method [createAndAddAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) expects: - - a either a `String` or a [Translatable](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) + - a either a `String` or a [Translatable](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) as description of your assertion. - the representation of the expected value. - and the actual check as lambda where you typically use `it` which refers to the subject of the assertion. @@ -1801,7 +1803,7 @@ fun Expect.isEven() = ``` -We are using a [RawString](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) +We are using a [RawString](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) here so that `"an even number"` is not treated as a `String` in reporting. Its usage looks then as follows: @@ -1810,7 +1812,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1909,7 +1911,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1941,7 +1943,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1982,7 +1984,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.9.2/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2043,7 +2045,7 @@ fun >> Expect.sameInitialsAs( There are a few additional methods which you can call after `mapArguments`. -See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). +See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). In case you want to provide your own implementation it suffices to create an extension function for `ArgumentMapperBuilder`. @@ -2053,21 +2055,21 @@ extension function for `ArgumentMapperBuilder`. Yet, sometimes we would like to create functions which have a better error reporting than the one we get when we compose assertion functions. -[`ExpectImpl`](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) is the entry point in this case. Its a builder and thus lets you find the functions you need via code completion. Following a quick overview what it provides: - all assertion functions on the domain level (what you have seen in [Compose-assertion-functions](#compose-assertion-functions) was the API level) so that you can reuse and compose them in other ways. -- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). +- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/master/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/v0.9.2/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2079,7 +2081,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/v0.9.2/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/master/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2093,7 +2095,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/v0.9.2/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/master/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2134,7 +2136,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2166,8 +2168,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/v0.9.2/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2197,24 +2199,24 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
💬 Using a TranslationSupplier Next to providing translations via code you can also use a -[TranslationSupplier](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) -based [Translator](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) +[TranslationSupplier](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) +based [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) by configuring the [`ReporterBuilder`](#reporterbuilder) accordingly (e.g. use `withDefaultTranslationSupplier` instead of `withoutTranslations`). Atrium supports a properties files based `TranslationSupplier` for JVM (a supplier for JS will follow) which is more or less what [ResourceBundle](https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html) provides out of the box. Yet, a `Translator` uses a more enhanced fallback mechanism compared to a `ResourceBundle`. -For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). +For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). Notice though, that we plan to move away from the `ResourceBundle`-inspired approach due to enconding problems and missing implementations on other platforms than JVM. @@ -2273,15 +2275,15 @@ fun _isMultipleOf(container: Expect, base: Int): Assertion = Notice that the impl-function is not an extension function as before because we do not want to pollute the API of `Expect` with this function. -In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) +In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) (`createAndAddAssertion` does the same under the hood) with a test which defines whether the assertion holds as well as a description (`IS_MULTIPLE_OF`) and a representation (`base`). -[`ExpectImpl`](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) helps you in writing own assertion functions. We suggest you use it as entry point (rather than memorizing different class names), it guides you to existing assertion function implementations for different types -as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) +as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) which in turn helps you with creating assertions. In the API module we define the extension function and call the impl-function: @@ -2333,17 +2335,17 @@ Both have their design focus on interoperability with code completion functional -- so that you can let your IDE do some of the work. Atrium is -[built up by different modules](https://docs.atriumlib.org/0.9.2/doc/) +[built up by different modules](https://docs.atriumlib.org/latest#/doc/) and it is your choice which implementation you want to use. However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.9.2/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.9.2/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for more information and to see how the API styles differ. @@ -2358,15 +2360,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/v0.9.2/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2420,13 +2422,13 @@ expect(sequenceOf(1, 2, 3)).feature { f(it::asIterable) }.contains(2) ## Where do I find a list of all available functions? Atrium provides KDoc for all APIs - have a look at their KDoc: -- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) -- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) Deprecated APIs: -- [atrium-api-cc-en_GB](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-api-cc-en_UK](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) -- [atrium-api-cc-de_CH](https://docs.atriumlib.org/0.9.2/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) +- [atrium-api-cc-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-api-cc-en_UK](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) +- [atrium-api-cc-de_CH](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) ## Problems in conjunction with `feature` @@ -2505,7 +2507,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/v0.9.2/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/master/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 6104959af..1663e47f6 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,14 +14,14 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/0.9.2/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.2/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/0.9.2/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) +- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/v0.9.2/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) for the rest): ``` dependencies { diff --git a/build.gradle b/build.gradle index 27e4d4dc0..e43795e6e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - rootProject.version = '0.9.2' + rootProject.version = '0.10.0-SNAPSHOT' rootProject.group = 'ch.tutteli.atrium' def sampleProjectsFun = subprojects.findAll { @@ -555,11 +555,11 @@ Prepare next dev cycle b) commit & push changes 2. update master: - a) search for `tree/vX.Y.Z` and replace it with `tree/master` - b) search for `X.Y.Z/doc` and replace with `latest#/doc` + a) search for `tree/vX.Y.Z` in all .md files and replace it with `tree/master` + b) search for `X.Y.Z/doc` in all .md files and replace with `latest#/doc` c) use the master badges in README (uncomment them in README and comment out release badges) d) uncomment the warning about taking a sneak peek in README - e) update version in the warning to X.Y.Z and update the link as well + e) update version in the warning to X.Y.Z and update the link as well (if not already correct) f) change rootProject.version in build.gradle to X.Y.Z-SNAPSHOT g) commit & push changes diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 1d64fa77a..888ac9bb2 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index 01c692242..35fcd84a6 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.9.2/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From 0cce6c25a8866f7c77140057acda41bc8adad205 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 9 Feb 2020 15:25:43 +0100 Subject: [PATCH 040/142] fix dependency in mpp sample --- samples/multiplatform/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/multiplatform/build.gradle b/samples/multiplatform/build.gradle index 02196e329..42f888f8d 100644 --- a/samples/multiplatform/build.gradle +++ b/samples/multiplatform/build.gradle @@ -20,7 +20,7 @@ kotlin { dependencies { implementation kotlin('test-common') implementation kotlin('test-annotations-common') - implementation 'ch.tutteli.atrium:atrium-fluent-en_GB-common:$atrium_version' + implementation "ch.tutteli.atrium:atrium-fluent-en_GB-common:$atrium_version" } } jvmTest { From ed7f51e4aab755d3e4733ed1f9b9c2065da77636 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 9 Feb 2020 15:26:16 +0100 Subject: [PATCH 041/142] add github workflow to check gradle jar --- .github/workflows/validate-gradle-wrapper.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/validate-gradle-wrapper.yml diff --git a/.github/workflows/validate-gradle-wrapper.yml b/.github/workflows/validate-gradle-wrapper.yml new file mode 100644 index 000000000..cbf839cf4 --- /dev/null +++ b/.github/workflows/validate-gradle-wrapper.yml @@ -0,0 +1,10 @@ +name: "Validate Gradle Wrapper" +on: [push, pull_request] + +jobs: + validation: + name: "Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 From 25c0e5b7760588463858b11e5202cecdf89e52fb Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Mon, 10 Feb 2020 06:36:03 +0100 Subject: [PATCH 042/142] use 0.9.2 in bc-test --- misc/tools/atrium-bc-test/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/tools/atrium-bc-test/build.gradle b/misc/tools/atrium-bc-test/build.gradle index 30f01ab2d..df1da500a 100644 --- a/misc/tools/atrium-bc-test/build.gradle +++ b/misc/tools/atrium-bc-test/build.gradle @@ -369,8 +369,8 @@ createBcAndBbcTasksForApis('0.8.0', ')', 'cc-de_CH', 'cc-en_GB', 'cc-infix-en_GB' ) -createBcAndBbcTasksForApis('0.9.1', - 'forgive=^.* assertion function can be used in an AssertionGroup with an ExplanatoryAssertionGroupType.*$', +createBcAndBbcTasksForApis('0.9.2', + 'forgive=^$', 'fluent-en_GB' ) //@formatter:on From 8c096e76e204f9d65c22786e9f279971dbc988aa Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Mon, 10 Feb 2020 13:50:43 -0500 Subject: [PATCH 043/142] add zonedDateTimeAssertions for thew new infix API (#319) Followed intructions from the issue: * copy and adjust the file zonedDateTimeAssertions.kt from atrium-api-fluent-en_GB-jdk8-jvm to atrium-api-infix-en_GB-jdk8-jvm * uncomment `exports ch.tutteli.atrium.api.infix.en_GB.jdk8` in module-info.java * (not mentioned in the issue): changed the `@sinse` from 0.9.0 to 0.10.0 as this change will only be available in 0.10.0 --- .../en_GB/jdk8/zonedDateTimeAssertions.kt | 104 ++++++++++++++++++ .../src/module/module-info.java | 2 +- .../ZonedDateTimeFeatureAssertionsSpec.kt | 36 ++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ZonedDateTimeFeatureAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt new file mode 100644 index 000000000..ed8a39883 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt @@ -0,0 +1,104 @@ +@file:Suppress( + "FINAL_UPPER_BOUND" /* remove once https://youtrack.jetbrains.com/issue/KT-34257 is fixed */, + "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */ +) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.zonedDateTime +import java.time.DayOfWeek +import java.time.ZonedDateTime + +/** + * Creates an [Expect] for the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.year: Expect + get() = ExpectImpl.zonedDateTime.year(this).getExpectOfFeature() + +/** + * Expects that the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.zonedDateTime.year(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] + * of the subject of the assertion, so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.month: Expect + get() = ExpectImpl.zonedDateTime.month(this).getExpectOfFeature() + +/** + * Expects that the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.zonedDateTime.month(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] + * of the subject of the assertion, so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.dayOfWeek: Expect + get() = ExpectImpl.zonedDateTime.dayOfWeek(this).getExpectOfFeature() + +/** + * Expects that the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.zonedDateTime.dayOfWeek(this).addToInitial(assertionCreator) + +/** + * Creates an [Expect] for the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] + * of the subject of the assertion, so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * + * @since 0.10.0 + */ +val Expect.day: Expect + get() = ExpectImpl.zonedDateTime.day(this).getExpectOfFeature() + +/** + * Expects that the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.zonedDateTime.day(this).addToInitial(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java index f583f55a2..20b5852f8 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java @@ -5,5 +5,5 @@ module ch.tutteli.atrium.api.infix.en_GB.jdk8 { requires kotlin.stdlib; requires java.base; -// exports ch.tutteli.atrium.api.infix.en_GB.jdk8; + exports ch.tutteli.atrium.api.infix.en_GB.jdk8; } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ZonedDateTimeFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ZonedDateTimeFeatureAssertionsSpec.kt new file mode 100644 index 000000000..ba168a1ab --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ZonedDateTimeFeatureAssertionsSpec.kt @@ -0,0 +1,36 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.property +import java.time.DayOfWeek +import java.time.ZonedDateTime + +class ZonedDateTimeFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ZonedDateTimeFeatureAssertionsSpec( + property(Expect::year), + fun1.() -> Unit>(Expect::year), + property(Expect::month), + fun1.() -> Unit>(Expect::month), + property(Expect::day), + fun1.() -> Unit>(Expect::day), + property(Expect::dayOfWeek), + fun1.() -> Unit>(Expect::dayOfWeek) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect = notImplemented() + + a1.year + a1 = a1 year { } + + a1.month + a1 = a1 month { } + + a1.dayOfWeek + a1 = a1 dayOfWeek { } + + a1.day + a1 = a1 day { } + } +} From 9fd1f7489c92fe7af27dc18b52ca759ff15546f9 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Mon, 10 Feb 2020 23:17:06 +0100 Subject: [PATCH 044/142] fix take a sneak peak banner --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 97df60b3b..2109f31de 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ See [Examples](#examples) below to get a feel for how you could benefit from Atr ❗ You are taking a *sneak peek* at the next version. Please have a look at the README of the git tag in case you are looking for the documentation of the corresponding version. For instance, the [README of v0.9.2](https://github.com/robstoll/atrium/tree/master/README.md). + ---- **Table of Content** From f0c52ebad055461385d6b3846319bd74e73333a2 Mon Sep 17 00:00:00 2001 From: name213 Date: Mon, 10 Feb 2020 23:19:47 +0100 Subject: [PATCH 045/142] #313 migrate chronoLocalDateAssertions for infix api --- .../en_GB/jdk8/chronoLocalDateAssertions.kt | 69 +++++++++++++++++++ .../jdk8/ChronoLocalDateAssertionsSpec.kt | 59 ++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt new file mode 100644 index 000000000..e6096b11e --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt @@ -0,0 +1,69 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.chronoLocalDate +import java.time.chrono.ChronoLocalDate + +/** + * Expects that the subject of the assertion (a [ChronoLocalDate]) + * is before the [expected] [ChronoLocalDate]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.9.0 + */ +infix fun Expect.isBefore(expected: ChronoLocalDate): Expect = + addAssertion(ExpectImpl.chronoLocalDate.isBefore(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDate]) + * is before or equal the [expected] [ChronoLocalDate]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.9.0 + */ +infix fun Expect.isBeforeOrEqual(expected: ChronoLocalDate): Expect = + addAssertion(ExpectImpl.chronoLocalDate.isBeforeOrEquals(this, expected)) + + +/** + * Expects that the subject of the assertion (a [ChronoLocalDate]) + * is after the [expected] [ChronoLocalDate]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.9.0 + */ +infix fun Expect.isAfter(expected: ChronoLocalDate): Expect = + addAssertion(ExpectImpl.chronoLocalDate.isAfter(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDate]) + * is after or equal the [expected] [ChronoLocalDate]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.9.0 + */ +infix fun Expect.isAfterOrEqual(expected: ChronoLocalDate): Expect = + addAssertion(ExpectImpl.chronoLocalDate.isAfterOrEquals(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDate]) + * is equal to the [expected] [ChronoLocalDate]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.9.0 + */ +infix fun Expect.isEqual(expected: ChronoLocalDate): Expect = + addAssertion(ExpectImpl.chronoLocalDate.isEqual(this, expected)) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt new file mode 100644 index 000000000..13a3944bc --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt @@ -0,0 +1,59 @@ +package kotlin.ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import java.time.LocalDate +import java.time.chrono.ChronoLocalDate +import java.time.chrono.JapaneseDate + +class ChronoLocalDateAssertionsSpec : ch.tutteli.atrium.specs.integration.ChronoLocalDateAssertionSpec( + fun1(Expect::isBefore), + fun1(Expect::isBeforeOrEqual), + fun1(Expect::isAfter), + fun1(Expect::isAfterOrEqual), + fun1(Expect::isEqual) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val chronoLocalDate: ChronoLocalDate = notImplemented() + var a1: Expect = notImplemented() + var a2: Expect = notImplemented() + + a1 = a1 isBefore LocalDate.now() + a1 = a1 isBeforeOrEqual LocalDate.now() + a1 = a1 isAfter LocalDate.now() + a1 = a1 isAfterOrEqual LocalDate.now() + a1 = a1 isEqual LocalDate.now() + + a2 = a2 isBefore LocalDate.now() + a2 = a2 isBeforeOrEqual LocalDate.now() + a2 = a2 isAfter LocalDate.now() + a2 = a2 isAfterOrEqual LocalDate.now() + a2 = a2 isEqual LocalDate.now() + + a1 = a1 isBefore JapaneseDate.now() + a1 = a1 isBeforeOrEqual JapaneseDate.now() + a1 = a1 isAfter JapaneseDate.now() + a1 = a1 isAfterOrEqual JapaneseDate.now() + a1 = a1 isEqual JapaneseDate.now() + + a2 = a2 isBefore JapaneseDate.now() + a2 = a2 isBeforeOrEqual JapaneseDate.now() + a2 = a2 isAfter JapaneseDate.now() + a2 = a2 isAfterOrEqual JapaneseDate.now() + a2 = a2 isEqual JapaneseDate.now() + + a1 = a1 isBefore chronoLocalDate + a1 = a1 isBeforeOrEqual chronoLocalDate + a1 = a1 isAfter chronoLocalDate + a1 = a1 isAfterOrEqual chronoLocalDate + a1 = a1 isEqual chronoLocalDate + + a2 = a2 isBefore chronoLocalDate + a2 = a2 isBeforeOrEqual chronoLocalDate + a2 = a2 isAfter chronoLocalDate + a2 = a2 isAfterOrEqual chronoLocalDate + a2 = a2 isEqual chronoLocalDate + } +} From 1fb77974c6da7f561050054482e206db88d4a595 Mon Sep 17 00:00:00 2001 From: name213 Date: Mon, 10 Feb 2020 23:21:50 +0100 Subject: [PATCH 046/142] #313 change since 0.9.0 to 0.10.0 --- .../api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt index e6096b11e..fe516e8fe 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt @@ -14,7 +14,7 @@ import java.time.chrono.ChronoLocalDate * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.9.0 + * @since 0.10.0 */ infix fun Expect.isBefore(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isBefore(this, expected)) @@ -26,7 +26,7 @@ infix fun Expect.isBefore(expected: ChronoLocalDate): E * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.9.0 + * @since 0.10.0 */ infix fun Expect.isBeforeOrEqual(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isBeforeOrEquals(this, expected)) @@ -39,7 +39,7 @@ infix fun Expect.isBeforeOrEqual(expected: ChronoLocalD * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.9.0 + * @since 0.10.0 */ infix fun Expect.isAfter(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isAfter(this, expected)) @@ -51,7 +51,7 @@ infix fun Expect.isAfter(expected: ChronoLocalDate): Ex * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.9.0 + * @since 0.10.0 */ infix fun Expect.isAfterOrEqual(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isAfterOrEquals(this, expected)) @@ -63,7 +63,7 @@ infix fun Expect.isAfterOrEqual(expected: ChronoLocalDa * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.9.0 + * @since 0.10.0 */ infix fun Expect.isEqual(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isEqual(this, expected)) From a5efbc17c0d537b486ef4264d88bbb0bbe87039b Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Thu, 13 Feb 2020 10:47:13 -0500 Subject: [PATCH 047/142] add chronoZonedDateTimeAssertions for thew new infix API (#315) Followed intructions from the issue: * copy and adjust the file chronoZonedDateTimeAssertions.kt from atrium-api-fluent-en_GB-jdk8-jvm to atrium-api-infix-en_GB-jdk8-jvm * module-info.java already had uncommented `exports ch.tutteli.atrium.api.infix.en_GB.jdk8` * change `@sinse` from 0.9.0 to 0.10.0 * copy the ChronoZonedDateTimeAssertionSpec.kt from atrium-api-fluent-en_GB-jdk8-jvm to atrium-api-infix-en_GB-jdk8-jvm (the description incorrectly said "ChronoZonedDateTimeAssertion_s_Spec.kt" with an "s") --- .../jdk8/chronoZonedDateTimeAssertions.kt | 69 +++++++++++++++++ .../jdk8/ChronoZonedDateTimeAssertionSpec.kt | 76 +++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt new file mode 100644 index 000000000..9ca7fddb0 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt @@ -0,0 +1,69 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.chronoZonedDateTime +import java.time.chrono.ChronoLocalDate +import java.time.chrono.ChronoZonedDateTime + +/** + * Expects that the subject of the assertion (a [ChronoZonedDateTime]) + * is before the [expected] [ChronoZonedDateTime]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun > Expect.isBefore(expected: ChronoZonedDateTime<*>): Expect = + addAssertion(ExpectImpl.chronoZonedDateTime.isBefore(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoZonedDateTime]) + * is before or equals the [expected] [ChronoZonedDateTime]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun > Expect.isBeforeOrEqual(expected: ChronoZonedDateTime<*>): Expect = + addAssertion(ExpectImpl.chronoZonedDateTime.isBeforeOrEqual(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoZonedDateTime]) + * is after the [expected] [ChronoZonedDateTime]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun > Expect.isAfter(expected: ChronoZonedDateTime<*>): Expect = + addAssertion(ExpectImpl.chronoZonedDateTime.isAfter(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoZonedDateTime]) + * is after or equal the [expected] [ChronoZonedDateTime]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun > Expect.isAfterOrEqual(expected: ChronoZonedDateTime<*>): Expect = + addAssertion(ExpectImpl.chronoZonedDateTime.isAfterOrEqual(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoZonedDateTime]) + * is equal to the [expected] [ChronoZonedDateTime]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun > Expect.isEqual(expected: ChronoZonedDateTime<*>): Expect = + addAssertion(ExpectImpl.chronoZonedDateTime.isEqual(this, expected)) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt new file mode 100644 index 000000000..37f1b9e32 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt @@ -0,0 +1,76 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import java.time.LocalDate +import java.time.ZonedDateTime +import java.time.chrono.ChronoLocalDate +import java.time.chrono.ChronoZonedDateTime + +class ChronoZonedDateTimeAssertionSpec : ch.tutteli.atrium.specs.integration.ChronoZonedDateTimeAssertionSpec( + fun1(Expect>::isBefore), + fun1(Expect>::isBeforeOrEqual), + fun1(Expect>::isAfter), + fun1(Expect>::isAfterOrEqual), + fun1(Expect>::isEqual) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val chronoZonedDateTime: ChronoZonedDateTime<*> = notImplemented() + var a1: Expect> = notImplemented() + var a2: Expect> = notImplemented() + var a3: Expect> = notImplemented() + var a4: Expect = notImplemented() + + + a1 =a1 isBefore ZonedDateTime.now() + a1 =a1 isBeforeOrEqual ZonedDateTime.now() + a1 =a1 isAfter ZonedDateTime.now() + a1 =a1 isAfterOrEqual ZonedDateTime.now() + a1 =a1 isEqual ZonedDateTime.now() + + a2 =a2 isBefore ZonedDateTime.now() + a2 =a2 isBeforeOrEqual ZonedDateTime.now() + a2 =a2 isAfter ZonedDateTime.now() + a2 =a2 isAfterOrEqual ZonedDateTime.now() + a2 =a2 isEqual ZonedDateTime.now() + + a3 =a3 isBefore ZonedDateTime.now() + a3 =a3 isBeforeOrEqual ZonedDateTime.now() + a3 =a3 isAfter ZonedDateTime.now() + a3 =a3 isAfterOrEqual ZonedDateTime.now() + a3 =a3 isEqual ZonedDateTime.now() + + a4 =a4 isBefore ZonedDateTime.now() + a4 =a4 isBeforeOrEqual ZonedDateTime.now() + a4 =a4 isAfter ZonedDateTime.now() + a4 =a4 isAfterOrEqual ZonedDateTime.now() + a4 =a4 isEqual ZonedDateTime.now() + + + a1 =a1 isBefore chronoZonedDateTime + a1 =a1 isBeforeOrEqual chronoZonedDateTime + a1 =a1 isAfter chronoZonedDateTime + a1 =a1 isAfterOrEqual chronoZonedDateTime + a1 =a1 isEqual chronoZonedDateTime + + a2 =a2 isBefore chronoZonedDateTime + a2 =a2 isBeforeOrEqual chronoZonedDateTime + a2 =a2 isAfter chronoZonedDateTime + a2 =a2 isAfterOrEqual chronoZonedDateTime + a2 =a2 isEqual chronoZonedDateTime + + a3 =a3 isBefore chronoZonedDateTime + a3 =a3 isBeforeOrEqual chronoZonedDateTime + a3 =a3 isAfter chronoZonedDateTime + a3 =a3 isAfterOrEqual chronoZonedDateTime + a3 =a3 isEqual chronoZonedDateTime + + a4 =a4 isBefore chronoZonedDateTime + a4 =a4 isBeforeOrEqual chronoZonedDateTime + a4 =a4 isAfter chronoZonedDateTime + a4 =a4 isAfterOrEqual chronoZonedDateTime + a4 =a4 isEqual chronoZonedDateTime + } +} From e253cbf4623bbf6560c4d8e1b2c6b0e838cd8ede Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 13 Feb 2020 22:36:59 +0100 Subject: [PATCH 048/142] re-activate the new infix API and fix bug in infix/.../chronoLocalDateAssertions.kt --- .../jdk8/chronoLocalDateTimeAssertions.kt | 20 +++-- .../jdk8/chronoZonedDateTimeAssertions.kt | 25 +++--- .../en_GB/jdk8/chronoLocalDateAssertions.kt | 2 +- .../jdk8/chronoZonedDateTimeAssertions.kt | 25 +++--- .../jdk8/ChronoLocalDateAssertionsSpec.kt | 2 +- .../jdk8/ChronoZonedDateTimeAssertionSpec.kt | 80 +++++++++---------- settings.gradle | 3 +- 7 files changed, 85 insertions(+), 72 deletions(-) diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt index 0f9be7ca0..c8df5cf00 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt @@ -29,8 +29,9 @@ fun > Expect.isBefore(expected: * * @since 0.9.0 */ -fun > Expect.isBeforeOrEqual(expected: ChronoLocalDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoLocalDateTime.isBeforeOrEquals(this, expected)) +fun > Expect.isBeforeOrEqual( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isBeforeOrEquals(this, expected)) /** * Expects that the subject of the assertion (a [ChronoLocalDateTime]) @@ -41,8 +42,9 @@ fun > Expect.isBeforeOrEqual(exp * * @since 0.9.0 */ -fun > Expect.isAfter(expected: ChronoLocalDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoLocalDateTime.isAfter(this, expected)) +fun > Expect.isAfter( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isAfter(this, expected)) /** * Expects that the subject of the assertion (a [ChronoLocalDateTime]) @@ -53,8 +55,9 @@ fun > Expect.isAfter(expected: C * * @since 0.9.0 */ -fun > Expect.isAfterOrEqual(expected: ChronoLocalDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoLocalDateTime.isAfterOrEquals(this, expected)) +fun > Expect.isAfterOrEqual( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isAfterOrEquals(this, expected)) /** * Expects that the subject of the assertion (a [ChronoLocalDateTime]) @@ -65,5 +68,6 @@ fun > Expect.isAfterOrEqual(expe * * @since 0.9.0 */ -fun > Expect.isEqual(expected: ChronoLocalDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoLocalDateTime.isEqual(this, expected)) +fun > Expect.isEqual( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isEqual(this, expected)) diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt index bf0ef514f..72ff95952 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt @@ -17,8 +17,9 @@ import java.time.chrono.ChronoZonedDateTime * * @since 0.9.0 */ -fun > Expect.isBefore(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isBefore(this, expected)) +fun > Expect.isBefore( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isBefore(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -29,8 +30,9 @@ fun > Expect.isBefore(expected: * * @since 0.9.0 */ -fun > Expect.isBeforeOrEqual(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isBeforeOrEqual(this, expected)) +fun > Expect.isBeforeOrEqual( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isBeforeOrEqual(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -41,8 +43,9 @@ fun > Expect.isBeforeOrEqual(exp * * @since 0.9.0 */ -fun > Expect.isAfter(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isAfter(this, expected)) +fun > Expect.isAfter( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isAfter(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -53,8 +56,9 @@ fun > Expect.isAfter(expected: C * * @since 0.9.0 */ -fun > Expect.isAfterOrEqual(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isAfterOrEqual(this, expected)) +fun > Expect.isAfterOrEqual( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isAfterOrEqual(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -65,5 +69,6 @@ fun > Expect.isAfterOrEqual(expe * * @since 0.9.0 */ -fun > Expect.isEqual(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isEqual(this, expected)) +fun > Expect.isEqual( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isEqual(this, expected)) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt index fe516e8fe..c7bd107d6 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt @@ -1,6 +1,6 @@ @file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) -package ch.tutteli.atrium.api.infix.en_GB +package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt index 9ca7fddb0..0ae0b9b37 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt @@ -17,8 +17,9 @@ import java.time.chrono.ChronoZonedDateTime * * @since 0.10.0 */ -infix fun > Expect.isBefore(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isBefore(this, expected)) +infix fun > Expect.isBefore( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isBefore(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -29,8 +30,9 @@ infix fun > Expect.isBefore(expe * * @since 0.10.0 */ -infix fun > Expect.isBeforeOrEqual(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isBeforeOrEqual(this, expected)) +infix fun > Expect.isBeforeOrEqual( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isBeforeOrEqual(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -41,8 +43,9 @@ infix fun > Expect.isBeforeOrEqu * * @since 0.10.0 */ -infix fun > Expect.isAfter(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isAfter(this, expected)) +infix fun > Expect.isAfter( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isAfter(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -53,8 +56,9 @@ infix fun > Expect.isAfter(expec * * @since 0.10.0 */ -infix fun > Expect.isAfterOrEqual(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isAfterOrEqual(this, expected)) +infix fun > Expect.isAfterOrEqual( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isAfterOrEqual(this, expected)) /** * Expects that the subject of the assertion (a [ChronoZonedDateTime]) @@ -65,5 +69,6 @@ infix fun > Expect.isAfterOrEqua * * @since 0.10.0 */ -infix fun > Expect.isEqual(expected: ChronoZonedDateTime<*>): Expect = - addAssertion(ExpectImpl.chronoZonedDateTime.isEqual(this, expected)) +infix fun > Expect.isEqual( + expected: ChronoZonedDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoZonedDateTime.isEqual(this, expected)) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt index 13a3944bc..b7b850146 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateAssertionsSpec.kt @@ -1,4 +1,4 @@ -package kotlin.ch.tutteli.atrium.api.infix.en_GB.jdk8 +package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt index 37f1b9e32..ecebc17d6 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoZonedDateTimeAssertionSpec.kt @@ -24,53 +24,53 @@ class ChronoZonedDateTimeAssertionSpec : ch.tutteli.atrium.specs.integration.Chr var a4: Expect = notImplemented() - a1 =a1 isBefore ZonedDateTime.now() - a1 =a1 isBeforeOrEqual ZonedDateTime.now() - a1 =a1 isAfter ZonedDateTime.now() - a1 =a1 isAfterOrEqual ZonedDateTime.now() - a1 =a1 isEqual ZonedDateTime.now() + a1 = a1 isBefore ZonedDateTime.now() + a1 = a1 isBeforeOrEqual ZonedDateTime.now() + a1 = a1 isAfter ZonedDateTime.now() + a1 = a1 isAfterOrEqual ZonedDateTime.now() + a1 = a1 isEqual ZonedDateTime.now() - a2 =a2 isBefore ZonedDateTime.now() - a2 =a2 isBeforeOrEqual ZonedDateTime.now() - a2 =a2 isAfter ZonedDateTime.now() - a2 =a2 isAfterOrEqual ZonedDateTime.now() - a2 =a2 isEqual ZonedDateTime.now() + a2 = a2 isBefore ZonedDateTime.now() + a2 = a2 isBeforeOrEqual ZonedDateTime.now() + a2 = a2 isAfter ZonedDateTime.now() + a2 = a2 isAfterOrEqual ZonedDateTime.now() + a2 = a2 isEqual ZonedDateTime.now() - a3 =a3 isBefore ZonedDateTime.now() - a3 =a3 isBeforeOrEqual ZonedDateTime.now() - a3 =a3 isAfter ZonedDateTime.now() - a3 =a3 isAfterOrEqual ZonedDateTime.now() - a3 =a3 isEqual ZonedDateTime.now() + a3 = a3 isBefore ZonedDateTime.now() + a3 = a3 isBeforeOrEqual ZonedDateTime.now() + a3 = a3 isAfter ZonedDateTime.now() + a3 = a3 isAfterOrEqual ZonedDateTime.now() + a3 = a3 isEqual ZonedDateTime.now() - a4 =a4 isBefore ZonedDateTime.now() - a4 =a4 isBeforeOrEqual ZonedDateTime.now() - a4 =a4 isAfter ZonedDateTime.now() - a4 =a4 isAfterOrEqual ZonedDateTime.now() - a4 =a4 isEqual ZonedDateTime.now() + a4 = a4 isBefore ZonedDateTime.now() + a4 = a4 isBeforeOrEqual ZonedDateTime.now() + a4 = a4 isAfter ZonedDateTime.now() + a4 = a4 isAfterOrEqual ZonedDateTime.now() + a4 = a4 isEqual ZonedDateTime.now() - a1 =a1 isBefore chronoZonedDateTime - a1 =a1 isBeforeOrEqual chronoZonedDateTime - a1 =a1 isAfter chronoZonedDateTime - a1 =a1 isAfterOrEqual chronoZonedDateTime - a1 =a1 isEqual chronoZonedDateTime + a1 = a1 isBefore chronoZonedDateTime + a1 = a1 isBeforeOrEqual chronoZonedDateTime + a1 = a1 isAfter chronoZonedDateTime + a1 = a1 isAfterOrEqual chronoZonedDateTime + a1 = a1 isEqual chronoZonedDateTime - a2 =a2 isBefore chronoZonedDateTime - a2 =a2 isBeforeOrEqual chronoZonedDateTime - a2 =a2 isAfter chronoZonedDateTime - a2 =a2 isAfterOrEqual chronoZonedDateTime - a2 =a2 isEqual chronoZonedDateTime + a2 = a2 isBefore chronoZonedDateTime + a2 = a2 isBeforeOrEqual chronoZonedDateTime + a2 = a2 isAfter chronoZonedDateTime + a2 = a2 isAfterOrEqual chronoZonedDateTime + a2 = a2 isEqual chronoZonedDateTime - a3 =a3 isBefore chronoZonedDateTime - a3 =a3 isBeforeOrEqual chronoZonedDateTime - a3 =a3 isAfter chronoZonedDateTime - a3 =a3 isAfterOrEqual chronoZonedDateTime - a3 =a3 isEqual chronoZonedDateTime + a3 = a3 isBefore chronoZonedDateTime + a3 = a3 isBeforeOrEqual chronoZonedDateTime + a3 = a3 isAfter chronoZonedDateTime + a3 = a3 isAfterOrEqual chronoZonedDateTime + a3 = a3 isEqual chronoZonedDateTime - a4 =a4 isBefore chronoZonedDateTime - a4 =a4 isBeforeOrEqual chronoZonedDateTime - a4 =a4 isAfter chronoZonedDateTime - a4 =a4 isAfterOrEqual chronoZonedDateTime - a4 =a4 isEqual chronoZonedDateTime + a4 = a4 isBefore chronoZonedDateTime + a4 = a4 isBeforeOrEqual chronoZonedDateTime + a4 = a4 isAfter chronoZonedDateTime + a4 = a4 isAfterOrEqual chronoZonedDateTime + a4 = a4 isEqual chronoZonedDateTime } } diff --git a/settings.gradle b/settings.gradle index fa3160673..3c2e71196 100644 --- a/settings.gradle +++ b/settings.gradle @@ -62,8 +62,7 @@ include { apis('api-') { apiWithExtensions(delegate, 'fluent-en_GB') - //TODO re-activate with 0.10.0 -// apiWithExtensions(delegate, 'infix-en_GB') + apiWithExtensions(delegate, 'infix-en_GB') } domain('domain-') { From 3e079a48edaf5669f5e7d8ebd26a7815b03ac437 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 13 Feb 2020 22:36:59 +0100 Subject: [PATCH 049/142] Add path resolve shortcut --- .../api/fluent/en_GB/jdk8/pathAssertions.kt | 23 +++++++++ .../en_GB/jdk8/PathFeatureAssertionsSpec.kt | 9 ++-- .../api/infix/en_GB/jdk8/pathAssertions.kt | 11 +++++ .../en_GB/jdk8/PathFeatureAssertionsSpec.kt | 11 +++-- .../atrium/domain/creating/PathAssertions.kt | 2 + .../creating/PathAssertionsBuilder.kt | 3 ++ .../robstoll/lib/creating/pathAssertions.kt | 3 ++ .../robstoll/creating/PathAssertionsImpl.kt | 1 + .../integration/PathFeatureAssertionsSpec.kt | 47 +++++++++++++++++++ 9 files changed, 104 insertions(+), 6 deletions(-) diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt index 4a9ad4ba4..54938c60f 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt @@ -156,6 +156,29 @@ val Expect.parent: Expect fun Expect.parent(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.parent(this).addToInitial(assertionCreator) +/** + * Expects that [other] resolve against this [Path] and creates an [Expect] for the resolved [Path] + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +fun Expect.resolve(other: String): Expect = + ExpectImpl.path.resolve(this, other).getExpectOfFeature() + +/** + * Expect that [other] resolve against this [Path] and that the resolved [Path] holds all assertions the + * given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +fun Expect.resolve(other: String, assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.path.resolve(this, other).addToInitial(assertionCreator) /** * Expects that the subject of the assertion (a [Path]) is readable; diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/PathFeatureAssertionsSpec.kt index 39b569a06..25d7a07a5 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/PathFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -1,14 +1,14 @@ package ch.tutteli.atrium.api.fluent.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.* import java.nio.file.Path class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatureAssertionsSpec( property(Expect::parent), fun1.() -> Unit>(Expect::parent), + feature1(Expect::resolve), + fun2.() -> Unit>(Expect::resolve), property(Expect::fileName), fun1.() -> Unit>(Expect::fileName), property(Expect::fileNameWithoutExtension), @@ -31,5 +31,8 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur a1.extension a1 = a1.extension { } + + a1.resolve("test") + a1.resolve("test", {}) } } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index b75ffcd0c..80fcf8094 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -158,6 +158,17 @@ val Expect.parent: Expect infix fun Expect.parent(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.parent(this).addToInitial(assertionCreator) +/** + * Expects that [other] resolve against this [Path] and creates an [Expect] for the resolved [Path] + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect]. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.resolve(other: String): Expect = + ExpectImpl.path.resolve(this, other).getExpectOfFeature() /** * Expects that the subject of the assertion (a [Path]) is readable; diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt index 76f0bf16b..60d08f755 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -1,15 +1,15 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import java.nio.file.Path class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatureAssertionsSpec( property(Expect::parent), fun1.() -> Unit>(Expect::parent), + feature1(Expect::resolve), + fun2.() -> Unit>(Expect::resolve), //resolve with assertionCreator not implemented in this API property(Expect::fileName), fun1.() -> Unit>(Expect::fileName), property(Expect::fileNameWithoutExtension), @@ -34,5 +34,10 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur a1.parent a1 parent {} + + a1 resolve "test" } } + +private fun Expect.resolve(other: String, assertionCreator: Expect.() -> Unit): Expect = + (this resolve other).addAssertionsCreatedBy(assertionCreator) diff --git a/domain/api/atrium-domain-api-jvm/src/main/kotlin/ch/tutteli/atrium/domain/creating/PathAssertions.kt b/domain/api/atrium-domain-api-jvm/src/main/kotlin/ch/tutteli/atrium/domain/creating/PathAssertions.kt index 485f5ebf0..5e4a09e54 100644 --- a/domain/api/atrium-domain-api-jvm/src/main/kotlin/ch/tutteli/atrium/domain/creating/PathAssertions.kt +++ b/domain/api/atrium-domain-api-jvm/src/main/kotlin/ch/tutteli/atrium/domain/creating/PathAssertions.kt @@ -24,6 +24,7 @@ interface PathAssertions { fun extension(expect: Expect): ExtractedFeaturePostStep fun fileNameWithoutExtension(expect: Expect): ExtractedFeaturePostStep fun parent(expect: Expect): ExtractedFeaturePostStep + fun resolve(expect: Expect, other: String): ExtractedFeaturePostStep fun startsWith(expect: Expect, expected: Path): Assertion fun startsNotWith(expect: Expect, expected: Path): Assertion @@ -37,4 +38,5 @@ interface PathAssertions { fun isWritable(expect: Expect): Assertion fun isRegularFile(expect: Expect): Assertion fun isDirectory(expect: Expect): Assertion + } diff --git a/domain/builders/atrium-domain-builders-jvm/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/PathAssertionsBuilder.kt b/domain/builders/atrium-domain-builders-jvm/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/PathAssertionsBuilder.kt index 6a092915b..d4cf5188c 100644 --- a/domain/builders/atrium-domain-builders-jvm/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/PathAssertionsBuilder.kt +++ b/domain/builders/atrium-domain-builders-jvm/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/PathAssertionsBuilder.kt @@ -48,6 +48,9 @@ object PathAssertionsBuilder : PathAssertions { override inline fun parent(expect: Expect) = pathAssertions.parent(expect) + override inline fun resolve(expect: Expect, other: String) = + pathAssertions.resolve(expect, other) + override inline fun isReadable(expect: Expect) = pathAssertions.isReadable(expect) diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/pathAssertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/pathAssertions.kt index 0b63f5670..7522a8e53 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/pathAssertions.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/pathAssertions.kt @@ -395,5 +395,8 @@ fun _parent(expect: Expect): ExtractedFeaturePostStep = .withoutOptions() .build() +fun _resolve(expect: Expect, other: String): ExtractedFeaturePostStep = + ExpectImpl.feature.f1(expect, Path::resolve, other) + fun _extension(expect: Expect): ExtractedFeaturePostStep = ExpectImpl.feature.manualFeature(expect, EXTENSION) { extension } diff --git a/domain/robstoll/atrium-domain-robstoll-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/PathAssertionsImpl.kt b/domain/robstoll/atrium-domain-robstoll-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/PathAssertionsImpl.kt index 5c4009279..6cbb9bcc0 100644 --- a/domain/robstoll/atrium-domain-robstoll-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/PathAssertionsImpl.kt +++ b/domain/robstoll/atrium-domain-robstoll-jvm/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/PathAssertionsImpl.kt @@ -30,6 +30,7 @@ class PathAssertionsImpl : PathAssertions { _fileNameWithoutExtension(expect) override fun parent(expect: Expect) = _parent(expect) + override fun resolve(expect: Expect, other: String) = _resolve(expect, other) override fun isReadable(expect: Expect) = _isReadable(expect) override fun isWritable(expect: Expect) = _isWritable(expect) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/PathFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/PathFeatureAssertionsSpec.kt index b3ab36942..5b60c07ee 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/PathFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/PathFeatureAssertionsSpec.kt @@ -16,6 +16,8 @@ import java.nio.file.Paths abstract class PathFeatureAssertionsSpec( parentFeature: Feature0, parent: Fun1.() -> Unit>, + resolveFeature: Feature1, + resolve: Fun2.() -> Unit>, fileNameFeature: Feature0, fileName: Fun1.() -> Unit>, fileNameWithoutExtensionFeature: Feature0, @@ -30,6 +32,8 @@ abstract class PathFeatureAssertionsSpec( include(object : SubjectLessSpec(describePrefix, parentFeature.forSubjectLess().adjustName { "$it feature" }, parent.forSubjectLess { }, + resolveFeature.forSubjectLess("test").adjustName { "$it feature" }, + resolve.forSubjectLess("test") { toBe(Paths.get("a/my.txt")) }, fileNameFeature.forSubjectLess().adjustName { "$it feature" }, fileName.forSubjectLess { }, fileNameWithoutExtensionFeature.forSubjectLess().adjustName { "$it feature" }, @@ -105,6 +109,49 @@ abstract class PathFeatureAssertionsSpec( } } + describeFun("val ${resolveFeature.name}") { + val resolveVal = resolveFeature.lambda + + context("Folder resolved from root") { + it("toBe(folder.resolve) holds") { + val resolvedFolder = tempFolder.newDirectory("resolve") + val rootFolder = resolvedFolder.parent + expect(rootFolder).resolveVal("resolve").toBe(resolvedFolder) + } + it("toBe(folder) fails") { + expect { + val resolvedFolder = tempFolder.newDirectory("resolve") + val rootFolder = resolvedFolder.parent + expect(rootFolder).resolveVal("notResolved").toBe(resolvedFolder) + }.toThrow { + messageContains("notResolved") + } + } + } + } + + describeFun("fun ${resolve.name}") { + val resolveFun = resolve.lambda + + context("Folder resolved from root") { + it("toBe(folder.resolve) holds") { + val resolvedFolder = tempFolder.newDirectory("resolve") + val rootFolder = resolvedFolder.parent + expect(rootFolder).resolveFun("resolve") { toBe(resolvedFolder) } + } + it("toBe(folder) fails") { + expect { + val resolvedFolder = tempFolder.newDirectory("resolve") + val rootFolder = resolvedFolder.parent + expect(rootFolder).resolveFun("notResolved"){ toBe(resolvedFolder) } + }.toThrow { + messageContains("notResolved") + } + } + } + } + + describeFun("val ${fileNameFeature.name}") { val fileNameVal = fileNameFeature.lambda From 8ff3a7495ed5839587da5f35d976184a4a7a4d5e Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 18 Feb 2020 18:38:41 +0100 Subject: [PATCH 050/142] cleanup Path.resolve --- .../tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt | 4 ++-- .../tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt | 2 +- .../api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt index 54938c60f..489bdd81f 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt @@ -157,7 +157,7 @@ fun Expect.parent(assertionCreator: Expect.() -> Unit): Expe ExpectImpl.path.parent(this).addToInitial(assertionCreator) /** - * Expects that [other] resolve against this [Path] and creates an [Expect] for the resolved [Path] + * Expects that [other] resolves against this [Path] and creates an [Expect] for the resolved [Path] * so that further fluent calls are assertions about it. * * @return The newly created [Expect]. @@ -169,7 +169,7 @@ fun Expect.resolve(other: String): Expect = ExpectImpl.path.resolve(this, other).getExpectOfFeature() /** - * Expect that [other] resolve against this [Path] and that the resolved [Path] holds all assertions the + * Expects that [other] resolves against this [Path] and that the resolved [Path] holds all assertions the * given [assertionCreator] creates for it and returns this assertion container. * * @return This assertion container to support a fluent API. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 80fcf8094..2313c1606 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -159,7 +159,7 @@ infix fun Expect.parent(assertionCreator: Expect.() -> Unit) ExpectImpl.path.parent(this).addToInitial(assertionCreator) /** - * Expects that [other] resolve against this [Path] and creates an [Expect] for the resolved [Path] + * Expects that [other] resolves against this [Path] and creates an [Expect] for the resolved [Path] * so that further fluent calls are assertions about it. * * @return The newly created [Expect]. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt index 60d08f755..dbd8fbcc6 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -9,7 +9,7 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur property(Expect::parent), fun1.() -> Unit>(Expect::parent), feature1(Expect::resolve), - fun2.() -> Unit>(Expect::resolve), //resolve with assertionCreator not implemented in this API + "resolve with assertionCreator not implemented in this API" to ::resolve, property(Expect::fileName), fun1.() -> Unit>(Expect::fileName), property(Expect::fileNameWithoutExtension), @@ -39,5 +39,5 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur } } -private fun Expect.resolve(other: String, assertionCreator: Expect.() -> Unit): Expect = - (this resolve other).addAssertionsCreatedBy(assertionCreator) +private fun resolve(expect: Expect, other: String, assertionCreator: Expect.() -> Unit): Expect = + (expect resolve other).addAssertionsCreatedBy(assertionCreator) From 9b97a681b05da2fda5f2ccc6632669c7ad99c57f Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 18 Feb 2020 19:00:09 +0100 Subject: [PATCH 051/142] remove Kotlin bugs from README, link to wiki instead --- README.md | 52 ++++------------------------------------------------ 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 2109f31de..95047fd1d 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,6 @@ For instance, the [README of v0.9.2](https://github.com/robstoll/atrium/tree/mas - [KDoc - Code Documentation](#kdoc---code-documentation) - [Known Limitations](#known-limitations) - [FAQ](#faq) -- [Kotlin Bugs](#kotlin-bugs) - [Roadmap](#roadmap) - [Contributors and contribute](#contributors-and-contribute) - [Sponsors](#sponsors) @@ -516,7 +515,7 @@ expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) We are sorry that the syntax is not yet the nicest one. We admit that one has to get used to it first and that is a pity. -Yet, it is due to many [Kotlin Bugs](#kotlin-bugs) standing in the way -- +Yet, it is due to many [Kotlin Bugs](https://github.com/robstoll/atrium/wiki/Kotlin-Bugs-and-missing-features) standing in the way -- we hope we can provide a better API once Kotlin 1.4 is out (the new type inference respectively). `feature` has several overloads, we are looking at the one expecting a lambda in which you have to provide a `MetaFeature`. @@ -591,7 +590,7 @@ if the property as such is renamed (e.g., as part of an IDE refactoring). As you can see, you would need to keep the property name and the name of the assertion function in sync to be meaningful (otherwise one gets quickly confused or has to remember two names for the same thing). -Writing assertion functions for methods is a different story though, especially due to [overload bugs in Kotlin](#kotlin-bugs). +Writing assertion functions for methods is a different story though, especially due to [overload bugs in Kotlin](https://github.com/robstoll/atrium/wiki/Kotlin-Bugs-and-missing-features). Also, code completion is not yet as good as it should be when it comes to methods. Last but not least, in case it is not always safe to call a method (e.g. `List.get` => IndexOutOfBound) then it makes sense to wrap it into an assertion function and use `ExpectImpl.feature.extractor` instead. @@ -722,7 +721,7 @@ Also this version of `feature` provides to kind of overloads, one without and on ### Ambiguity Problems Unfortunately there are several Kotlin bugs when it comes to overloading, especially in conjunction with `KFunction` -(see [Kotlin Bugs](#kotlin-bugs) and upvote in case you run into one). +(see [Kotlin Bugs](https://github.com/robstoll/atrium/wiki/Kotlin-Bugs-and-missing-features) and upvote in case you run into one). However, Atrium provides alternative functions next to `f` within the `MetaFeature`-provider-lambda to disambiguate the situation. Use `p` for properties and `f0` to `f5` for methods. Likely you need to specify the type parameters manually as Kotlin is not able to infer them correctly. @@ -1470,7 +1469,7 @@ expected that subject: "calling myFun with ..." <1234789> The example should be self explanatory. One detail to note though is the usage of `subExpect`. -It is a helper function which circumvents certain [Kotlin type inference bugs](#kotlin-bugs) (upvote them please). +It is a helper function which circumvents certain [Kotlin type inference bugs](https://github.com/robstoll/atrium/wiki/Kotlin-Bugs-and-missing-features) (upvote them please). Writing the same as `mapOf.() -> Unit>( 1 to { ... } )` would not work as the type for a lambda involved in a `Pair` is not (yet) inferred correctly by Kotlin. @@ -2435,49 +2434,6 @@ Deprecated APIs: See [Ambiguity Problems](#ambiguity-problems) and [Property does not exist](#property-does-not-exist). -# Kotlin Bugs -The following issues hinder Atrium to progress in certain areas or they are the reason that we cannot use Atrium as intended in all cases. -Please upvote them (especially if you encounter them yourself): -- [Symbol is declared in unnamed module](https://youtrack.jetbrains.com/issue/KT-35343) -- [Gradle runtimeOnly bug](https://youtrack.jetbrains.com/issue/KT-21685) (reason that you see functions from package cc.en_GB when using cc.infix.en_GB) -- [navigate to source or show KDoc for overloaded extension function](https://youtrack.jetbrains.com/issue/KT-24836) -- [Lower bounds](https://youtrack.jetbrains.com/issue/KT-209), i.a. that functions intended for nullable subject do not show up on non-nullable subjects. -- [CTRL+P shows extension functions of unrelated type](https://youtrack.jetbrains.com/issue/KT-29133) -- [Expose @OnlyInputTypes to restrict e.g. toBe](https://youtrack.jetbrains.com/issue/KT-13198) -- [Type inference KFunction overload bug 1](https://youtrack.jetbrains.com/issue/KT-17340) -- [Type inference KFunction overload bug 2](https://youtrack.jetbrains.com/issue/KT-19884) -- [Type inference KProperty/KFunction ambiguity bug](https://youtrack.jetbrains.com/issue/KT-17341) -- [Type inference fails to infer T of KFunction0 for most types](https://youtrack.jetbrains.com/issue/KT-29515) -- [Type inference type parameter bug](https://youtrack.jetbrains.com/issue/KT-12963) -- [Type inference return type bug](https://youtrack.jetbrains.com/issue/KT-24918) -- [Type inference out type parameter bug](https://youtrack.jetbrains.com/issue/KT-18401) -- [Type inference explicit type and overloads](https://youtrack.jetbrains.com/issue/KT-23791) -- [Type inference Pair with receiver type](https://youtrack.jetbrains.com/issue/KT-29129) -- [Type inference unable to infer primitive type](https://youtrack.jetbrains.com/issue/KT-33290) -- [Overload resolution null bug](https://youtrack.jetbrains.com/issue/KT-6591) (reason why you need to specify what type `null` is in the infix API when using `assert(listOf(...)) contains null`) -- [Extension resolution null as receiver bug](https://youtrack.jetbrains.com/issue/KT-30496) (reason why you need to define that `null to null` is a Pair in the infix API) -- [Overload resolution nullable bug](https://youtrack.jetbrains.com/issue/KT-23768) -- [Overload resolution primitive type bug](https://youtrack.jetbrains.com/issue/KT-24230) -- [Overload resolution function type bug](https://youtrack.jetbrains.com/issue/KT-23883) -- [Overload resolution generic upper bound bug](https://youtrack.jetbrains.com/issue/KT-30235) -- [Overload ambiguity between val and fun](https://youtrack.jetbrains.com/issue/KT-32958) -- [false positive: remove explicit type arguments](https://youtrack.jetbrains.com/issue/KT-32869) -- [Wrong JS generated in case of name clash](https://youtrack.jetbrains.com/issue/KT-33294) -- [forbid function types as substitute of reified types ](https://youtrack.jetbrains.com/issue/KT-27846) -- [forbid parameterised types as substitute of reified types](https://youtrack.jetbrains.com/issue/KT-27826) -- [ReplaceWith does not add type parameter](https://youtrack.jetbrains.com/issue/KT-33685) -- [Wrong warning about predetermined type parameter](https://youtrack.jetbrains.com/issue/KT-34257) - -And some features which would be handy -- [hide function with deprecation level error in code completion](https://youtrack.jetbrains.com/issue/KT-25263) -- [Method reference without `this`](https://youtrack.jetbrains.com/issue/KT-22920) -- [Infix function call with type parameters](https://youtrack.jetbrains.com/issue/KT-21593) -- [Extensibility for infix API](https://youtrack.jetbrains.com/issue/KT-27659) -- [Summarising overloads in code completion](https://youtrack.jetbrains.com/issue/KT-25079) -- [vararg for lambdas](https://youtrack.jetbrains.com/issue/KT-24287) -- [delegate with inline modifier](https://youtrack.jetbrains.com/issue/KT-23241) - - # Roadmap The roadmap is maintained at [atrium-roadmap](https://github.com/robstoll/atrium-roadmap). From ded28903c7199d46b3fecf18e3c3b8c5eb7057ad Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 18 Feb 2020 20:05:36 +0100 Subject: [PATCH 052/142] exclude new infix API from being published until we are ready --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e43795e6e..38ced6607 100644 --- a/build.gradle +++ b/build.gradle @@ -261,8 +261,10 @@ configure(apiProjects) { apiProject -> } def bundleSmokeTests = subprojects.findAll { it.name.endsWith('smoke-test') } +//TODO new infix API: remove once we are ready to publish the new API +def newInfixApiModules = subprojects.findAll { it.name.contains('-api-infix') } -configure(subprojects - bundleSmokeTests - sampleProjects - toolProjects) { subproject -> +configure(subprojects - bundleSmokeTests - sampleProjects - toolProjects - newInfixApiModules) { subproject -> apply plugin: 'ch.tutteli.publish' tutteliPublish { From e135750aedff2e3785c2e3bd6e0765fe06e0fc9b Mon Sep 17 00:00:00 2001 From: Joar Ekelund Date: Thu, 20 Feb 2020 12:08:46 +0100 Subject: [PATCH 053/142] implement mapAssertions with new infix API Co-authored-by: alexjdz Co-authored-by: jlundhol Co-authored-by: ashgreyship > --- .../creating/map/get/builders/MapGetOption.kt | 48 ++++ .../map/get/builders/impl/MapGetOptionImpl.kt | 14 + .../atrium/api/infix/en_GB/mapAssertions.kt | 178 +++++++++++++ .../api/infix/en_GB/parameterObjects.kt | 28 ++ .../infix/en_GB/MapAsEntriesAssertionsSpec.kt | 41 +++ .../api/infix/en_GB/MapAssertionsSpec.kt | 240 ++++++++++++++++++ .../infix/en_GB/MapFeatureAssertionsSpec.kt | 50 ++++ 7 files changed, 599 insertions(+) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt new file mode 100644 index 000000000..4a7c95f38 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt @@ -0,0 +1,48 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders + +import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.impl.MapGetOptionImpl +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Assert +import ch.tutteli.atrium.creating.AssertionPlant +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.SubjectProvider + +/** + * Represents the extension point for another option after a `get key`-step within a + * sophisticated `get` assertion building process for [Map]. + * + * @param K The key type of the [Map]. + * @param V the value type of the [Map]. + * @param T A subtype of [Map]. + */ +interface MapGetOption> { + /** + * The [AssertionPlant] for which this assertion is created + */ + val plant: Expect + + /** + * The given key which will be used to perform the [Map.get]. + */ + val key: K + + /** + * Makes the assertion that the [Assert.subject][SubjectProvider.subject] contains the previously specified [key] and that the + * corresponding value holds all assertions the given [assertionCreator] might create for it. + * + * @return This plant to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if a created [Assertion]s (by calling [assertionCreator]) + * does not hold. + * @throws IllegalArgumentException in case the given [assertionCreator] did not create a single assertion. + */ + infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect + + companion object { + /** + * Creates a [MapGetOption] based on the given [plant] and [key]. + */ + fun > create(plant: Expect, key: K): MapGetOption + = MapGetOptionImpl(plant, key) + } +} + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt new file mode 100644 index 000000000..d043387b5 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.MapGetOption +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl + +internal class MapGetOptionImpl>( + override val plant: Expect, + override val key: K +) : MapGetOption { + + override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect + = plant.addAssertion(ExpectImpl.map.getExisting(plant, key).collect(assertionCreator)) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt new file mode 100644 index 000000000..6cf12971b --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -0,0 +1,178 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.MapGetOption +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl + +/** + * Expects that the subject of the assertion (a [Map]) contains a key as defined by [keyValuePair]'s [Pair.first] + * with a corresponding value as defined by [keyValuePair]'s [Pair.second] + * + * Delegates to 'contains Pairs(keyValuePair)'. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.contains(keyValuePair: Pair) = + contains(Pairs(keyValuePair)) + +/** + * Expects the subject of the assertion (a [Map]) contains for each entry in [keyValuePairs], + * a key as defined by that entry's [Pair.first] with a corresponding value as defined by entry's [Pair.second]. + * + * Notice, that it does not search for unique matches. Meaning, if the map is `mapOf('a' to 1)` and one of the [Pair] + * in [keyValuePairs] is defined as `'a' to 1` and another one is defined as `'a' to 1` as well, then both match, + * even though they match the same entry. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.contains(keyValuePairs: Pairs) :Expect = + addAssertion(ExpectImpl.map.contains(this, keyValuePairs.toList())) + +/** + * Expects that the subject of the assertion (a [Map]) contains a key as defined by [keyValue]'s [KeyValue.key] + * with a corresponding value which either holds all assertions [keyValue]'s + * [KeyValue.valueAssertionCreatorOrNull] creates or needs to be `null` in case + * [KeyValue.valueAssertionCreatorOrNull] is defined as `null` + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +inline infix fun > Expect.contains(keyValue: KeyValue) :Expect = + contains(All(keyValue)) + +/** + * Expects that the subject of the assertion (a [Map]) contains for each [KeyValue] in [keyValues], + * a key as defined by [KeyValue.key] with a corresponding value which either holds all + * assertions [KeyValue]'s [KeyValue.valueAssertionCreatorOrNull] creates or needs to be `null` in case + * [KeyValue.valueAssertionCreatorOrNull] is defined as `null` + * + * Notice, that it does not search for unique matches. Meaning, if the map is `mapOf('a' to 1)` and one [KeyValue] in + * [keyValues] is defined as `Key('a') { isGreaterThan(0) }` and another one is defined as `Key('a') { isLessThan(2) }` + * , then both match, even though they match the same entry. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +inline infix fun > Expect.contains(keyValues: All>) + = addAssertion(ExpectImpl.map.containsKeyWithValueAssertions(this, V::class, keyValues.toList().map { it.toPair() })) + +/** + * Expects that the subject of the assertion (a [Map]) contains the given [key]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsKey(key: K) = addAssertion(ExpectImpl.map.containsKey(this, key)) + +/** + * Expects that the subject of the assertion (a [Map]) does not contain the given [key]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsNotKey(key: K) = + addAssertion(ExpectImpl.map.containsNotKey(this, key)) + +/** + * Expects that the subject of the assertion (a [Map]) contains the given [key], + * creates an [Expect] for the corresponding value and returns the newly created assertion container, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect] for the feature. + * @throws AssertionError Might throw an [AssertionError] if the given [key] does not exist. + */ +infix fun > Expect.getExisting(key: K): Expect = + ExpectImpl.map.getExisting(this, key).getExpectOfFeature() + +/** + * Prepares the assertion about the return value of calling [get][Map.get] with the given [key]. + * + * @return A fluent builder to finish the assertion. + * */ +infix fun > Expect.getExisting(key: Key): MapGetOption + = MapGetOption.create(this, key.key) + + +/** + * Creates an [Expect] for the property [Map.keys] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect] for the feature. + */ +val > Expect.keys: Expect> + get() = keys(this).getExpectOfFeature() + +/** + * Expects that the property [Map.keys] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.keys(assertionCreator: Expect>.() -> Unit): Expect = + keys(this).addToInitial(assertionCreator) + +private fun > keys(e: Expect) = ExpectImpl.feature.property(e, Map::keys) + +/** + * Expects that the subject of the assertion (a [Map]) is an empty [Map]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = addAssertion(ExpectImpl.map.isEmpty(this)) + +/** + * Expects that the subject of the assertion (a [Map]) is not an empty [Map]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = addAssertion(ExpectImpl.map.isNotEmpty(this)) + +/** + * Creates an [Expect] for the property [Map.values] of the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @return The newly created [Expect] for the feature. + */ +val > Expect.values: Expect> + get() = values().getExpectOfFeature() + +/** + * Expects that the property [Map.keys] of the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.values(assertionCreator: Expect>.() -> Unit): Expect = + values().addToInitial(assertionCreator) + +private fun > Expect.values() = ExpectImpl.feature.property(this, Map::values) + +/** + * Turns `Expect>` into `Expect>>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::entries) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + */ +fun > Expect.asEntries(): Expect>> = + ExpectImpl.changeSubject(this).unreported { it.entries } + +/** + * Turns `Expect>` into `Expect>>` and expects that it holds all assertions the given + * [assertionCreator] creates. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::entries) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + */ +infix fun > Expect.asEntries( + assertionCreator: Expect>>.() -> Unit +): Expect = apply { asEntries().addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt index 227adbe66..9a3ce117d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt @@ -1,6 +1,34 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.VarArgHelper + /** * Wrapper for a single index -- can be used as distinguishable type for an overload where Int is already in use. */ data class Index(val index: Int) + +data class Key(val key: K) +/** + * Parameter object to express `T, vararg T` in the infix-api. + */ +class All(override val expected: T, override vararg val otherExpected: T) : VarArgHelper + +/** + * Parameter object to express `Pair, vararg Pair` in the infix-api. + */ +class Pairs( + override val expected: Pair, + override vararg val otherExpected: Pair +) : VarArgHelper> + + +/** + * Parameter object to express a key/value [Pair] whose value type is a lambda with an + * [Assert][AssertionPlant] receiver, which means one can either pass a lambda or `null`. + */ +data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { + fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull + override fun toString(): String + = "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt new file mode 100644 index 000000000..1e6bced3d --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt @@ -0,0 +1,41 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.feature0 +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented + +object MapAsEntriesAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAsEntriesAssertionsSpec( + feature0, Set>>(Expect>::asEntries), + fun1, Expect>>.() -> Unit>(Expect>::asEntries) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var map: Expect> = notImplemented() + var subMap: Expect> = notImplemented() + var nullableKeyMap: Expect> = notImplemented() + var nullableValueMap: Expect> = notImplemented() + var nullableKeyValueMap: Expect> = notImplemented() + var readOnlyNullableKeyValueMap: Expect> = notImplemented() + + var starKeyMap: Expect> = notImplemented() + var starValueMap: Expect> = notImplemented() + + map asEntries {} + subMap asEntries {} + nullableKeyMap asEntries {} + nullableValueMap asEntries {} + nullableKeyValueMap asEntries {} + readOnlyNullableKeyValueMap asEntries {} + + map = map asEntries {} + subMap = subMap asEntries {} + nullableKeyMap = nullableKeyMap asEntries {} + nullableValueMap = nullableValueMap asEntries {} + nullableKeyValueMap = nullableKeyValueMap asEntries {} + readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap asEntries {} + + starKeyMap = starKeyMap asEntries {} + starValueMap = starValueMap asEntries {} + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt new file mode 100644 index 000000000..d97984b70 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -0,0 +1,240 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.mapArguments +import ch.tutteli.atrium.specs.* + +class MapExpectionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( + fun2(Companion::contains), + fun2(Companion::contains).name to Companion::containsNullable, + "${fun2(Companion::contains).name} ${KeyValue::class.simpleName}" to Companion::containsKeyWithValueAssertions, + "${fun2(Companion::contains).name} ${KeyValue::class.simpleName}" to Companion::containsKeyWithNullableValueAssertions, + fun1(Companion::containsKey), + fun1(Companion::containsNullableKey), + fun1(Companion::containsNotKey), + fun1(Companion::containsNotNullableKey), + /* string toBe, notToBe to avoid ambiguity error */ + "toBe ${Empty::class.simpleName}" to Companion::isEmpty, + "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty +) { + companion object { + private fun contains(plant: Expect>, pair: Pair, otherPairs: Array>): Expect> { + return if (otherPairs.isEmpty()) { + plant contains (pair.first to pair.second) + } else { + plant contains Pairs(pair, *otherPairs) + } + } + + private fun containsNullable(plant: Expect>, pair: Pair, otherPairs: Array>): Expect> { + return if (otherPairs.isEmpty()) { + plant contains (pair.first to pair.second) + } else { + plant contains Pairs(pair, *otherPairs) + } + } + + private fun containsKeyWithValueAssertions(plant: Expect>, keyValue: Pair.() -> Unit>, otherKeyValues: Array.() -> Unit>>) : Expect> { + return if (otherKeyValues.isEmpty()) { + plant contains KeyValue(keyValue.first, keyValue.second) + } else { + mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + plant contains All(first, *others) + } + } + } + + private fun containsKeyWithNullableValueAssertions(plant: Expect>, keyValue: Pair.() -> Unit)?>, otherKeyValues: Array.() -> Unit)?>>): Expect> { + return if (otherKeyValues.isEmpty()) { + plant contains KeyValue(keyValue.first, keyValue.second) + } else { + mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + plant contains All(first, *others) + } + } + } + + private fun containsKey(plant: Expect>, key: String) + = plant containsKey key + + private fun containsNullableKey(plant: Expect>, key: String?) + = plant containsKey key + + private fun containsNotKey(plant: Expect>, key: String) + = plant containsNotKey key + + private fun containsNotNullableKey(plant: Expect>, key: String?) + = plant containsNotKey key + + private fun isEmpty(plant: Expect>) + = plant toBe Empty + + private fun isNotEmpty(plant: Expect>) + = plant notToBe Empty + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var map: Expect> = notImplemented() + var subMap: Expect> = notImplemented() + var nullableKeyMap: Expect> = notImplemented() + var nullableValueMap: Expect> = notImplemented() + var nullableKeyValueMap: Expect> = notImplemented() + var readOnlyNullableKeyValueMap: Expect> = notImplemented() + var starMap: Expect> = notImplemented() + + map contains (1 to "a") + map contains Pairs(1 to "a", 2 to "b") + map contains (KeyValue(1) {}) + map contains All(KeyValue(1) {}, KeyValue(2) {}) + map contains Pairs(1.0 to StringBuilder("a")) + map contains Pairs(12f to "a", 2L to StringBuilder("b")) + map contains (KeyValue(1) {}) + map contains All(KeyValue(1) {}, KeyValue(2) {}) + + subMap contains (1 to "a") + subMap contains Pairs(1 to "a", 2 to "b") + subMap contains (KeyValue(1) {}) + subMap contains All(KeyValue(1) {}, KeyValue(2) {}) + subMap contains (1.0 to StringBuilder("a")) + subMap contains Pairs(12f to "a", 2L to StringBuilder("b")) + subMap contains (KeyValue(1) {}) + subMap contains All(KeyValue(1) {}, KeyValue(2) {}) + + nullableKeyMap contains (1 to "a") + nullableKeyMap contains Pairs(1 to "a", 2 to "b") + nullableKeyMap contains (KeyValue(1) {}) + nullableKeyMap contains All(KeyValue(1) {}, KeyValue(2) {}) + nullableKeyMap contains (null to "a") + nullableKeyMap contains Pairs(null to "a", null to "b") + nullableKeyMap contains Pairs(null to "a", 2 to "b") + nullableKeyMap contains (KeyValue(null) {}) + nullableKeyMap contains All(KeyValue(null) {}, KeyValue(null) {}) + nullableKeyMap contains All(KeyValue(null) {}, KeyValue(2) {}) + + nullableValueMap contains (1 to "a") + nullableValueMap contains Pairs(1 to "a", 2 to "b") + nullableValueMap contains (KeyValue(1) {}) + nullableValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + nullableValueMap contains (1 to null) + nullableValueMap contains Pairs(1 to null, 2 to null) + nullableValueMap contains Pairs(1 to null, 2 to "a") + nullableValueMap contains (KeyValue(1, null)) + nullableValueMap contains All(KeyValue(1, null), KeyValue(2, null)) + nullableValueMap contains All(KeyValue(1, null), KeyValue(2) {}) + + nullableKeyValueMap contains (1 to "a") + nullableKeyValueMap contains Pairs(1 to "a", 2 to "b") + nullableKeyValueMap contains (KeyValue(1) {}) + nullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + + nullableKeyValueMap contains (null to "a") + nullableKeyValueMap contains Pairs(null to "a", null to "b") + nullableKeyValueMap contains Pairs(null to "a", 2 to "b") + nullableKeyValueMap contains (KeyValue(null) {}) + nullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(null) {}) + nullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(2) {}) + + nullableKeyValueMap contains (1 to null) + nullableKeyValueMap contains Pairs(1 to null, 2 to null) + nullableKeyValueMap contains Pairs(1 to null, 2 to "a") + nullableKeyValueMap contains (KeyValue(1, null)) + nullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2, null)) + nullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2) {}) + + nullableKeyValueMap contains (null to null) + nullableKeyValueMap contains Pairs(null to null, null to null) + nullableKeyValueMap contains Pairs(1 to null, null to "a") + nullableKeyValueMap contains (KeyValue(null, null)) + nullableKeyValueMap contains All(KeyValue(null, null), KeyValue(null, null)) + nullableKeyValueMap contains All(KeyValue(1, null), KeyValue(null) {}) + + readOnlyNullableKeyValueMap contains (1 to "a") + readOnlyNullableKeyValueMap contains Pairs(1 to "a", 2 to "b") + readOnlyNullableKeyValueMap contains (KeyValue(1) {}) + readOnlyNullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + + readOnlyNullableKeyValueMap contains (null to "a") + readOnlyNullableKeyValueMap contains Pairs(null to "a", null to "b") + readOnlyNullableKeyValueMap contains Pairs(null to "a", 2 to "b") + readOnlyNullableKeyValueMap contains (KeyValue(null) {}) + readOnlyNullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(null) {}) + readOnlyNullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(2) {}) + + readOnlyNullableKeyValueMap contains (1 to null) + readOnlyNullableKeyValueMap contains Pairs(1 to null, 2 to null) + readOnlyNullableKeyValueMap contains Pairs(1 to null, 2 to "a") + readOnlyNullableKeyValueMap contains (KeyValue(1, null)) + readOnlyNullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2, null)) + readOnlyNullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2) {}) + + readOnlyNullableKeyValueMap contains (null to null) + readOnlyNullableKeyValueMap contains Pairs(null to null, null to null) + readOnlyNullableKeyValueMap contains Pairs(1 to null, null to "a") + readOnlyNullableKeyValueMap contains (KeyValue(null, null)) + readOnlyNullableKeyValueMap contains All(KeyValue(null, null), KeyValue(null, null)) + readOnlyNullableKeyValueMap contains All(KeyValue(1, null), KeyValue(null) {}) + + readOnlyNullableKeyValueMap contains (1 to "a") + readOnlyNullableKeyValueMap contains Pairs(1 to "a", 2 to "b") + readOnlyNullableKeyValueMap contains (KeyValue(1) {}) + readOnlyNullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + + starMap contains (null to "a") + starMap contains Pairs(null to "a", null to "b") + starMap contains Pairs(null to "a", 2 to "b") + starMap contains (KeyValue(null) {}) + starMap contains All(KeyValue(null) {}, KeyValue(null) {}) + starMap contains All(KeyValue(null) {}, KeyValue(2) {}) + + starMap contains (1 to null) + starMap contains Pairs(1 to null, 2 to null) + starMap contains Pairs(1 to null, 2 to "a") + starMap contains (KeyValue(1, null)) + starMap contains All(KeyValue(1, null), KeyValue(2, null)) + starMap contains All(KeyValue(1, null), KeyValue(2) {}) + + starMap contains (null to null) + starMap contains Pairs(null to null, null to null) + starMap contains Pairs(1 to null, null to "a") + starMap contains (KeyValue(null, null)) + starMap contains All(KeyValue(null, null), KeyValue(null, null)) + starMap contains All(KeyValue(1, null), KeyValue(null) {}) + + map containsKey 1 + map containsKey 1f + subMap containsKey 1 + subMap containsKey 1f + nullableKeyMap containsKey 1 + nullableKeyMap containsKey 1f + readOnlyNullableKeyValueMap containsKey 1 + readOnlyNullableKeyValueMap containsKey 1f + + map containsNotKey 1 + map containsNotKey 1f + subMap containsNotKey 1 + subMap containsNotKey 1f + nullableKeyMap containsNotKey 1 + nullableKeyMap containsNotKey 1f + readOnlyNullableKeyValueMap containsNotKey 1 + readOnlyNullableKeyValueMap containsNotKey 1f + + + map = map toBe Empty + subMap = subMap toBe Empty + nullableKeyMap = nullableKeyMap toBe Empty + nullableValueMap = nullableValueMap toBe Empty + nullableKeyValueMap = nullableKeyValueMap toBe Empty + readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap toBe Empty + starMap = starMap toBe Empty + + map = map notToBe Empty + subMap = subMap notToBe Empty + nullableKeyMap = nullableKeyMap notToBe Empty + nullableValueMap = nullableValueMap notToBe Empty + nullableKeyValueMap = nullableKeyValueMap notToBe Empty + readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap notToBe Empty + starMap = starMap notToBe Empty + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt new file mode 100644 index 000000000..afa782ebd --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt @@ -0,0 +1,50 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.* + +class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureAssertionsSpec( + property, Set>(Expect>::keys), + fun1, Expect>.() -> Unit>(Expect>::keys), + property, Collection>(Expect>::values), + fun1, Expect>.() -> Unit>(Expect>::values), + feature1, String, Int>(Expect>::getExisting), + fun2, String, Expect.() -> Unit>(Companion::getExisting), + feature1, String?, Int?>(Expect>::getExisting).withNullableSuffix(), + fun2(Companion::getExisting).name to Companion::getExistingNullable +) { + companion object { + private fun getExisting( + plant: Expect>, + key: String, + assertionCreator: Expect.() -> Unit + ): Expect> + = plant getExisting Key(key) assertIt { assertionCreator() } + + private fun getExistingNullable( + plant: Expect>, + key: String?, + assertionCreator: Expect.() -> Unit + ): Expect> + = plant getExisting Key(key) assertIt { assertionCreator() } + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a2: Expect> = notImplemented() + var a3: Expect> = notImplemented() + var star: Expect> = notImplemented() + + //TODO ideally this would not work as the map has not defined the key to be out + a1 getExisting 1 + a2 getExisting 1 + a3 getExisting null as String? + star getExisting "a" + + a1 = a1 getExisting Key("a") assertIt { } + a2 = a2 getExisting Key(1) assertIt { } + a3 = a3 getExisting Key(null) assertIt { } + star = star getExisting Key("a") assertIt { } + } +} From f4e9d5b7d7f45845bdb47a49d96c01de05e51d2e Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Feb 2020 10:04:14 +0100 Subject: [PATCH 054/142] format files, rename plant to expect --- .../creating/map/get/builders/MapGetOption.kt | 11 ++-- .../map/get/builders/impl/MapGetOptionImpl.kt | 10 ++-- .../atrium/api/infix/en_GB/mapAssertions.kt | 20 ++++--- .../api/infix/en_GB/parameterObjects.kt | 4 +- .../api/infix/en_GB/MapAssertionsSpec.kt | 59 +++++++++++-------- .../infix/en_GB/MapFeatureAssertionsSpec.kt | 10 ++-- 6 files changed, 62 insertions(+), 52 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt index 4a7c95f38..179fb375b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt @@ -2,7 +2,6 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.impl.MapGetOptionImpl import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.creating.AssertionPlant import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.SubjectProvider @@ -19,7 +18,7 @@ interface MapGetOption> { /** * The [AssertionPlant] for which this assertion is created */ - val plant: Expect + val expect: Expect /** * The given key which will be used to perform the [Map.get]. @@ -30,7 +29,7 @@ interface MapGetOption> { * Makes the assertion that the [Assert.subject][SubjectProvider.subject] contains the previously specified [key] and that the * corresponding value holds all assertions the given [assertionCreator] might create for it. * - * @return This plant to support a fluent API. + * @return This expect to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if a created [Assertion]s (by calling [assertionCreator]) * does not hold. * @throws IllegalArgumentException in case the given [assertionCreator] did not create a single assertion. @@ -39,10 +38,10 @@ interface MapGetOption> { companion object { /** - * Creates a [MapGetOption] based on the given [plant] and [key]. + * Creates a [MapGetOption] based on the given [expect] and [key]. */ - fun > create(plant: Expect, key: K): MapGetOption - = MapGetOptionImpl(plant, key) + fun > create(expect: Expect, key: K): MapGetOption = + MapGetOptionImpl(expect, key) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt index d043387b5..ae34f177f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt @@ -4,11 +4,11 @@ import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.MapGetOption import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl -internal class MapGetOptionImpl>( - override val plant: Expect, +internal class MapGetOptionImpl>( + override val expect: Expect, override val key: K ) : MapGetOption { - - override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect - = plant.addAssertion(ExpectImpl.map.getExisting(plant, key).collect(assertionCreator)) + + override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect = + expect.addAssertion(ExpectImpl.map.getExisting(expect, key).collect(assertionCreator)) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index 6cf12971b..a51518408 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -13,7 +13,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.contains(keyValuePair: Pair) = +infix fun > Expect.contains(keyValuePair: Pair) = contains(Pairs(keyValuePair)) /** @@ -27,7 +27,7 @@ infix fun > Expect.contains(keyValuePair: Pair) * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.contains(keyValuePairs: Pairs) :Expect = +infix fun > Expect.contains(keyValuePairs: Pairs): Expect = addAssertion(ExpectImpl.map.contains(this, keyValuePairs.toList())) /** @@ -39,7 +39,7 @@ infix fun > Expect.contains(keyValuePairs: Pairs> Expect.contains(keyValue: KeyValue) :Expect = +inline infix fun > Expect.contains(keyValue: KeyValue): Expect = contains(All(keyValue)) /** @@ -55,8 +55,8 @@ inline infix fun > Expect.contains(key * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -inline infix fun > Expect.contains(keyValues: All>) - = addAssertion(ExpectImpl.map.containsKeyWithValueAssertions(this, V::class, keyValues.toList().map { it.toPair() })) +inline infix fun > Expect.contains(keyValues: All>) = + addAssertion(ExpectImpl.map.containsKeyWithValueAssertions(this, V::class, keyValues.toList().map { it.toPair() })) /** * Expects that the subject of the assertion (a [Map]) contains the given [key]. @@ -91,8 +91,8 @@ infix fun > Expect.getExisting(key: K): Expect = * * @return A fluent builder to finish the assertion. * */ -infix fun > Expect.getExisting(key: Key): MapGetOption - = MapGetOption.create(this, key.key) +infix fun > Expect.getExisting(key: Key): MapGetOption = + MapGetOption.create(this, key.key) /** @@ -122,7 +122,8 @@ private fun > keys(e: Expect) = ExpectImpl.feature.prope * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = addAssertion(ExpectImpl.map.isEmpty(this)) +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = + addAssertion(ExpectImpl.map.isEmpty(this)) /** * Expects that the subject of the assertion (a [Map]) is not an empty [Map]. @@ -130,7 +131,8 @@ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Em * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = addAssertion(ExpectImpl.map.isNotEmpty(this)) +infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = + addAssertion(ExpectImpl.map.isNotEmpty(this)) /** * Creates an [Expect] for the property [Map.values] of the subject of the assertion, diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt index 9a3ce117d..ee945e498 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt @@ -29,6 +29,6 @@ class Pairs( */ data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull - override fun toString(): String - = "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" + override fun toString(): String = + "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index d97984b70..0141e8ead 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -18,59 +18,70 @@ class MapExpectionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty ) { companion object { - private fun contains(plant: Expect>, pair: Pair, otherPairs: Array>): Expect> { + private fun contains( + expect: Expect>, + pair: Pair, + otherPairs: Array> + ): Expect> { return if (otherPairs.isEmpty()) { - plant contains (pair.first to pair.second) + expect contains (pair.first to pair.second) } else { - plant contains Pairs(pair, *otherPairs) + expect contains Pairs(pair, *otherPairs) } } - private fun containsNullable(plant: Expect>, pair: Pair, otherPairs: Array>): Expect> { + private fun containsNullable( + expect: Expect>, + pair: Pair, + otherPairs: Array> + ): Expect> { return if (otherPairs.isEmpty()) { - plant contains (pair.first to pair.second) + expect contains (pair.first to pair.second) } else { - plant contains Pairs(pair, *otherPairs) + expect contains Pairs(pair, *otherPairs) } } - private fun containsKeyWithValueAssertions(plant: Expect>, keyValue: Pair.() -> Unit>, otherKeyValues: Array.() -> Unit>>) : Expect> { + private fun containsKeyWithValueAssertions( + expect: Expect>, + keyValue: Pair.() -> Unit>, + otherKeyValues: Array.() -> Unit>> + ): Expect> { return if (otherKeyValues.isEmpty()) { - plant contains KeyValue(keyValue.first, keyValue.second) + expect contains KeyValue(keyValue.first, keyValue.second) } else { mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - plant contains All(first, *others) + expect contains All(first, *others) } } } - private fun containsKeyWithNullableValueAssertions(plant: Expect>, keyValue: Pair.() -> Unit)?>, otherKeyValues: Array.() -> Unit)?>>): Expect> { + private fun containsKeyWithNullableValueAssertions( + expect: Expect>, + keyValue: Pair.() -> Unit)?>, + otherKeyValues: Array.() -> Unit)?>> + ): Expect> { return if (otherKeyValues.isEmpty()) { - plant contains KeyValue(keyValue.first, keyValue.second) + expect contains KeyValue(keyValue.first, keyValue.second) } else { mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - plant contains All(first, *others) + expect contains All(first, *others) } } } - private fun containsKey(plant: Expect>, key: String) - = plant containsKey key + private fun containsKey(expect: Expect>, key: String) = expect containsKey key - private fun containsNullableKey(plant: Expect>, key: String?) - = plant containsKey key + private fun containsNullableKey(expect: Expect>, key: String?) = expect containsKey key - private fun containsNotKey(plant: Expect>, key: String) - = plant containsNotKey key + private fun containsNotKey(expect: Expect>, key: String) = expect containsNotKey key - private fun containsNotNullableKey(plant: Expect>, key: String?) - = plant containsNotKey key + private fun containsNotNullableKey(expect: Expect>, key: String?) = + expect containsNotKey key - private fun isEmpty(plant: Expect>) - = plant toBe Empty + private fun isEmpty(expect: Expect>) = expect toBe Empty - private fun isNotEmpty(plant: Expect>) - = plant notToBe Empty + private fun isNotEmpty(expect: Expect>) = expect notToBe Empty } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt index afa782ebd..20ef9dbf2 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt @@ -15,18 +15,16 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA ) { companion object { private fun getExisting( - plant: Expect>, + expect: Expect>, key: String, assertionCreator: Expect.() -> Unit - ): Expect> - = plant getExisting Key(key) assertIt { assertionCreator() } + ): Expect> = expect getExisting Key(key) assertIt { assertionCreator() } private fun getExistingNullable( - plant: Expect>, + expect: Expect>, key: String?, assertionCreator: Expect.() -> Unit - ): Expect> - = plant getExisting Key(key) assertIt { assertionCreator() } + ): Expect> = expect getExisting Key(key) assertIt { assertionCreator() } } @Suppress("unused", "UNUSED_VALUE") From 1a8e76e1ac8d41ddd6189348d732cae3a92eb481 Mon Sep 17 00:00:00 2001 From: Alex Diaz <33261531+alexjdz@users.noreply.github.com> Date: Sat, 29 Feb 2020 14:33:18 +0100 Subject: [PATCH 055/142] undo renaming of MapAssertionsSpec class While working on #229, mapAssertionsSpec was accidentally renamed to mapExceptionsSpec. As all tests passed, this error was unfortunately never noticed. This change reverts it back to mapAssertionsSpec. --- .../ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index 0141e8ead..14ec68fc6 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments import ch.tutteli.atrium.specs.* -class MapExpectionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( +class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( fun2(Companion::contains), fun2(Companion::contains).name to Companion::containsNullable, "${fun2(Companion::contains).name} ${KeyValue::class.simpleName}" to Companion::containsKeyWithValueAssertions, From 48ebaaf43af20373dcbc67eaefbaf7d74270a493 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 29 Feb 2020 20:59:10 +0100 Subject: [PATCH 056/142] rename `assertion container` to `Expect` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit moreover: - get rid off `to support a fluent API`, that's actually wrong, even   if we return an Expect for a feature it is still a fluent API - do not mention that this Expect is returned but one for the current   subject --- .../atrium/api/fluent/en_GB/anyAssertions.kt | 22 ++++---- .../fluent/en_GB/charSequenceAssertions.kt | 34 ++++++------- .../api/fluent/en_GB/collectionAssertions.kt | 14 +++--- .../api/fluent/en_GB/comparableAssertions.kt | 8 +-- .../api/fluent/en_GB/expectExtensions.kt | 16 ++++++ .../api/fluent/en_GB/featureAssertions.kt | 36 ++++++------- .../fluent/en_GB/floatingPointAssertions.kt | 4 +- .../atrium/api/fluent/en_GB/fun0Assertions.kt | 6 ++- .../api/fluent/en_GB/iterableAssertions.kt | 36 ++++++------- .../atrium/api/fluent/en_GB/listAssertions.kt | 2 +- .../atrium/api/fluent/en_GB/mapAssertions.kt | 28 +++++------ .../api/fluent/en_GB/mapEntryAssertions.kt | 14 +++--- .../atrium/api/fluent/en_GB/pairAssertions.kt | 12 ++--- .../api/fluent/en_GB/sequenceAssertions.kt | 2 +- .../api/fluent/en_GB/throwableAssertions.kt | 8 +-- .../api/fluent/en_GB/bigDecimalAssertions.kt | 10 ++-- .../en_GB/floatingPointJvmAssertions.kt | 2 +- .../en_GB/jdk8/chronoLocalDateAssertions.kt | 10 ++-- .../jdk8/chronoLocalDateTimeAssertions.kt | 10 ++-- .../jdk8/chronoZonedDateTimeAssertions.kt | 10 ++-- .../api/fluent/en_GB/jdk8/fileAssertions.kt | 2 +- .../fluent/en_GB/jdk8/localDateAssertions.kt | 24 ++++----- .../en_GB/jdk8/localDateTimeAssertions.kt | 24 ++++----- .../fluent/en_GB/jdk8/optionalAssertions.kt | 6 +-- .../api/fluent/en_GB/jdk8/pathAssertions.kt | 50 +++++++++---------- .../en_GB/jdk8/zonedDateTimeAssertions.kt | 24 ++++----- .../en_GB/kotlin_1_3/resultAssertions.kt | 6 +-- .../atrium/api/infix/en_GB/anyAssertions.kt | 24 +++++---- .../api/infix/en_GB/collectionAssertions.kt | 10 ++-- .../api/infix/en_GB/comparableAssertions.kt | 8 +-- .../creating/list/get/builders/ListGetStep.kt | 2 +- .../atrium/api/infix/en_GB/fun0Assertions.kt | 6 ++- .../api/infix/en_GB/iterableAssertions.kt | 2 +- .../atrium/api/infix/en_GB/mapAssertions.kt | 30 +++++------ .../api/infix/en_GB/mapEntryAssertions.kt | 14 +++--- .../atrium/api/infix/en_GB/pairAssertions.kt | 12 ++--- .../api/infix/en_GB/sequenceAssertions.kt | 3 +- .../en_GB/jdk8/chronoLocalDateAssertions.kt | 10 ++-- .../jdk8/chronoZonedDateTimeAssertions.kt | 10 ++-- .../api/infix/en_GB/jdk8/fileAssertions.kt | 2 +- .../infix/en_GB/jdk8/localDateAssertions.kt | 24 ++++----- .../en_GB/jdk8/localDateTimeAssertions.kt | 24 ++++----- .../api/infix/en_GB/jdk8/pathAssertions.kt | 46 ++++++++--------- .../en_GB/jdk8/zonedDateTimeAssertions.kt | 24 ++++----- .../creating/CollectingAssertionContainer.kt | 4 +- .../ch/tutteli/atrium/creating/Expect.kt | 8 +-- .../creating/changers/FeatureExtractor.kt | 2 +- .../creating/changers/SubjectChanger.kt | 4 +- .../kotlin_1_3/creating/ResultAssertions.kt | 4 +- .../atrium/domain/builders/ExpectImpl.kt | 4 +- .../changers/SubjectChangerBuilder.kt | 12 ++--- .../impl/subjectchanger/defaultImpls.kt | 12 ++--- .../creating/ResultAssertionsBuilder.kt | 11 ++-- .../creating/resultAssertions.kt | 4 +- .../creating/ResultAssertionsImpl.kt | 10 ++-- 55 files changed, 381 insertions(+), 365 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt index 02bf6492c..5436baa1f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/anyAssertions.kt @@ -8,7 +8,7 @@ import ch.tutteli.atrium.reporting.Reporter /** * Expects that the subject of the assertion is (equal to) [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.toBe(expected: T) = addAssertion(ExpectImpl.any.toBe(this, expected)) @@ -16,7 +16,7 @@ fun Expect.toBe(expected: T) = addAssertion(ExpectImpl.any.toBe(this, exp /** * Expects that the subject of the assertion is not (equal to) [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.notToBe(expected: T) = addAssertion(ExpectImpl.any.notToBe(this, expected)) @@ -24,7 +24,7 @@ fun Expect.notToBe(expected: T) = addAssertion(ExpectImpl.any.notToBe(thi /** * Expects that the subject of the assertion is the same instance as [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isSameAs(expected: T) = addAssertion(ExpectImpl.any.isSame(this, expected)) @@ -32,7 +32,7 @@ fun Expect.isSameAs(expected: T) = addAssertion(ExpectImpl.any.isSame(thi /** * Expects that the subject of the assertion is not the same instance as [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isNotSameAs(expected: T) = addAssertion(ExpectImpl.any.isNotSame(this, expected)) @@ -47,7 +47,7 @@ fun Expect.isNotSameAs(expected: T) = addAssertion(ExpectImpl.any.isNotSa * else notToBeNull(assertionCreatorOrNull) * ``` * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun Expect.toBeNullIfNullGivenElse( @@ -59,7 +59,7 @@ inline fun Expect.toBeNullIfNullGivenElse( * * It delegates to [isA] with [T] as type. * - * @return An assertion container with the non-nullable type [T] (was `T?` before). + * @return An [Expect] with the non-nullable type [T] (was `T?` before). * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @Suppress(/* less magic */ "RemoveExplicitTypeArguments") @@ -71,7 +71,7 @@ inline fun Expect.notToBeNull(): Expect = isA() * * It delegates to [isA] with [T] as type. * - * @return An assertion container with the non-nullable type [T] (was `T?` before) + * @return An [Expect] with the non-nullable type [T] (was `T?` before) * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @Suppress(/* less magic */ "RemoveExplicitTypeArguments") @@ -94,7 +94,7 @@ inline fun Expect.notToBeNull(noinline assertionCreator: E * the element type is actually `String`. Or in other words * `assert(listOf(1, 2)).isA>{}` holds, even though `List` is clearly not a `List`. * - * @return An assertion container with the new type [TSub]. + * @return An [Expect] with the new type [TSub]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun Expect<*>.isA(): Expect = @@ -138,7 +138,7 @@ inline fun Expect<*>.isA(): Expect = * the element type is actually `String`. Or in other words * `assert(listOf(1, 2)).isA>{}` holds, even though `List` is clearly not a `List`. * - * @return An assertion container with the new type [TSub]. + * @return An [Expect] with the new type [TSub]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun Expect<*>.isA(noinline assertionCreator: Expect.() -> Unit): Expect = @@ -152,7 +152,7 @@ inline fun Expect<*>.isA(noinline assertionCreator: Expect< * asserts that 1 is greater than 0. If the first assertion fails, then usually (depending on the configured * [AssertionChecker]) the second assertion is not evaluated. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. */ inline val Expect.and: Expect get() = this @@ -164,6 +164,6 @@ inline val Expect.and: Expect get() = this * second one is evaluated as a whole. Meaning, even though 1 is not even, it still evaluates that 1 is greater than 1. * Hence the reporting might (depending on the configured [Reporter]) contain both failing sub-assertions. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. */ infix fun Expect.and(assertionCreator: Expect.() -> Unit) = addAssertionsCreatedBy(assertionCreator) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt index 85ce8f0a3..49ca8b16c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt @@ -47,7 +47,7 @@ val Expect.containsNot: NotCheckerOption Expect.contains(expected: Any, vararg otherExpected: A * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.containsNot(expected: Any, vararg otherExpected: Any) = @@ -90,7 +90,7 @@ fun Expect.containsNot(expected: Any, vararg otherExpected * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.containsRegex(pattern: String, vararg otherPatterns: String): Expect = @@ -116,7 +116,7 @@ fun Expect.containsRegex(pattern: String, vararg otherPatt * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -127,7 +127,7 @@ fun Expect.containsRegex(pattern: Regex, vararg otherPatte /** * Expects that the subject of the assertion (a [CharSequence]) starts with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.startsWith(expected: CharSequence) = @@ -136,7 +136,7 @@ fun Expect.startsWith(expected: CharSequence) = /** * Expects that the subject of the assertion (a [CharSequence]) starts with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -146,7 +146,7 @@ fun Expect.startsWith(expected: Char) = startsWith(expecte /** * Expects that the subject of the assertion (a [CharSequence]) does not start with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.startsNotWith(expected: CharSequence) = @@ -155,7 +155,7 @@ fun Expect.startsNotWith(expected: CharSequence) = /** * Expects that the subject of the assertion (a [CharSequence]) does not start with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -166,7 +166,7 @@ fun Expect.startsNotWith(expected: Char) = startsNotWith(e /** * Expects that the subject of the assertion (a [CharSequence]) ends with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.endsWith(expected: CharSequence) = @@ -175,7 +175,7 @@ fun Expect.endsWith(expected: CharSequence) = /** * Expects that the subject of the assertion (a [CharSequence]) ends with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -185,7 +185,7 @@ fun Expect.endsWith(expected: Char) = endsWith(expected.to /** * Expects that the subject of the assertion (a [CharSequence]) does not end with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.endsNotWith(expected: CharSequence) = @@ -194,7 +194,7 @@ fun Expect.endsNotWith(expected: CharSequence) = /** * Expects that the subject of the assertion (a [CharSequence]) does not end with [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -205,7 +205,7 @@ fun Expect.endsNotWith(expected: Char) = endsNotWith(expec /** * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isEmpty]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isEmpty() = addAssertion(ExpectImpl.charSequence.isEmpty(this)) @@ -213,7 +213,7 @@ fun Expect.isEmpty() = addAssertion(ExpectImpl.charSequenc /** * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isNotEmpty]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isNotEmpty() = addAssertion(ExpectImpl.charSequence.isNotEmpty(this)) @@ -221,7 +221,7 @@ fun Expect.isNotEmpty() = addAssertion(ExpectImpl.charSequ /** * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isNotBlank]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isNotBlank() = addAssertion(ExpectImpl.charSequence.isNotBlank(this)) @@ -229,7 +229,7 @@ fun Expect.isNotBlank() = addAssertion(ExpectImpl.charSequ /** * Expects that the subject of the assertion (a [CharSequence]) matches the given [expected] [Regex]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -240,7 +240,7 @@ fun Expect.matches(expected: Regex) = /** * Expects that the subject of the assertion (a [CharSequence]) mismatches the given [expected] [Regex]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt index 3fc129558..46913253a 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt @@ -6,7 +6,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl /** * Expects that the subject of the assertion (a [Collection]) is an empty [Collection]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isEmpty() = addAssertion(ExpectImpl.collection.isEmpty(this)) @@ -14,7 +14,7 @@ fun > Expect.isEmpty() = addAssertion(ExpectImpl.collection /** * Expects that the subject of the assertion (a [Collection]) is not an empty [Collection]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isNotEmpty() = addAssertion(ExpectImpl.collection.isNotEmpty(this)) @@ -22,9 +22,9 @@ fun > Expect.isNotEmpty() = addAssertion(ExpectImpl.collect /** * Expects that the subject of the assertion (a [Collection]) has the given [expected] size. * - * Shortcut for `expected.toBe(expectedSize)`. + * Shortcut for `size.toBe(expected)`. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.hasSize(expected: Int) = size { toBe(expected) } @@ -33,16 +33,16 @@ fun > Expect.hasSize(expected: Int) = size { toBe(expected) * Creates an [Expect] for the property [Collection.size] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.size: Expect get() = ExpectImpl.collection.size(this).getExpectOfFeature() /** * Expects that the property [Collection.size] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.size(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/comparableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/comparableAssertions.kt index c96f93aad..7f1151866 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/comparableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/comparableAssertions.kt @@ -7,7 +7,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * Expects that the subject of the assertion is less than [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isLessThan(expected: T) = @@ -17,7 +17,7 @@ fun > Expect.isLessThan(expected: T) = * Expects that the subject of the assertion is less than or equal [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isLessThanOrEqual(expected: T) = @@ -27,7 +27,7 @@ fun > Expect.isLessThanOrEqual(expected: T) = * Expects that the subject of the assertion is greater than [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isGreaterThan(expected: T) = @@ -37,7 +37,7 @@ fun > Expect.isGreaterThan(expected: T) = * Expects that the subject of the assertion is greater than or equal [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isGreaterThanOrEqual(expected: T) = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt index 5afdcfcf6..422e620ea 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt @@ -20,6 +20,8 @@ annotation class ExperimentalWithOptions * instead of the representation that has been defined so far (which defaults to the subject itself). * * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions fun RootExpect.withRepresentation(textRepresentation: String): Expect = @@ -36,6 +38,8 @@ fun RootExpect.withRepresentation(textRepresentation: String): Expect * a `String` and does the wrapping for you. * * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions fun RootExpect.withRepresentation(representationProvider: (T) -> Any): Expect = @@ -44,6 +48,8 @@ fun RootExpect.withRepresentation(representationProvider: (T) -> Any): Ex /** * Uses the given [configuration]-lambda to create an [ExpectOptions] which in turn is used * to override (parts) of the existing configuration. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser.() -> Unit): Expect = @@ -53,6 +59,8 @@ fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser //in the same go we should get rid of ReportingAssertionContainer.AssertionCheckerDecorator, rename it respectively. /** * Uses the given [options] to override (parts) of the existing configuration. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions @UseExperimental(ExperimentalExpectConfig::class) @@ -73,6 +81,8 @@ fun RootExpect.withOptions(options: ExpectOptions): Expect = coreFa * instead of the representation that has been defined so far (which defaults to the subject itself). * * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions fun FeatureExpect.withRepresentation(textRepresentation: String): Expect = @@ -89,6 +99,8 @@ fun FeatureExpect.withRepresentation(textRepresentation: String): E * a `String` and does the wrapping for you. * * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions fun FeatureExpect.withRepresentation(representationProvider: (R) -> Any): Expect = @@ -97,6 +109,8 @@ fun FeatureExpect.withRepresentation(representationProvider: (R) -> /** * Uses the given [configuration]-lambda to create an [ExpectOptions] which in turn is used * to override (parts) of the existing configuration. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions fun FeatureExpect.withOptions(configuration: FeatureExtractorBuilder.OptionsChooser.() -> Unit): Expect = @@ -104,6 +118,8 @@ fun FeatureExpect.withOptions(configuration: FeatureExtractorBuilde /** * Uses the given [options] to override (parts) of the existing configuration. + * + * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions @UseExperimental(ExperimentalExpectConfig::class) 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 d18e87aa7..68142486d 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 @@ -13,7 +13,7 @@ import kotlin.reflect.* * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the given [property]. + * @return The newly created [Expect] for the given [property]. * * @since 0.9.0 */ @@ -26,7 +26,7 @@ fun Expect.feature(property: KProperty1): FeatureExpect * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -42,7 +42,7 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. * * @since 0.9.0 */ @@ -55,7 +55,7 @@ fun Expect.feature(f: KFunction1): FeatureExpect = * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -72,7 +72,7 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. * * @since 0.9.0 */ @@ -88,7 +88,7 @@ fun Expect.feature( * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -106,7 +106,7 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. * * @since 0.9.0 */ @@ -122,7 +122,7 @@ fun Expect.feature( * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -140,7 +140,7 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. * * @since 0.9.0 */ @@ -156,7 +156,7 @@ fun Expect.feature( * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -174,7 +174,7 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. * * @since 0.9.0 */ @@ -190,7 +190,7 @@ fun Expect.feature( * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -208,7 +208,7 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return An [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly [Expect] for the return value of calling [f] on the current subject of the assertion. * * @since 0.9.0 */ @@ -224,7 +224,7 @@ fun Expect.feature( * applies an assertion group based on the given [assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -245,7 +245,7 @@ fun Expect.feature( * @param provider Extracts the feature where the subject of the assertion is available via * implicit parameter `it`. * - * @return An [Expect] for the extracted feature. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -262,7 +262,7 @@ fun Expect.feature(description: String, provider: T.() -> R): FeatureE * @param provider Extracts the feature where the subject of the assertion is available via * implicit parameter `it`. * - * @return The current [Expect]. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * * @since 0.9.0 @@ -284,7 +284,7 @@ fun Expect.feature( * implicit parameter `it`. Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], * e.g. `feature { f(it::size) }` * - * @return An [Expect] for the extracted feature. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -301,7 +301,7 @@ fun Expect.feature(provider: MetaFeatureOption.(T) -> MetaFeature.toBeWithErrorTolerance(expected: Float, tolerance: Float) = @@ -34,7 +34,7 @@ fun Expect.toBeWithErrorTolerance(expected: Float, tolerance: Float) = * * | `subject of the assertion` - [expected] | ≤ [tolerance] * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.toBeWithErrorTolerance(expected: Double, tolerance: Double) = 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 800df45d8..c985389c4 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 @@ -10,7 +10,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * For instance `toThrow>` would only check if the subject is a `MyException` without checking if * the element type is actually `String`. * - * @return An assertion container with the new type [TExpected]. + * @return An [Expect] with the new type [TExpected]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun Expect Any?>.toThrow(): Expect = @@ -46,7 +46,7 @@ inline fun Expect Any?>.toThrow(): Exp * For instance `toThrow>` would only check if the subject is a `MyException` without checking if * the element type is actually `String`. * - * @return An assertion container with the new type [TExpected]. + * @return An [Expect] with the new type [TExpected]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun Expect Any?>.toThrow( @@ -58,6 +58,7 @@ inline fun Expect Any?>.toThrow( * Expects that no [Throwable] is thrown at all when calling the subject (a lambda with arity 0, i.e. without arguments) * and changes the subject of the assertion to the return value of type [R]. * + * @return An [Expect] with the new type [R]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun R> Expect.notToThrow(): Expect = ExpectImpl.fun0.isNotThrowing(this).getExpectOfFeature() @@ -66,6 +67,7 @@ fun R> Expect.notToThrow(): Expect = ExpectImpl.fun0.isNotTh * Expects that no [Throwable] is thrown at all when calling the subject (a lambda with arity 0, i.e. without arguments) * and that the corresponding return value holds all assertions the given [assertionCreator] creates. * + * @return An [Expect] with the new type [R]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun R> Expect.notToThrow( diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt index 1537bc3ce..a28eb79df 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt @@ -28,9 +28,9 @@ val > Expect.containsNot: NotCheckerOption, T : Iterable> Expect.min(assertionCreator: Expect< * Creates an [Expect] for the property min of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @since 0.9.0 */ fun , T : Iterable> Expect.min(): Expect = ExpectImpl.iterable.min(this).getExpectOfFeature() /** * Expects that the property max of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @since 0.9.0 */ @@ -61,7 +61,7 @@ fun , T : Iterable> Expect.max(assertionCreator: Expect< * Creates an [Expect] for the property max of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @since 0.9.0 */ fun , T : Iterable> Expect.max(): Expect = ExpectImpl.iterable.max(this).getExpectOfFeature() @@ -81,7 +81,7 @@ fun , T : Iterable> Expect.max(): Expect = ExpectImpl * instead of: * `contains('a', 'a')` * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.contains(expected: E, vararg otherExpected: E): Expect = @@ -98,7 +98,7 @@ fun > Expect.contains(expected: E, vararg otherExpected: E * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.contains(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = @@ -118,7 +118,7 @@ fun > Expect.contains(assertionCreatorOrNull: (Expe * @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry * which we are looking for (see [assertionCreatorOrNull] for more information). * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.contains( @@ -136,7 +136,7 @@ fun > Expect.contains( * which will cause a binary backward compatibility break (see * [#292](https://github.com/robstoll/atrium/issues/292) for more information) * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.containsExactly(expected: E, vararg otherExpected: E): Expect = @@ -157,7 +157,7 @@ fun > Expect.containsExactly(expected: E, vararg otherExpe * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.containsExactly(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = @@ -181,7 +181,7 @@ fun > Expect.containsExactly(assertionCreatorOrNull * @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry * which we are looking for (see [assertionCreatorOrNull] for more information). * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.containsExactly( @@ -196,7 +196,7 @@ fun > Expect.containsExactly( * * It is a shortcut for `containsNot.values(expected, *otherExpected)` * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.containsNot(expected: E, vararg otherExpected: E) = @@ -209,7 +209,7 @@ fun > Expect.containsNot(expected: E, vararg otherExpected * * It is a shortcut for `contains.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)` * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.any(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = @@ -223,7 +223,7 @@ fun > Expect.any(assertionCreatorOrNull: (Expect * * It is a shortcut for `containsNot.entry(assertionCreatorOrNull)` * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.none(assertionCreatorOrNull: (Expect.() -> Unit)?) = @@ -235,7 +235,7 @@ fun > Expect.none(assertionCreatorOrNull: (Expect> Expect.all(assertionCreatorOrNull: (Expect.() -> Unit)?) = @@ -244,7 +244,7 @@ fun > Expect.all(assertionCreatorOrNull: (Expect /** * Expects that the subject of the assertion (an [Iterable]) has at least one element. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -254,7 +254,7 @@ fun > Expect.hasNext() = addAssertion(ExpectImpl.iterable. /** * Expects that the subject of the assertion (an [Iterable]) does not have next element. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt index 8280ea4bf..9b8d8a1ab 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt @@ -16,7 +16,7 @@ fun > Expect.get(index: Int): Expect = ExpectImpl.list.get( * Expects that the given [index] is within the bounds of the subject of the assertion (a [List]) and that * the element at that position holds all assertions the given [assertionCreator] creates for it. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the given [index] is out of bound. */ fun > Expect.get(index: Int, assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt index cc7bb8a57..ca97d4319 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt @@ -14,7 +14,7 @@ import ch.tutteli.kbox.glue * defined as `'a' to 1` and one of the [otherPairs] is defined as `'a' to 1` as well, then both match, * even though they match the same entry. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.contains( @@ -33,7 +33,7 @@ fun > Expect.contains( * defined as `Key('a') { isGreaterThan(0) }` and one of the [otherKeyValues] is defined as `Key('a') { isLessThan(2) }` * , then both match, even though they match the same entry. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun > Expect.contains( @@ -46,7 +46,7 @@ inline fun > Expect.contains( /** * Expects that the subject of the assertion (a [Map]) contains the given [key]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.containsKey(key: K) = addAssertion(ExpectImpl.map.containsKey(this, key)) @@ -54,7 +54,7 @@ fun > Expect.containsKey(key: K) = addAssertion(ExpectIm /** * Expects that the subject of the assertion (a [Map]) does not contain the given [key]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.containsNotKey(key: K) = addAssertion(ExpectImpl.map.containsNotKey(this, key)) @@ -63,7 +63,7 @@ fun > Expect.containsNotKey(key: K) = addAssertion(Expec /** * Expects that the subject of the assertion (a [Map]) is an empty [Map]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isEmpty() = addAssertion(ExpectImpl.map.isEmpty(this)) @@ -71,7 +71,7 @@ fun > Expect.isEmpty() = addAssertion(ExpectImpl.map.isEmpty(th /** * Expects that the subject of the assertion (a [Map]) is not an empty [Map]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isNotEmpty() = addAssertion(ExpectImpl.map.isNotEmpty(this)) @@ -82,7 +82,7 @@ fun > Expect.isNotEmpty() = addAssertion(ExpectImpl.map.isNotEm * creates an [Expect] for the corresponding value and returns the newly created assertion container, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect] for the feature. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the given [key] does not exist. */ fun > Expect.getExisting(key: K): Expect = @@ -92,7 +92,7 @@ fun > Expect.getExisting(key: K): Expect = * Expects that the subject of the assertion (a [Map]) contains the given [key] and that * the corresponding value holds all assertions the given [assertionCreator] creates for it. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if a created [Assertion]s (by calling [assertionCreator]) * does not hold. */ @@ -103,16 +103,16 @@ fun > Expect.getExisting(key: K, assertionCreator: Ex * Creates an [Expect] for the property [Map.keys] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect] for the feature. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.keys: Expect> get() = keys(this).getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.keys(assertionCreator: Expect>.() -> Unit): Expect = @@ -124,16 +124,16 @@ private fun > keys(e: Expect) = ExpectImpl.feature.prope * Creates an [Expect] for the property [Map.values] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect] for the feature. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.values: Expect> get() = values().getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.values(assertionCreator: Expect>.() -> Unit): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt index 902723d42..e00f14bdb 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt @@ -11,7 +11,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * block. Yet, the actual behaviour depends on implementation - could also be fail fast for instance or augment * reporting etc. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.isKeyValue(key: K, value: V): Expect = @@ -21,16 +21,16 @@ fun > Expect.isKeyValue(key: K, value: V): Expect> Expect.key: Expect get() = ExpectImpl.map.entry.key(this).getExpectOfFeature() /** * Expects that the property [Map.Entry.key] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.key(assertionCreator: Expect.() -> Unit): Expect = @@ -40,16 +40,16 @@ fun > Expect.key(assertionCreator: Expect.() -> * Creates an [Expect] for the property [Map.Entry.value] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.value: Expect get() = ExpectImpl.map.entry.value(this).getExpectOfFeature() /** * Expects that the property [Map.Entry.value] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.value(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt index 0d4e73da3..1b2fa6bee 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt @@ -7,16 +7,16 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * Creates an [Expect] for the property [Pair.first] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.first: Expect get() = ExpectImpl.pair.first(this).getExpectOfFeature() /** * Expects that the property [Pair.first] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.first(assertionCreator: Expect.() -> Unit): Expect = @@ -26,16 +26,16 @@ fun > Expect.first(assertionCreator: Expect.() -> Uni * Creates an [Expect] for the property [Pair.second] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.second: Expect get() = ExpectImpl.pair.second(this).getExpectOfFeature() /** * Expects that the property [Pair.second] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.second(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt index 04378221d..6aeb691f2 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/sequenceAssertions.kt @@ -21,7 +21,7 @@ fun > Expect.asIterable(): Expect> = * The transformation as such is not reflected in reporting. * Use `feature(Sequence::asIterable, assertionCreator)` if you want to show the transformation in reporting. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. */ fun > Expect.asIterable(assertionCreator: Expect>.() -> Unit): Expect = apply { asIterable().addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt index 8bec46bac..98d3fe72b 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt @@ -6,7 +6,7 @@ import ch.tutteli.atrium.creating.Expect * Expects that the property [Throwable.message] of the subject of the assertion is not null, * creates an [Expect] for it and returns it. * - * @return The newly created [Expect] for the property [Throwable.message] of the subject of the assertion + * @return The newly created [Expect] for the property [Throwable.message] of the subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ val Expect.message: Expect @@ -14,9 +14,9 @@ val Expect.message: Expect /** * Expects that the property [Throwable.message] of the subject of the assertion is not null and - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.message(assertionCreator: Expect.() -> Unit): Expect = @@ -33,7 +33,7 @@ fun Expect.message(assertionCreator: Expect.() -> Uni * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed * (this function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.messageContains(expected: Any, vararg otherExpected: Any): Expect = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalAssertions.kt index b32793d84..25a253fc3 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/bigDecimalAssertions.kt @@ -46,7 +46,7 @@ fun Expect.toBe(expected: T): Nothing = throw PleaseUseRepl /** * Expects that the subject of the assertion (a [BigDecimal]) is `null`. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @JvmName("toBeNull") @@ -87,7 +87,7 @@ fun Expect.notToBe(expected: T): Nothing = throw PleaseUseRe * - `expect(BigDecimal("10")).isEqualIncludingScale(BigDecimal("10.0"))` does not hold. * - `expect(BigDecimal("10")).isNumericallyEqualTo(BigDecimal("10.0"))` holds. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isNumericallyEqualTo(expected: T) = @@ -105,7 +105,7 @@ fun Expect.isNumericallyEqualTo(expected: T) = * - `expect(BigDecimal("10")).isNotEqualIncludingScale(BigDecimal("10.0"))` holds. * - `expect(BigDecimal("10")).isNotNumericallyEqualTo(BigDecimal("10.0"))` does not hold. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isNotNumericallyEqualTo(expected: T) = @@ -121,7 +121,7 @@ fun Expect.isNotNumericallyEqualTo(expected: T) = * - `expect(BigDecimal("10")).isEqualIncludingScale(BigDecimal("10.0"))` does not hold. * - `expect(BigDecimal("10")).isNumericallyEqualTo(BigDecimal("10.0"))` holds. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isEqualIncludingScale(expected: T) = @@ -136,7 +136,7 @@ fun Expect.isEqualIncludingScale(expected: T) = * - `expect(BigDecimal("10")).isNotEqualIncludingScale(BigDecimal("10.0"))` holds. * - `expect(BigDecimal("10")).isNotNumericallyEqualTo(BigDecimal("10.0"))` does not hold. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.isNotEqualIncludingScale(expected: T) = diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/floatingPointJvmAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/floatingPointJvmAssertions.kt index 971b5d5b5..eff41ce25 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/floatingPointJvmAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/floatingPointJvmAssertions.kt @@ -18,7 +18,7 @@ import java.math.BigDecimal * * | `subject of the assertion` - [expected] | ≤ [tolerance] * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Expect.toBeWithErrorTolerance(expected: BigDecimal, tolerance: BigDecimal) = diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateAssertions.kt index 4c3d92a46..c289a9eee 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateAssertions.kt @@ -11,7 +11,7 @@ import java.time.chrono.ChronoLocalDate * Expects that the subject of the assertion (a [ChronoLocalDate]) * is before the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -23,7 +23,7 @@ fun Expect.isBefore(expected: ChronoLocalDate): Expect< * Expects that the subject of the assertion (a [ChronoLocalDate]) * is before or equal the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -36,7 +36,7 @@ fun Expect.isBeforeOrEqual(expected: ChronoLocalDate): * Expects that the subject of the assertion (a [ChronoLocalDate]) * is after the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -48,7 +48,7 @@ fun Expect.isAfter(expected: ChronoLocalDate): Expect Expect.isAfterOrEqual(expected: ChronoLocalDate): E * Expects that the subject of the assertion (a [ChronoLocalDate]) * is equal to the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt index c8df5cf00..b966b8ff9 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoLocalDateTimeAssertions.kt @@ -12,7 +12,7 @@ import java.time.chrono.ChronoLocalDateTime * Expects that the subject of the assertion (a [ChronoLocalDateTime]) * is before the [expected] [ChronoLocalDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -24,7 +24,7 @@ fun > Expect.isBefore(expected: * Expects that the subject of the assertion (a [ChronoLocalDateTime]) * is before or equal the [expected] [ChronoLocalDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -37,7 +37,7 @@ fun > Expect.isBeforeOrEqual( * Expects that the subject of the assertion (a [ChronoLocalDateTime]) * is after the [expected] [ChronoLocalDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -50,7 +50,7 @@ fun > Expect.isAfter( * Expects that the subject of the assertion (a [ChronoLocalDateTime]) * is after or equal the [expected] [ChronoLocalDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -63,7 +63,7 @@ fun > Expect.isAfterOrEqual( * Expects that the subject of the assertion (a [ChronoLocalDateTime]) * is equal to the [expected] [ChronoLocalDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt index 72ff95952..d234a5b61 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/chronoZonedDateTimeAssertions.kt @@ -12,7 +12,7 @@ import java.time.chrono.ChronoZonedDateTime * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is before the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -25,7 +25,7 @@ fun > Expect.isBefore( * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is before or equals the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -38,7 +38,7 @@ fun > Expect.isBeforeOrEqual( * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is after the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -51,7 +51,7 @@ fun > Expect.isAfter( * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is after or equal the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -64,7 +64,7 @@ fun > Expect.isAfterOrEqual( * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is equal to the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/fileAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/fileAssertions.kt index fa1d7068f..cc47c6073 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/fileAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/fileAssertions.kt @@ -27,7 +27,7 @@ fun Expect.asPath(): Expect = * The transformation as such is not reflected in reporting. * Use `feature(File::toPath, assertionCreator)` if you want to show the transformation in reporting. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * * @since 0.9.0 */ diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt index 759e51e04..adc5e74c8 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt @@ -15,7 +15,7 @@ import java.time.LocalDate * Creates an [Expect] for the property [LocalDate.year][LocalDate.getYear] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -24,9 +24,9 @@ val Expect.year: Expect /** * Expects that the property [LocalDate.year][LocalDate.getYear]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -38,7 +38,7 @@ fun Expect.year(assertionCreator: Expect.() -> Unit): Ex * Creates an [Expect] for the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -47,9 +47,9 @@ val Expect.month: Expect /** * Expects that the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -61,7 +61,7 @@ fun Expect.month(assertionCreator: Expect.() -> Unit): E * Creates an [Expect] for the property [LocalDate.getDayOfWeek] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -70,9 +70,9 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDate.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -85,7 +85,7 @@ fun Expect.dayOfWeek(assertionCreator: Expect.() - * Creates an [Expect] for the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -94,9 +94,9 @@ val Expect.day: Expect /** * Expects that the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt index 3822dedee..7704555ec 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt @@ -15,7 +15,7 @@ import java.time.LocalDateTime * Creates an [Expect] for the property [LocalDateTime.year][[LocalDateTime.getYear] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -24,9 +24,9 @@ val Expect.year: Expect /** * Expects that the property [LocalDateTime.year][LocalDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -38,7 +38,7 @@ fun Expect.year(assertionCreator: Expect.() -> Unit) * Creates an [Expect] for the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -47,9 +47,9 @@ val Expect.month: Expect /** * Expects that the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -61,7 +61,7 @@ fun Expect.month(assertionCreator: Expect.() -> Unit * Creates an [Expect] for the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -70,9 +70,9 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -84,7 +84,7 @@ fun Expect.dayOfWeek(assertionCreator: Expect. * Creates an [Expect] for the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -93,9 +93,9 @@ val Expect.day: Expect /** * Expects that the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/optionalAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/optionalAssertions.kt index c9bb54ad5..8b711c4d0 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/optionalAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/optionalAssertions.kt @@ -13,7 +13,7 @@ import java.util.* * Shortcut for more or less something like `feature(Optional::isEmpty) { toBe(true) }` * depends on the underlying implementation though. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -27,7 +27,7 @@ fun > Expect.isEmpty(): Expect = addAssertion(ExpectImpl.o * Shortcut for more or less something like `feature(Optional::get)` but with error handling; yet it * depends on the underlying implementation though. * - * @return The newly created [Expect] if the given assertion is success + * @return The newly created [Expect] for the inner type [E]. * @throws AssertionError Might throw an [AssertionError] if the given assertion is not a success. * * @since 0.9.0 @@ -38,7 +38,7 @@ fun > Expect.isPresent(): Expect = ExpectImpl.optional. * Expects that the subject of the assertion (an [Optional]) is present and * that it holds all assertions the given [assertionCreator] creates. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the given assertions are not success. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt index 489bdd81f..73fc6c2f9 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt @@ -10,7 +10,7 @@ import java.nio.file.Path /** * Expects that the subject of the assertion (a [Path]) starts with the [expected] [Path]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -21,7 +21,7 @@ fun Expect.startsWith(expected: Path): Expect = /** * Expects that the subject of the assertion (a [Path]) does not start with the [expected] [Path]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -32,7 +32,7 @@ fun Expect.startsNotWith(expected: Path): Expect = /** * Expects that the subject of the assertion (a [Path]) ends with the expected [Path]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -44,7 +44,7 @@ fun Expect.endsWith(expected: Path): Expect = * Expects that the subject of the assertion (a [Path]) does not end with the expected [Path]; * * @param expected The [Path] provided to the assertion - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -59,7 +59,7 @@ fun Expect.endsNotWith(expected: Path): Expect = * This matcher _resolves_ symbolic links. Therefore, if a symbolic link exists at the location the subject points to, * then the search will continue at that location. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -73,7 +73,7 @@ fun Expect.exists(): Expect = addAssertion(ExpectImpl.path.exis * This matcher _resolves_ symbolic links. Therefore, if a symbolic link exists at the location the subject points to, * then the search will continue at that location. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -85,7 +85,7 @@ fun Expect.existsNot(): Expect = addAssertion(ExpectImpl.path.e * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -95,9 +95,9 @@ val Expect.fileName: Expect /** * Expects that the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -110,7 +110,7 @@ fun Expect.fileName(assertionCreator: Expect.() -> Unit): * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -122,9 +122,9 @@ val Expect.fileNameWithoutExtension: Expect * Expects that the property [Path.fileNameWithoutExtension][ch.tutteli.niok.fileNameWithoutExtension] * (provided via [niok](https://github.com/robstoll/niok)) * of the subject of the assertion holds all assertions the given [assertionCreator] creates for it - * and returns this assertion container. + * and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -136,7 +136,7 @@ fun Expect.fileNameWithoutExtension(assertionCreator: Expect Expect.parent: Expect /** * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the - * given [assertionCreator] creates for it and returns this assertion container. + * given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -160,7 +160,7 @@ fun Expect.parent(assertionCreator: Expect.() -> Unit): Expe * Expects that [other] resolves against this [Path] and creates an [Expect] for the resolved [Path] * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -170,9 +170,9 @@ fun Expect.resolve(other: String): Expect = /** * Expects that [other] resolves against this [Path] and that the resolved [Path] holds all assertions the - * given [assertionCreator] creates for it and returns this assertion container. + * given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -193,7 +193,7 @@ fun Expect.resolve(other: String, assertionCreator: Expect.( * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations * take place. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -209,7 +209,7 @@ fun Expect.isReadable(): Expect = addAssertion(ExpectImpl.path. * Therefore, if a symbolic link exists at the location the subject points to, search will continue * at the location the link points at. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -228,7 +228,7 @@ fun Expect.isWritable(): Expect = addAssertion(ExpectImpl.path. * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations * take place. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -247,7 +247,7 @@ fun Expect.isRegularFile(): Expect = addAssertion(ExpectImpl.pa * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations * take place. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -259,7 +259,7 @@ fun Expect.isDirectory(): Expect = addAssertion(ExpectImpl.path * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -269,9 +269,9 @@ val Expect.extension: Expect /** * Expects that the property [Path.extension][ch.tutteli.niok.extension] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt index 50ce004a6..88dab2dbd 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt @@ -15,7 +15,7 @@ import java.time.ZonedDateTime * Creates an [Expect] for the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -24,9 +24,9 @@ val Expect.year: Expect /** * Expects that the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -38,7 +38,7 @@ fun Expect.year(assertionCreator: Expect.() -> Unit) * Creates an [Expect] for the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -47,9 +47,9 @@ val Expect.month: Expect /** * Expects that the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -61,7 +61,7 @@ fun Expect.month(assertionCreator: Expect.() -> Unit * Creates an [Expect] for the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -70,9 +70,9 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -84,7 +84,7 @@ fun Expect.dayOfWeek(assertionCreator: Expect. * Creates an [Expect] for the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.9.0 */ @@ -93,9 +93,9 @@ val Expect.day: Expect /** * Expects that the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/resultAssertions.kt b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/resultAssertions.kt index 85bf2569e..9f591f0aa 100644 --- a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/resultAssertions.kt +++ b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/kotlin_1_3/resultAssertions.kt @@ -19,7 +19,7 @@ fun > Expect.isSuccess(): Expect = ExpectImpl.result.isSu * Expects that the subject of the assertion (a [Result]) is a Success and * that it holds all assertions the given [assertionCreator] creates. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the given assertions are not success. * * @since 0.9.0 @@ -31,7 +31,7 @@ fun > Expect.isSuccess(assertionCreator: Expect.() -> Uni * Expects that the subject of the assertion (a [Result]) is a Failure and * that it encapsulates an exception of type [TExpected]. * - * @return An assertion container with the new type [TExpected] + * @return An [Expect] with the new type [TExpected] * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -44,7 +44,7 @@ inline fun Expect>.isFailure(): Ex * it encapsulates an exception of type [TExpected] and that the exception * holds all assertions the given [assertionCreator] creates. * - * @return An assertion container with the new type [TExpected] + * @return An [Expect] with the new type [TExpected] * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt index 17980a924..23b0b10c2 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt @@ -8,7 +8,7 @@ import ch.tutteli.atrium.reporting.Reporter /** * Expects that the subject of the assertion is (equal to) [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.toBe(expected: T) = addAssertion(ExpectImpl.any.toBe(this, expected)) @@ -16,7 +16,7 @@ infix fun Expect.toBe(expected: T) = addAssertion(ExpectImpl.any.toBe(thi /** * Expects that the subject of the assertion is not (equal to) [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.notToBe(expected: T) = addAssertion(ExpectImpl.any.notToBe(this, expected)) @@ -24,7 +24,7 @@ infix fun Expect.notToBe(expected: T) = addAssertion(ExpectImpl.any.notTo /** * Expects that the subject of the assertion is the same instance as [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.isSameAs(expected: T) = addAssertion(ExpectImpl.any.isSame(this, expected)) @@ -32,7 +32,7 @@ infix fun Expect.isSameAs(expected: T) = addAssertion(ExpectImpl.any.isSa /** * Expects that the subject of the assertion is not the same instance as [expected]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.isNotSameAs(expected: T) = addAssertion(ExpectImpl.any.isNotSame(this, expected)) @@ -47,7 +47,7 @@ infix fun Expect.isNotSameAs(expected: T) = addAssertion(ExpectImpl.any.i * else notToBeNull(assertionCreatorOrNull) * ``` * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline infix fun Expect.toBeNullIfNullGivenElse( @@ -60,7 +60,7 @@ inline infix fun Expect.toBeNullIfNullGivenElse( * * It delegates to [isA] with [T] as type. * - * @return An assertion container with the non-nullable type [T] (was `T?` before). + * @return An [Expect] with the non-nullable type [T] (was `T?` before). * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @Suppress(/* less magic */ "RemoveExplicitTypeArguments") @@ -72,7 +72,7 @@ inline infix fun Expect.notToBeNull(@Suppress("UNUSED_PARA * * It delegates to [isA] with [T] as type. * - * @return An assertion container with the non-nullable type [T] (was `T?` before) + * @return An [Expect] with the non-nullable type [T] (was `T?` before) * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @Suppress(/* less magic */ "RemoveExplicitTypeArguments") @@ -95,7 +95,7 @@ inline infix fun Expect.notToBeNull(noinline assertionCrea * the element type is actually `String`. Or in other words * `assert(listOf(1, 2)).isA>{}` holds, even though `List` is clearly not a `List`. * - * @return An assertion container with the new type [TSub]. + * @return An [Expect] with the new type [TSub]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ //TODO make infix and add `o` as parameter as soon as https://youtrack.jetbrains.com/issue/KT-21593 is fixed @@ -140,7 +140,7 @@ inline fun Expect<*>.isA(): Expect = * the element type is actually `String`. Or in other words * `assert(listOf(1, 2)).isA>{}` holds, even though `List` is clearly not a `List`. * - * @return An assertion container with the new type [TSub]. + * @return An [Expect] with the new type [TSub]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline infix fun Expect<*>.isA(noinline assertionCreator: Expect.() -> Unit): Expect = @@ -154,7 +154,7 @@ inline infix fun Expect<*>.isA(noinline assertionCreator: E * asserts that 1 is greater than 0. If the first assertion fails, then usually (depending on the configured * [AssertionChecker]) the second assertion is not evaluated. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * * @since 0.10.0 */ @@ -169,7 +169,7 @@ inline infix fun Expect.and(@Suppress("UNUSED_PARAMETER") o: o): Expect Expect.and(assertionCreator: Expect.() -> Unit) = addAssertionsCreatedBy(assertionCreator) @@ -190,5 +190,7 @@ infix fun Expect.and(assertionCreator: Expect.() -> Unit) = addAsserti * o ends with "world" * } * ``` + * + * @return `this` */ inline val Expect.o get() : Expect = this diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt index 9819a0631..d200e747c 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt @@ -6,7 +6,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl /** * Expects that the subject of the assertion (a [Collection]) is an empty [Collection]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = @@ -15,7 +15,7 @@ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty /** * Expects that the subject of the assertion (a [Collection]) is not an empty [Collection]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = @@ -25,15 +25,15 @@ infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Em * Creates an [Expect] for the property [Collection.size] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.size get(): Expect = ExpectImpl.collection.size(this).getExpectOfFeature() /** * Expects that the property [Collection.size] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.size(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt index 80409b017..1e25a5d7d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/comparableAssertions.kt @@ -7,7 +7,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * Expects that the subject of the assertion is less than [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.isLessThan(expected: T) = @@ -17,7 +17,7 @@ infix fun > Expect.isLessThan(expected: T) = * Expects that the subject of the assertion is less than or equal [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.isLessThanOrEqual(expected: T) = @@ -27,7 +27,7 @@ infix fun > Expect.isLessThanOrEqual(expected: T) = * Expects that the subject of the assertion is greater than [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.isGreaterThan(expected: T) = @@ -37,7 +37,7 @@ infix fun > Expect.isGreaterThan(expected: T) = * Expects that the subject of the assertion is greater than or equal [expected]. * The comparison is carried out with [Comparable.compareTo]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.isGreaterThanOrEqual(expected: T) = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt index 4c1787581..07cdea536 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt @@ -25,7 +25,7 @@ interface ListGetStep> { * Makes the assertion that the given [index] is within the bounds of [Expect.subject] and that * the corresponding entry holds all assertions the given [assertionCreator] might create for it. * - * @return This [Expect] to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if a created [Expect]s (by calling [assertionCreator]) * does not hold. * @throws IllegalArgumentException in case the given [assertionCreator] did not create a single assertion. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fun0Assertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fun0Assertions.kt index e329265c1..ed972a79d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fun0Assertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/fun0Assertions.kt @@ -10,7 +10,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * For instance `toThrow>` would only check if the subject is a `MyException` without checking if * the element type is actually `String`. * - * @return An assertion container with the new type [TExpected]. + * @return An [Expect] with the new type [TExpected]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline fun Expect Any?>.toThrow(): Expect = @@ -46,7 +46,7 @@ inline fun Expect Any?>.toThrow(): Exp * For instance `toThrow>` would only check if the subject is a `MyException` without checking if * the element type is actually `String`. * - * @return An assertion container with the new type [TExpected]. + * @return An [Expect] with the new type [TExpected]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline infix fun Expect Any?>.toThrow( @@ -58,6 +58,7 @@ inline infix fun Expect Any?>.toThrow( * Expects that no [Throwable] is thrown at all when calling the subject (a lambda with arity 0, i.e. without arguments) * and changes the subject of the assertion to the return value of type [R]. * + * @return An [Expect] with the new type [R]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun R> Expect.notToThrow(): Expect = ExpectImpl.fun0.isNotThrowing(this).getExpectOfFeature() @@ -66,6 +67,7 @@ fun R> Expect.notToThrow(): Expect = ExpectImpl.fun0.isNotTh * Expects that no [Throwable] is thrown at all when calling the subject (a lambda with arity 0, i.e. without arguments) * and that the corresponding return value holds all assertions the given [assertionCreator] creates. * + * @return An [Expect] with the new type [R]. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun R> Expect.notToThrow( diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt index 86a614c12..e37d1a5be 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt @@ -8,7 +8,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * that every element holds all assertions created by the [assertionCreatorOrNull] or that all elements are `null` * in case [assertionCreatorOrNull] is defined as `null`. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.all(assertionCreatorOrNull: (Expect.() -> Unit)?) = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index a51518408..48f30c173 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -10,7 +10,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * * Delegates to 'contains Pairs(keyValuePair)'. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.contains(keyValuePair: Pair) = @@ -24,7 +24,7 @@ infix fun > Expect.contains(keyValuePair: Pair) * in [keyValuePairs] is defined as `'a' to 1` and another one is defined as `'a' to 1` as well, then both match, * even though they match the same entry. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.contains(keyValuePairs: Pairs): Expect = @@ -36,7 +36,7 @@ infix fun > Expect.contains(keyValuePairs: Pairs> Expect.contains(keyValue: KeyValue): Expect = @@ -52,7 +52,7 @@ inline infix fun > Expect.contains(key * [keyValues] is defined as `Key('a') { isGreaterThan(0) }` and another one is defined as `Key('a') { isLessThan(2) }` * , then both match, even though they match the same entry. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ inline infix fun > Expect.contains(keyValues: All>) = @@ -61,7 +61,7 @@ inline infix fun > Expect.contains(key /** * Expects that the subject of the assertion (a [Map]) contains the given [key]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.containsKey(key: K) = addAssertion(ExpectImpl.map.containsKey(this, key)) @@ -69,7 +69,7 @@ infix fun > Expect.containsKey(key: K) = addAssertion(Ex /** * Expects that the subject of the assertion (a [Map]) does not contain the given [key]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.containsNotKey(key: K) = @@ -80,7 +80,7 @@ infix fun > Expect.containsNotKey(key: K) = * creates an [Expect] for the corresponding value and returns the newly created assertion container, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect] for the feature. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the given [key] does not exist. */ infix fun > Expect.getExisting(key: K): Expect = @@ -99,16 +99,16 @@ infix fun > Expect.getExisting(key: Key): MapGetOp * Creates an [Expect] for the property [Map.keys] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect] for the feature. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.keys: Expect> get() = keys(this).getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.keys(assertionCreator: Expect>.() -> Unit): Expect = @@ -119,7 +119,7 @@ private fun > keys(e: Expect) = ExpectImpl.feature.prope /** * Expects that the subject of the assertion (a [Map]) is an empty [Map]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = @@ -128,7 +128,7 @@ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Em /** * Expects that the subject of the assertion (a [Map]) is not an empty [Map]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = @@ -138,16 +138,16 @@ infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: * Creates an [Expect] for the property [Map.values] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect] for the feature. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.values: Expect> get() = values().getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.values(assertionCreator: Expect>.() -> Unit): Expect = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt index 47ba49797..499d296b8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt @@ -11,7 +11,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * block. Yet, the actual behaviour depends on implementation - could also be fail fast for instance or augment * reporting etc. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.isKeyValue(keyValuePair: Pair): Expect = @@ -21,16 +21,16 @@ infix fun > Expect.isKeyValue(keyValuePair: Pair> Expect.key: Expect get() = ExpectImpl.map.entry.key(this).getExpectOfFeature() /** * Expects that the property [Map.Entry.key] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.key(assertionCreator: Expect.() -> Unit): Expect = @@ -40,16 +40,16 @@ infix fun > Expect.key(assertionCreator: Expect. * Creates an [Expect] for the property [Map.Entry.value] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.value: Expect get() = ExpectImpl.map.entry.value(this).getExpectOfFeature() /** * Expects that the property [Map.Entry.value] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.value(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt index e9ee467b8..e19b5cef8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt @@ -7,15 +7,15 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * Creates an [Expect] for the property [Pair.first] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.first get() : Expect = ExpectImpl.pair.first(this).getExpectOfFeature() /** * Expects that the property [Pair.first] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.first(assertionCreator: Expect.() -> Unit): Expect = @@ -25,15 +25,15 @@ infix fun > Expect.first(assertionCreator: Expect.() * Creates an [Expect] for the property [Pair.second] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ val > Expect.second get() : Expect = ExpectImpl.pair.second(this).getExpectOfFeature() /** * Expects that the property [Pair.second] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.second(assertionCreator: Expect.() -> Unit): Expect = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt index 3275f15b5..73e955711 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt @@ -1,4 +1,3 @@ -import ch.tutteli.atrium.creating.AssertionPlant import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl.changeSubject @@ -20,7 +19,7 @@ fun > Expect.asIterable(): Expect> * The transformation as such is not reflected in reporting. * Use `feature(Sequence::asIterable, assertionCreator)` if you want to show the transformation in reporting. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. */ infix fun > Expect.asIterable(assertionCreator: Expect>.() -> Unit): Expect = apply { asIterable().addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt index c7bd107d6..ab78421e0 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt @@ -11,7 +11,7 @@ import java.time.chrono.ChronoLocalDate * Expects that the subject of the assertion (a [ChronoLocalDate]) * is before the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -23,7 +23,7 @@ infix fun Expect.isBefore(expected: ChronoLocalDate): E * Expects that the subject of the assertion (a [ChronoLocalDate]) * is before or equal the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -36,7 +36,7 @@ infix fun Expect.isBeforeOrEqual(expected: ChronoLocalD * Expects that the subject of the assertion (a [ChronoLocalDate]) * is after the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -48,7 +48,7 @@ infix fun Expect.isAfter(expected: ChronoLocalDate): Ex * Expects that the subject of the assertion (a [ChronoLocalDate]) * is after or equal the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -60,7 +60,7 @@ infix fun Expect.isAfterOrEqual(expected: ChronoLocalDa * Expects that the subject of the assertion (a [ChronoLocalDate]) * is equal to the [expected] [ChronoLocalDate]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt index 0ae0b9b37..63871d9cd 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt @@ -12,7 +12,7 @@ import java.time.chrono.ChronoZonedDateTime * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is before the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -25,7 +25,7 @@ infix fun > Expect.isBefore( * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is before or equals the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -38,7 +38,7 @@ infix fun > Expect.isBeforeOrEqu * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is after the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -51,7 +51,7 @@ infix fun > Expect.isAfter( * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is after or equal the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -64,7 +64,7 @@ infix fun > Expect.isAfterOrEqua * Expects that the subject of the assertion (a [ChronoZonedDateTime]) * is equal to the [expected] [ChronoZonedDateTime]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt index 7c88de900..4c6e60129 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt @@ -27,7 +27,7 @@ fun Expect.asPath(): Expect = * The transformation as such is not reflected in reporting. * Use `feature(File::toPath, assertionCreator)` if you want to show the transformation in reporting. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * * @since 0.10.0 */ diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt index f3d58a428..d43f73233 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt @@ -15,7 +15,7 @@ import java.time.LocalDate * Creates an [Expect] for the property [LocalDate.year][LocalDate.getYear] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -24,9 +24,9 @@ val Expect.year: Expect /** * Expects that the property [LocalDate.year][LocalDate.getYear]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -38,7 +38,7 @@ infix fun Expect.year(assertionCreator: Expect.() -> Uni * Creates an [Expect] for the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -47,9 +47,9 @@ val Expect.month: Expect /** * Expects that the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -61,7 +61,7 @@ infix fun Expect.month(assertionCreator: Expect.() -> Un * Creates an [Expect] for the property [LocalDate.getDayOfWeek] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -70,9 +70,9 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDate.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -85,7 +85,7 @@ infix fun Expect.dayOfWeek(assertionCreator: Expect Expect.day: Expect /** * Expects that the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt index 0ef63dd7e..02149102e 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt @@ -15,7 +15,7 @@ import java.time.LocalDateTime * Creates an [Expect] for the property [LocalDateTime.year][[LocalDateTime.getYear] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -24,9 +24,9 @@ val Expect.year: Expect /** * Expects that the property [LocalDateTime.year][LocalDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -38,7 +38,7 @@ infix fun Expect.year(assertionCreator: Expect.() -> * Creates an [Expect] for the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -47,9 +47,9 @@ val Expect.month: Expect /** * Expects that the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -61,7 +61,7 @@ infix fun Expect.month(assertionCreator: Expect.() - * Creates an [Expect] for the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -70,9 +70,9 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -84,7 +84,7 @@ infix fun Expect.dayOfWeek(assertionCreator: Expect Expect.day: Expect /** * Expects that the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 2313c1606..bddfed398 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -10,7 +10,7 @@ import java.nio.file.Path /** * Expects that the subject of the assertion (a [Path]) starts with the [expected] [Path]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -21,7 +21,7 @@ infix fun Expect.startsWith(expected: Path): Expect = /** * Expects that the subject of the assertion (a [Path]) does not start with the [expected] [Path]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -32,7 +32,7 @@ infix fun Expect.startsNotWith(expected: Path): Expect = /** * Expects that the subject of the assertion (a [Path]) ends with the expected [Path]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -44,7 +44,7 @@ infix fun Expect.endsWith(expected: Path): Expect = * Expects that the subject of the assertion (a [Path]) does not end with the expected [Path]; * * @param expected The [Path] provided to the assertion - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -59,7 +59,7 @@ infix fun Expect.endsNotWith(expected: Path): Expect = * This matcher _resolves_ symbolic links. Therefore, if a symbolic link exists at the location the subject points to, * then the search will continue at that location. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -74,7 +74,7 @@ infix fun Expect.to(@Suppress("UNUSED_PARAMETER") exist: exist): E * This matcher _resolves_ symbolic links. Therefore, if a symbolic link exists at the location the subject points to, * then the search will continue at that location. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -87,7 +87,7 @@ infix fun Expect.notTo(@Suppress("UNUSED_PARAMETER") exist: exist) * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -97,9 +97,9 @@ val Expect.fileName: Expect /** * Expects that the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -112,7 +112,7 @@ infix fun Expect.fileName(assertionCreator: Expect.() -> U * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -124,9 +124,9 @@ val Expect.fileNameWithoutExtension: Expect * Expects that the property [Path.fileNameWithoutExtension][ch.tutteli.niok.fileNameWithoutExtension] * (provided via [niok](https://github.com/robstoll/niok)) * of the subject of the assertion holds all assertions the given [assertionCreator] creates for it - * and returns this assertion container. + * and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -138,7 +138,7 @@ infix fun Expect.fileNameWithoutExtension(assertionCreator: Expect * Expects that this [Path] has a [parent][Path.getParent] and creates an [Expect] for it, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -148,9 +148,9 @@ val Expect.parent: Expect /** * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the - * given [assertionCreator] creates for it and returns this assertion container. + * given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -162,7 +162,7 @@ infix fun Expect.parent(assertionCreator: Expect.() -> Unit) * Expects that [other] resolves against this [Path] and creates an [Expect] for the resolved [Path] * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -183,7 +183,7 @@ infix fun Expect.resolve(other: String): Expect = * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations * take place. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -200,7 +200,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") readable: read * Therefore, if a symbolic link exists at the location the subject points to, search will continue * at the location the link points at. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -220,7 +220,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") writable: writ * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations * take place. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -240,7 +240,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aRegularFile: * Its result, in particular its extended explanations, may be wrong if such concurrent file system operations * take place. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -253,7 +253,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aDirectory: aD * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -263,9 +263,9 @@ val Expect.extension: Expect /** * Expects that the property [Path.extension][ch.tutteli.niok.extension] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt index ed8a39883..4714c3c69 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt @@ -15,7 +15,7 @@ import java.time.ZonedDateTime * Creates an [Expect] for the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion, * so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -24,9 +24,9 @@ val Expect.year: Expect /** * Expects that the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -38,7 +38,7 @@ infix fun Expect.year(assertionCreator: Expect.() -> * Creates an [Expect] for the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -47,9 +47,9 @@ val Expect.month: Expect /** * Expects that the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -61,7 +61,7 @@ infix fun Expect.month(assertionCreator: Expect.() - * Creates an [Expect] for the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] * of the subject of the assertion, so that further fluent calls are assertions about it. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. * * @since 0.10.0 */ @@ -70,9 +70,9 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -84,7 +84,7 @@ infix fun Expect.dayOfWeek(assertionCreator: Expect Expect.day: Expect /** * Expects that the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingAssertionContainer.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingAssertionContainer.kt index 2fa00f288..d3cb2ecf7 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingAssertionContainer.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/CollectingAssertionContainer.kt @@ -4,12 +4,12 @@ import ch.tutteli.atrium.assertions.Assertion /** * Represents a container for [Assertion] which is intended to serve as receiver object for lambdas which create - * [Assertion]s, in which this assertion container collects the assertions created this ways. + * [Assertion]s, in which this [Expect] collects the assertions created this ways. * * This container does not offer reporting capabilities in contrast to [ReportingAssertionContainer]. * It merely offers a method to [getAssertions] (the collected ones). * - * @param T The type of the [subject] of this assertion container. + * @param T The type of the [subject] of this [Expect]. */ interface CollectingAssertionContainer : Expect { diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt index 0852e3cfa..14e4e45a1 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/Expect.kt @@ -37,7 +37,7 @@ interface Expect : SubjectProvider { * * @param assertionCreator The receiver function which should create and add assertions to this container. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] depending on the concrete implementation. */ fun addAssertionsCreatedBy(assertionCreator: Expect.() -> Unit): Expect @@ -47,7 +47,7 @@ interface Expect : SubjectProvider { * * @param assertion The assertion which will be added to this container. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately * evaluated (see [ReportingAssertionContainer]). @@ -63,7 +63,7 @@ interface Expect : SubjectProvider { * @param expected The expected value, e.g., `5` * @param test Indicates whether the assertion holds or fails. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately * evaluated (see [ReportingAssertionContainer]). */ @@ -78,7 +78,7 @@ interface Expect : SubjectProvider { * @param expected The expected value, e.g., `5` * @param test Indicates whether the assertion holds or fails. * - * @return This assertion container to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case [Assertion]s are immediately * evaluated (see [ReportingAssertionContainer]). */ diff --git a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/FeatureExtractor.kt b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/FeatureExtractor.kt index ab6c987db..0c1027791 100644 --- a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/FeatureExtractor.kt +++ b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/FeatureExtractor.kt @@ -50,7 +50,7 @@ interface FeatureExtractor { * if you want a different representation, then use this parameter where passing `null` still means use the * feature. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ fun extract( originalAssertionContainer: Expect, diff --git a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/SubjectChanger.kt b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/SubjectChanger.kt index ebace1334..ca2753902 100644 --- a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/SubjectChanger.kt +++ b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/changers/SubjectChanger.kt @@ -44,7 +44,7 @@ interface SubjectChanger { * [Expect]) then you usually pass `this` (so the instance of [Expect]) for this parameter. * @param transformation Provides the subject. * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ fun unreported( originalAssertionContainer: Expect, @@ -80,7 +80,7 @@ interface SubjectChanger { * change fails since we can then already show to you (in error reporting) what you wanted to assert about * the new subject (which gives you more context to the error). * - * @return The newly created [Expect]. + * @return The newly created [Expect] for the extracted feature. */ fun reported( originalAssertionContainer: Expect, diff --git a/domain/api/extensions/kotlin_1_3/atrium-domain-api-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/kotlin_1_3/creating/ResultAssertions.kt b/domain/api/extensions/kotlin_1_3/atrium-domain-api-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/kotlin_1_3/creating/ResultAssertions.kt index 31e719426..82c421cfa 100644 --- a/domain/api/extensions/kotlin_1_3/atrium-domain-api-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/kotlin_1_3/creating/ResultAssertions.kt +++ b/domain/api/extensions/kotlin_1_3/atrium-domain-api-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/kotlin_1_3/creating/ResultAssertions.kt @@ -18,10 +18,10 @@ val resultAssertions by lazy { loadSingleService(ResultAssertions::class) } * which an implementation of the domain of Atrium has to provide. */ interface ResultAssertions { - fun > isSuccess(assertionContainer: Expect): ExtractedFeaturePostStep + fun > isSuccess(expect: Expect): ExtractedFeaturePostStep fun isFailure( - assertionContainer: Expect>, + expect: Expect>, expectedType: KClass ): ChangedSubjectPostStep } diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/ExpectImpl.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/ExpectImpl.kt index b94dce233..14529fba2 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/ExpectImpl.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/ExpectImpl.kt @@ -35,8 +35,8 @@ object ExpectImpl { * into another representation (e.g. down-cast `Person` to `Student`) then you should use * [feature.extractor][NewFeatureAssertionsBuilder.extractor] instead. */ - inline fun changeSubject(originalAssertionContainer: Expect) = - SubjectChangerBuilder.create(originalAssertionContainer) + inline fun changeSubject(originalExpect: Expect) = + SubjectChangerBuilder.create(originalExpect) @Deprecated("Do no longer use Assert, use Expect instead - this method was introduced in 0.9.0 to ease the migration from Assert to Expect; will be removed with 1.0.0") @Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith") diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/SubjectChangerBuilder.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/SubjectChangerBuilder.kt index b16be204f..3d902db27 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/SubjectChangerBuilder.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/SubjectChangerBuilder.kt @@ -31,7 +31,7 @@ interface SubjectChangerBuilder { /** * Entry point to use the [SubjectChangerBuilder]. */ - fun create(originalAssertionContainer: Expect): KindStep = KindStepImpl(originalAssertionContainer) + fun create(expect: Expect): KindStep = KindStepImpl(expect) @Deprecated("Do no longer use Assert, use Expect instead - this method was introduced in 0.9.0 to ease the migration from Assert to Expect; will be removed with 1.0.0") @Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith") @@ -75,7 +75,7 @@ interface SubjectChangerBuilder { /** * The previously specified assertion container to which the new [Expect] will delegate assertion checking. */ - val originalAssertionContainer: Expect + val originalExpect: Expect /** @@ -85,7 +85,7 @@ interface SubjectChangerBuilder { * @return The newly created [Expect] for the new subject. */ fun unreported(transformation: (T) -> R): Expect = - subjectChanger.unreported(originalAssertionContainer, transformation) + subjectChanger.unreported(originalExpect, transformation) /** * Entry point of the building process to not only change the subject but also report the change in reporting. @@ -107,11 +107,11 @@ interface SubjectChangerBuilder { /** * The previously specified assertion container to which the new [Expect] will delegate assertion checking. */ - val originalAssertionContainer: Expect + val originalExpect: Expect /** * Uses [DescriptionAnyAssertion.IS_A] as description of the change, - * the given [subType] as representation and tries to perform a down-cast of [originalAssertionContainer]'s + * the given [subType] as representation and tries to perform a down-cast of [originalExpect]'s * [Expect.maybeSubject] to the given type [TSub] */ //TODO once kotlin supports to have type parameters as upper bounds of another type parameter next to `: Any` we should restrict TSub : T & Any @@ -161,7 +161,7 @@ interface SubjectChangerBuilder { /** * The previously specified assertion container to which the new [Expect] will delegate assertion checking. */ - val originalAssertionContainer: Expect + val originalExpect: Expect /** * The previously specified description which describes the kind of subject change. diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/subjectchanger/defaultImpls.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/subjectchanger/defaultImpls.kt index 81697ef87..5e54bd780 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/subjectchanger/defaultImpls.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/subjectchanger/defaultImpls.kt @@ -13,11 +13,11 @@ import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.Translatable class KindStepImpl( - override val originalAssertionContainer: Expect + override val originalExpect: Expect ) : SubjectChangerBuilder.KindStep { override fun reportBuilder(): SubjectChangerBuilder.DescriptionRepresentationStep = - SubjectChangerBuilder.DescriptionRepresentationStep.create(originalAssertionContainer) + SubjectChangerBuilder.DescriptionRepresentationStep.create(originalExpect) } @Suppress("DEPRECATION") @@ -26,21 +26,21 @@ class DeprecatedKindStepImpl( ) : SubjectChangerBuilder.DeprecatedKindStep class DescriptionRepresentationStepImpl( - override val originalAssertionContainer: Expect + override val originalExpect: Expect ) : SubjectChangerBuilder.DescriptionRepresentationStep { override fun withDescriptionAndRepresentation( description: Translatable, representation: Any? ): SubjectChangerBuilder.TransformationStep = SubjectChangerBuilder.TransformationStep.create( - originalAssertionContainer, + originalExpect, description, representation ?: RawString.NULL ) } class TransformationStepImpl( - override val originalAssertionContainer: Expect, + override val originalExpect: Expect, override val description: Translatable, override val representation: Any ) : SubjectChangerBuilder.TransformationStep { @@ -72,7 +72,7 @@ class FinalStepImpl( ) : SubjectChangerBuilder.FinalStep { override fun build(): ChangedSubjectPostStep = - ChangedSubjectPostStep(transformationStep.originalAssertionContainer, + ChangedSubjectPostStep(transformationStep.originalExpect, transform = { transformIt(this, None) }, transformAndApply = { assertionCreator -> transformIt(this, Some(assertionCreator)) } ) diff --git a/domain/builders/extensions/kotlin_1_3/atrium-domain-builders-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/kotlin_1_3/creating/ResultAssertionsBuilder.kt b/domain/builders/extensions/kotlin_1_3/atrium-domain-builders-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/kotlin_1_3/creating/ResultAssertionsBuilder.kt index 86deda1c8..11cc08716 100644 --- a/domain/builders/extensions/kotlin_1_3/atrium-domain-builders-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/kotlin_1_3/creating/ResultAssertionsBuilder.kt +++ b/domain/builders/extensions/kotlin_1_3/atrium-domain-builders-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/kotlin_1_3/creating/ResultAssertionsBuilder.kt @@ -16,12 +16,9 @@ import kotlin.reflect.KClass */ object ResultAssertionsBuilder : ResultAssertions { - override inline fun > isSuccess( - assertionContainer: Expect - ): ExtractedFeaturePostStep = resultAssertions.isSuccess(assertionContainer) + override inline fun > isSuccess(expect: Expect): ExtractedFeaturePostStep = + resultAssertions.isSuccess(expect) - override fun isFailure( - assertionContainer: Expect>, - expectedType: KClass - ) = resultAssertions.isFailure(assertionContainer, expectedType) + override fun isFailure(expect: Expect>, expectedType: KClass) = + resultAssertions.isFailure(expect, expectedType) } diff --git a/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt b/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt index a2845a55c..f86e534b0 100644 --- a/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt +++ b/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt @@ -26,12 +26,12 @@ fun > _isSuccess(expect: Expect): ExtractedFeaturePostStep _isFailure( - assertionContainer: Expect>, + expect: Expect>, expectedType: KClass ): ChangedSubjectPostStep { val throwableExpect = ExpectImpl.feature - .manualFeature(assertionContainer, EXCEPTION) { exceptionOrNull() } + .manualFeature(expect, EXCEPTION) { exceptionOrNull() } .getExpectOfFeature() .withRepresentation { it ?: RawString.create(IS_NOT_FAILURE) } diff --git a/domain/robstoll/extensions/kotlin_1_3/atrium-domain-robstoll-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll.kotlin_1_3/creating/ResultAssertionsImpl.kt b/domain/robstoll/extensions/kotlin_1_3/atrium-domain-robstoll-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll.kotlin_1_3/creating/ResultAssertionsImpl.kt index ad2892552..e1a79f578 100644 --- a/domain/robstoll/extensions/kotlin_1_3/atrium-domain-robstoll-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll.kotlin_1_3/creating/ResultAssertionsImpl.kt +++ b/domain/robstoll/extensions/kotlin_1_3/atrium-domain-robstoll-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll.kotlin_1_3/creating/ResultAssertionsImpl.kt @@ -1,17 +1,15 @@ package ch.tutteli.atrium.domain.robstoll.kotlin_1_3.creating import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.creating.changers.ChangedSubjectPostStep import ch.tutteli.atrium.domain.kotlin_1_3.creating.ResultAssertions import ch.tutteli.atrium.domain.robstoll.lib.kotlin_1_3.creating._isFailure import ch.tutteli.atrium.domain.robstoll.lib.kotlin_1_3.creating._isSuccess import kotlin.reflect.KClass class ResultAssertionsImpl : ResultAssertions { - override fun > isSuccess(assertionContainer: Expect) = _isSuccess(assertionContainer) + override fun > isSuccess(expect: Expect) = + _isSuccess(expect) - override fun isFailure( - assertionContainer: Expect>, - expectedType: KClass - ) = _isFailure(assertionContainer, expectedType) + override fun isFailure(expect: Expect>, expectedType: KClass) = + _isFailure(expect, expectedType) } From 382ce93bdbff375a71c0666427e44becef628a41 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 29 Feb 2020 20:28:51 +0100 Subject: [PATCH 057/142] add feature assertions to the new infix API --- .../api/fluent/en_GB/featureAssertions.kt | 15 +- .../atrium/api/infix/en_GB/anyAssertions.kt | 5 +- .../creating/list/get/builders/ListGetStep.kt | 2 +- .../list/get/builders/impl/ListGetStepImpl.kt | 6 +- .../api/infix/en_GB/featureAssertions.kt | 271 ++++++++++++++++++ .../atrium/api/infix/en_GB/keywords.kt | 10 +- .../api/infix/en_GB/parameterObjects.kt | 30 +- .../api/infix/en_GB/sequenceAssertions.kt | 6 +- .../infix/en_GB/workaround/anyAssertions.kt | 25 ++ .../creating/NewFeatureAssertionsBuilder.kt | 76 ++--- .../impl/featureextractor/defaultImpls.kt | 5 +- 11 files changed, 388 insertions(+), 63 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/workaround/anyAssertions.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 68142486d..f26049fa8 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 @@ -42,7 +42,8 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling the method [f] + * on the current subject of the assertion. * * @since 0.9.0 */ @@ -72,7 +73,8 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling the method [f] + * on the current subject of the assertion. * * @since 0.9.0 */ @@ -106,7 +108,8 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling the method [f] + * on the current subject of the assertion. * * @since 0.9.0 */ @@ -140,7 +143,8 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling the method [f] + * on the current subject of the assertion. * * @since 0.9.0 */ @@ -174,7 +178,8 @@ fun Expect.feature( * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * @return The newly created [Expect] for the return value of calling [f] on the current subject of the assertion. + * @return The newly created [Expect] for the return value of calling the method [f] + * on the current subject of the assertion. * * @since 0.9.0 */ diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt index 23b0b10c2..093148973 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt @@ -171,10 +171,11 @@ inline infix fun Expect.and(@Suppress("UNUSED_PARAMETER") o: o): Expect Expect.and(assertionCreator: Expect.() -> Unit) = addAssertionsCreatedBy(assertionCreator) +infix fun Expect.and(assertionCreator: Expect.() -> Unit): Expect = + addAssertionsCreatedBy(assertionCreator) /** - * Inline property referring actually to `this` and allows to write nicer sub-assertions. + * Inline property referring actually to `this` and allows to write infix assertions within an assertion group block * * For instance, instead of: * ``` diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt index 07cdea536..ffc070a8b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt @@ -23,7 +23,7 @@ interface ListGetStep> { /** * Makes the assertion that the given [index] is within the bounds of [Expect.subject] and that - * the corresponding entry holds all assertions the given [assertionCreator] might create for it. + * the corresponding entry holds all assertions the given [assertionCreator] creates for it. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if a created [Expect]s (by calling [assertionCreator]) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt index b837b17d0..a8f7a637d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt @@ -4,11 +4,11 @@ import ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.ListGetStep import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl -internal class ListGetStepImpl>( +internal class ListGetStepImpl>( override val expect: Expect, override val index: Int ) : ListGetStep { - override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect - = expect.addAssertion(ExpectImpl.list.get(expect, index).collect(assertionCreator)) + override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.list.get(expect, index).addToInitial(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt new file mode 100644 index 000000000..5c0c7abb3 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt @@ -0,0 +1,271 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.assertions.AssertionGroup +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.FeatureExpect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.creating.MetaFeatureOption +import ch.tutteli.atrium.domain.creating.MetaFeature +import kotlin.reflect.* + +/** + * Extracts the [property] out of the current subject of the assertion, + * creates a new [Expect] for it and + * returns it so that subsequent calls are based on the feature. + * + * @return The newly created [Expect] for the given [property]. + * + * @since 0.10.0 + */ +infix fun Expect.feature(property: KProperty1): FeatureExpect = + ExpectImpl.feature.property(this, property).getExpectOfFeature() + +/** + * Extracts the value which is returned when calling the method [f] on the current subject of the assertion, + * creates a new [Expect] for it and + * returns it so that subsequent calls are based on the feature. + * + * Use `feature of(...)` in case the method requires parameters or in case you want to define + * an assertion group block for it. + * + * @return The newly created [Expect] for the return value of calling the method [f] + * on the current subject of the assertion. + * + * @since 0.10.0 + */ +infix fun Expect.feature(f: KFunction1): FeatureExpect = + ExpectImpl.feature.f0(this, f).getExpectOfFeature() + +/** + * Extracts a feature out of the current subject of the assertion using the given [Feature.extractor], + * creates a new [Expect] for it and + * returns it so that subsequent calls are based on the feature. + * + * Use `of(K..., ...)` to create this representation where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX` and potentially the required arguments for a `KFunctionX` where `X` > 1. + * + * @return The newly created [Expect] for the extracted feature. + * + * @since 0.10.0 + */ +infix fun Expect.feature(of: Feature): FeatureExpect = + ExpectImpl.feature.manualFeature(this, of.description, of.extractor).getExpectOfFeature() + +/** + * Extracts a feature out of the current subject of the assertion using the given [FeatureWithCreator.extractor], + * creates a new [Expect] for it, + * applies an assertion group based on the given [FeatureWithCreator.assertionCreator] for the feature and + * returns the initial [Expect] with the current subject. + * + * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX`, the last an `assertionCreator`-lambda and the remaining arguments in-between the + * required arguments in case of a `KFunctionX` where `X` > 1. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. + * + * @since 0.10.0 + */ +infix fun Expect.feature(of: FeatureWithCreator): Expect = + ExpectImpl.feature.manualFeature(this, of.description, of.extractor).addToInitial(of.assertionCreator) + + +/** + * Extracts a feature out of the current subject of the assertion, + * based on the given [provider], + * creates a new [Expect] for it and + * returns it so that subsequent calls are based on the feature. + * + * @param provider Creates a [MetaFeature] where the subject of the assertion is available via + * implicit parameter `it`. Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], + * e.g. `feature { f(it::size) }` + * + * @return The newly created [Expect] for the extracted feature. + * + * @since 0.10.0 + */ +infix fun Expect.feature(provider: MetaFeatureOption.(T) -> MetaFeature): FeatureExpect = + ExpectImpl.feature.genericSubjectBasedFeature(this) { MetaFeatureOption(this).provider(it) }.getExpectOfFeature() + +/** + * Extracts a feature out of the current subject of the assertion, + * based on the given [MetaFeatureOptionWithCreator] + * creates a new [Expect] for it, + * applies an assertion group based on the given [MetaFeatureOptionWithCreator.assertionCreator] for the feature and + * returns the initial [Expect] with the current subject. + * + * Note that you need to enable the new type inference of Kotlin (or use Kotlin 1.4 and above) in order that Kotlin + * is able to infer the types. + * As workaround you can use the overload which expects `MetaFeatureOption.(T) -> MetaFeature` + * and use `it` after the call (import from the package workaround). For instance: + * + * ``` + * // use + * expect(person) feature { f(it::age) } it { o toBe 20 } + * + * // instead of (which causes problems with Kotlin < 1.4) + * expect(person) feature of({ f(it::age) }) { o toBe 20 } + * ``` + * + * @param of Use the function `of({ ... }) { ... }` to create the [MetaFeatureOptionWithCreator] where the first + * argument is a lambda with a [MetaFeatureOption] as receiver which has to create a [MetaFeature] + * where the subject of the assertion is available via implicit parameter `it`. + * Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], + * e.g. `feature of({ f(it::size) }) { o toBe 3 }` + * + * @return An [Expect] for the current subject of the assertion. + * @since 0.10.0 + */ +infix fun Expect.feature(of: MetaFeatureOptionWithCreator): Expect = + ExpectImpl.feature.genericSubjectBasedFeature(this) { + MetaFeatureOption(this).(of.provider)(it) + }.addToInitial(of.assertionCreator) + +/** + * Creates a [MetaFeature] using the given [provider] and [description]. + * + * This can be used to create complex features with a custom description or as workaround where Kotlin is not able to + * infer the types properly. + * + * For instance: + * ``` + * expect(person) feature { f("first underage child", it.children.first { it < 18 }) } + * ``` + * + * @return The newly created [MetaFeature]. + */ +@Suppress("unused" /* unused receiver, but that's fine */) +fun MetaFeatureOption.f(description: String, provider: R): MetaFeature = + MetaFeature(description, provider) + +/** + * Parameter object which contains a [description] of a feature along with an [extractor] + * which actually extracts the feature out of a subject of an assertion. + * + * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX` and the remaining arguments are the required arguments in case of a `KFunctionX` + * where `X` > 1. + * + * @property description The description of the feature. + * @property extractor The extractor which extracts the feature out of the subject of the assertion. + + * @since 0.10.0 + */ +data class Feature(val description: String, val extractor: (T) -> R) + +/** + * Parameter object which contains a [description] of a feature along with an [extractor] + * which actually extracts the feature out of a subject of an assertion + an [assertionCreator] + * which defines assertions for the feature. + * + * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX`, the last an [assertionCreator]-lambda and the remaining arguments in-between the + * required arguments in case of a `KFunctionX` where `X` > 1. + * + * @property description The description of the feature. + * @property extractor The extractor which extracts the feature out of the subject of the assertion. + * @property assertionCreator The `assertionCreator`-lambda which defines assertions for the feature. + * + * @since 0.10.0 + */ +data class FeatureWithCreator( + val description: String, + val extractor: (T) -> R, + val assertionCreator: Expect.() -> Unit +) + + +//@formatter:off +/** + * Helper function to create a [Feature] based on a [KFunction2] + arguments. + */ +fun of(f: KFunction2, a1: A1): Feature = + Feature(f.name) { f.invoke(it, a1) } + +/** + * Helper function to create a [Feature] based on a [KFunction3] + arguments. + */ +fun of(f: KFunction3, a1: A1, a2: A2): Feature = + Feature(f.name) { f.invoke(it, a1, a2) } + +/** + * Helper function to create a [Feature] based on a [KFunction4] + arguments. + */ +fun of(f: KFunction4, a1: A1, a2: A2, a3: A3): Feature = + Feature(f.name) { f.invoke(it, a1, a2, a3) } + +/** + * Helper function to create a [Feature] based on a [KFunction5] + arguments. + */ +fun of(f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4): Feature = + Feature(f.name) { f.invoke(it, a1, a2, a3, a4) } + +/** + * Helper function to create a [Feature] based on a [KFunction5] + arguments. + */ +fun of(f: KFunction6, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): Feature = + Feature(f.name) { f.invoke(it, a1, a2, a3, a4, a5) } + +/** + * Helper function to create a [FeatureWithCreator] based on a [KProperty1] + [assertionCreator]. + */ +fun of(property: KProperty1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(property.name, { property.invoke(it) }, assertionCreator) + +/** + * Helper function to create a [FeatureWithCreator] based on a [KFunction1] + [assertionCreator]. + */ +fun of(f: KFunction1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(f.name, { f.invoke(it) }, assertionCreator) + +/** + * Helper function to create a [FeatureWithCreator] based on a [KFunction2] + arguments + [assertionCreator]. + */ +fun of(f: KFunction2, a1: A1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(f.name, { f.invoke(it, a1) }, assertionCreator) + +/** + * Helper function to create a [FeatureWithCreator] based on a [KFunction3] + arguments + [assertionCreator]. + */ +fun of(f: KFunction3, a1: A1, a2: A2, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(f.name, { f.invoke(it, a1, a2) }, assertionCreator) + +/** + * Helper function to create a [FeatureWithCreator] based on a [KFunction4] + arguments + [assertionCreator]. + */ +fun of(f: KFunction4, a1: A1, a2: A2, a3: A3, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(f.name, { f.invoke(it, a1, a2, a3) }, assertionCreator) + +/** + * Helper function to create a [FeatureWithCreator] based on a [KFunction5] + arguments + [assertionCreator]. + */ +fun of(f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(f.name, { f.invoke(it, a1, a2, a3, a4) }, assertionCreator) +//@formatter:on + + +/** + * Parameter object which combines a lambda with a [MetaFeatureOption] receiver (called [provider]) + * and an [assertionCreator]. + * + * Use the function `of({ ... }) { ... }` to create this representation where the first + * argument is a lambda with a [MetaFeatureOption] as receiver which has to create a [MetaFeature] + * where the subject of the assertion is available via implicit parameter `it`. + * Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], + * e.g. `feature of({ f(it::size) }) { o toBe 3 }` + * + * @since 0.10.0 + */ +data class MetaFeatureOptionWithCreator( + val provider: MetaFeatureOption.(T) -> MetaFeature, + val assertionCreator: Expect.() -> Unit +) + +/** + * Helper function to create a [MetaFeatureOptionWithCreator] based on a lambda with + * [MetaFeatureOption] receiver (has to return a [MetaFeature]) and an [assertionCreator]. + */ +fun of( + provider: MetaFeatureOption.(T) -> MetaFeature, + assertionCreator: Expect.() -> Unit +): MetaFeatureOptionWithCreator = MetaFeatureOptionWithCreator(provider, assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 8f1bbc3b9..e6b45b239 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -27,40 +27,48 @@ object Blank : Keyword /** * Represents the pseudo keyword `contain` as in [to] `contain`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ object contain : Keyword /** * Represents the pseudo keyword `case` as in [ignoring] `case`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ object case : Keyword /** * Represents the pseudo keyword `entries` as in [grouped] `entries`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ object entries : Keyword /** * Represents the pseudo keyword `group` as in [within] `group`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ object group : Keyword /** * Represents a filler, a pseudo keyword where there isn't really a good keyword. - * A reader should skip this filler without reading it. For instance, `contains o atleast 1...` should be read as + * A reader should skip this filler without reading it. For instance, `contains o atLeast 1...` should be read as * `contains at least once...` * + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * * @since 0.10.0 */ object o : Keyword /** * Represents the pseudo keyword `only` as in [and] `only`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ object only : Keyword /** * Represents the pseudo keyword `order` as in [inAny] `order`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. */ object order : Keyword diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt index ee945e498..bcd7cef2b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt @@ -3,32 +3,34 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.VarArgHelper +/** + * Parameter object to express `T, vararg T`. + */ +class All(override val expected: T, override vararg val otherExpected: T) : VarArgHelper + /** * Wrapper for a single index -- can be used as distinguishable type for an overload where Int is already in use. */ data class Index(val index: Int) data class Key(val key: K) -/** - * Parameter object to express `T, vararg T` in the infix-api. - */ -class All(override val expected: T, override vararg val otherExpected: T) : VarArgHelper - -/** - * Parameter object to express `Pair, vararg Pair` in the infix-api. - */ -class Pairs( - override val expected: Pair, - override vararg val otherExpected: Pair -) : VarArgHelper> - /** * Parameter object to express a key/value [Pair] whose value type is a lambda with an - * [Assert][AssertionPlant] receiver, which means one can either pass a lambda or `null`. + * [Expect] receiver, which means one can either pass a lambda or `null`. */ data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull override fun toString(): String = "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" } + + + +/** + * Parameter object to express `Pair, vararg Pair`. + */ +class Pairs( + override val expected: Pair, + override vararg val otherExpected: Pair +) : VarArgHelper> diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt index 73e955711..63912e893 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt @@ -1,3 +1,5 @@ +package ch.tutteli.atrium.api.infix.en_GB + import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl.changeSubject @@ -9,8 +11,8 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl.changeSubject * * @return The newly created [Expect] for the transformed subject. */ -fun > Expect.asIterable(): Expect> - = changeSubject(this).unreported { it.asIterable() } +fun > Expect.asIterable(): Expect> = + changeSubject(this).unreported { it.asIterable() } /** * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/workaround/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/workaround/anyAssertions.kt new file mode 100644 index 000000000..2c0b63365 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/workaround/anyAssertions.kt @@ -0,0 +1,25 @@ +package ch.tutteli.atrium.api.infix.en_GB.workaround + +import ch.tutteli.atrium.api.infix.en_GB.and +import ch.tutteli.atrium.creating.Expect + +/** + * Can be used to create a group of sub assertions when using the fluent API. + * + * Intended to be used in combination with feature assertions where Kotlin < 1.4 is not able to infer the correct type. + * For instance: + * ``` + * // use + * expect(person) feature { f(it::age) } it { o toBe 20 } + * + * // instead of (which causes problems with Kotlin < 1.4) + * expect(person) feature of({ f(it::age) }) { o toBe 20 } + * ``` + * + * Note that this workaround will be removed in some minor version after a major version with Kotlin 1.4 support + * (most likely with Atrium v1.1.0 where Atrium v1.0.0 requires Kotlin 1.4) + * + * @return An [Expect] for the current subject of the assertion. + */ +@Suppress("NOTHING_TO_INLINE" /* inline so that one does not actually call `it` on binary level */) +inline infix fun Expect.it(noinline assertionCreator: Expect.() -> Unit): Expect = and(assertionCreator) diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/NewFeatureAssertionsBuilder.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/NewFeatureAssertionsBuilder.kt index 4cf5ddc9c..0ecd76652 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/NewFeatureAssertionsBuilder.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/NewFeatureAssertionsBuilder.kt @@ -80,23 +80,16 @@ object NewFeatureAssertionsBuilder : NewFeatureAssertions { description: Translatable, provider: T.() -> R ): ExtractedFeaturePostStep = - genericFeature(expect, createMetaFeature(expect, description, provider)) + genericFeature(expect, ExpectImpl.feature.meta.create(expect, description, provider)) fun genericSubjectBasedFeature( expect: Expect, provider: (T) -> MetaFeature ): ExtractedFeaturePostStep = ExpectImpl.feature.genericFeature( expect, - expect.maybeSubject.fold(this::createFeatureSubjectNotDefined) { provider(it) } + ExpectImpl.feature.meta.createSubjectBased(expect, provider) ) - private fun createFeatureSubjectNotDefined(): MetaFeature = - MetaFeature( - ErrorMessages.DEDSCRIPTION_BASED_ON_SUBJECT, - RawString.create(ErrorMessages.REPRESENTATION_BASED_ON_SUBJECT_NOT_DEFINED), - None - ) - override inline fun genericFeature( expect: Expect, metaFeature: MetaFeature @@ -107,30 +100,7 @@ object NewFeatureAssertionsBuilder : NewFeatureAssertions { description: String, provider: (T) -> R ): ExtractedFeaturePostStep = - genericFeature(expect, createMetaFeature(expect, description, provider)) - - private fun createMetaFeature( - expect: Expect, - description: String, - provider: (T) -> R - ): MetaFeature = createMetaFeature(expect, Untranslatable(description), provider) - - private fun createMetaFeature( - expect: Expect, - description: Translatable, - provider: (T) -> R - ): MetaFeature { - return expect.maybeSubject.fold({ - MetaFeature( - description, - RawString.create(ErrorMessages.REPRESENTATION_BASED_ON_SUBJECT_NOT_DEFINED), - None - ) - }) { - val prop = provider(it) - MetaFeature(description, prop, Some(prop)) - } - } + genericFeature(expect, ExpectImpl.feature.meta.create(expect, description, provider)) /** * Returns [MetaFeatureBuilder] which helps to create a [MetaFeature]. @@ -143,6 +113,7 @@ object NewFeatureAssertionsBuilder : NewFeatureAssertions { * into an overload ambiguity, then either [p] (for property) or one of the `fN` functions (e.g. [f2] for * a function which expects 2 arguments). */ +//TODO move to API, this could potentially be different per API class MetaFeatureOption(private val expect: Expect) { /** @@ -338,4 +309,43 @@ object MetaFeatureBuilder { fun f5(expect: Expect<*>, f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) = MetaFeature(coreFactory.newMethodCallFormatter().formatCall(f.name, arrayOf(a1, a2, a3, a4, a5)), f.invoke(a1, a2, a3, a4, a5)) //@formatter:on + + /** + * creates a [MetaFeature] which is entirely based on the subject (i.e. also the description). + */ + fun createSubjectBased( + expect: Expect, + provider: (T) -> MetaFeature + ): MetaFeature = expect.maybeSubject.fold(this::createFeatureSubjectNotDefined) { provider(it) } + + private fun createFeatureSubjectNotDefined(): MetaFeature = + MetaFeature( + ErrorMessages.DEDSCRIPTION_BASED_ON_SUBJECT, + RawString.create(ErrorMessages.REPRESENTATION_BASED_ON_SUBJECT_NOT_DEFINED), + None + ) + + fun create( + expect: Expect, + description: String, + provider: (T) -> R + ): MetaFeature = create(expect, Untranslatable(description), provider) + + fun create( + expect: Expect, + description: Translatable, + provider: (T) -> R + ): MetaFeature { + return expect.maybeSubject.fold({ + MetaFeature( + description, + RawString.create(ErrorMessages.REPRESENTATION_BASED_ON_SUBJECT_NOT_DEFINED), + None + ) + }) { + val feature = provider(it) + MetaFeature(description, feature, Some(feature)) + } + } + } diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/defaultImpls.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/defaultImpls.kt index 67f000595..c45509e06 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/defaultImpls.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/changers/impl/featureextractor/defaultImpls.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.core.None import ch.tutteli.atrium.core.Option import ch.tutteli.atrium.core.Some import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.FeatureExpect import ch.tutteli.atrium.domain.builders.creating.changers.FeatureExtractorBuilder import ch.tutteli.atrium.domain.builders.creating.changers.FeatureOptions import ch.tutteli.atrium.domain.creating.changers.ExtractedFeaturePostStep @@ -68,13 +69,13 @@ class FinalStepImpl( extractAndApply = { assertionCreator -> extractIt(this, Some(assertionCreator)) } ) - private fun extractIt(expect: Expect, subAssertions: Option.() -> Unit>) = + private fun extractIt(expect: Expect, maybeSubAssertions: Option.() -> Unit>): FeatureExpect = featureExtractor.extract( expect, featureOptions?.description ?: featureExtractionStep.description, featureExtractionStep.representationForFailure, featureExtraction, - subAssertions, + maybeSubAssertions, featureOptions?.representationInsteadOfFeature ) } From 7514f448446ade8d9ecf495ef1ad84b42aa522d3 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 29 Feb 2020 23:08:06 +0100 Subject: [PATCH 058/142] transform List.get and Map.getExisting use fun instead of param obj moreover: - move param objects to own package so that they are not automatically available when one adds an `import ch.tutteli.atrium.api.infix.*` statement - simplify MapAssertionsSpec by introducing mfun2 which covers most types (also in fluent-en_GB) --- .../api/fluent/en_GB/Fun0AssertionsSpec.kt | 17 +- .../fluent/en_GB/IterableAllAssertionsSpec.kt | 3 +- .../api/fluent/en_GB/MapAssertionsSpec.kt | 61 +++---- .../infix/en_GB/creating/feature/Feature.kt | 18 ++ .../creating/feature/FeatureWithCreator.kt | 25 +++ .../feature/MetaFeatureOptionWithCreator.kt | 22 +++ .../en_GB/creating/list/IndexWithCreator.kt | 14 ++ .../creating/list/get/builders/ListGetStep.kt | 40 ----- .../list/get/builders/impl/ListGetStepImpl.kt | 14 -- .../en_GB/creating/map/KeyWithCreator.kt | 14 ++ .../creating/map/get/builders/MapGetOption.kt | 47 ----- .../map/get/builders/impl/MapGetOptionImpl.kt | 14 -- .../api/infix/en_GB/featureAssertions.kt | 80 +++------ .../atrium/api/infix/en_GB/listAssertions.kt | 23 ++- .../atrium/api/infix/en_GB/mapAssertions.kt | 25 ++- .../api/infix/en_GB/parameterObjects.kt | 11 +- .../api/infix/en_GB/AnyAssertionsSpec.kt | 2 +- .../infix/en_GB/CollectionAssertionsSpec.kt | 6 +- .../infix/en_GB/IterableAllAssertionsSpec.kt | 21 +-- .../infix/en_GB/ListFeatureAssertionsSpec.kt | 33 ++-- .../api/infix/en_GB/MapAssertionsSpec.kt | 168 ++++++++++-------- .../infix/en_GB/MapFeatureAssertionsSpec.kt | 41 +++-- .../domain/builders/utils/VarArgHelper.kt | 2 +- 23 files changed, 328 insertions(+), 373 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt delete mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt delete mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt delete mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt delete mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt index 504be460c..6ec6d3c08 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt @@ -4,21 +4,16 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.feature0 import ch.tutteli.atrium.specs.feature1 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withFeatureSuffix class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpec( - "toThrow" to Companion::toThrowFeature, - "toThrow" to Companion::toThrow, + ("toThrow" to ::toThrowFeature).withFeatureSuffix(), + "toThrow" to ::toThrow, feature0<() -> Int, Int>(Expect<() -> Int>::notToThrow), feature1<() -> Int, Expect.() -> Unit, Int>(Expect<() -> Int>::notToThrow), "⚬ ", "» " ) { - companion object { - fun toThrowFeature(expect: Expect Any?>) = expect.toThrow() - fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = - expect.toThrow { assertionCreator() } - } - @Suppress("unused", "UNUSED_VALUE", "UNUSED_VARIABLE") private fun ambiguityTest() { val a1: Expect<() -> Any?> = notImplemented() @@ -37,3 +32,9 @@ class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpe val r8: Expect = a2.notToThrow {} } } + +private fun toThrowFeature(expect: Expect Any?>) = + expect.toThrow() + +private fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = + expect.toThrow { assertionCreator() } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt index 760bb7016..46c1c7620 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt @@ -3,10 +3,11 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix object IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAllAssertionsSpec( fun1(Expect>::all), - fun1(Expect>::all), + fun1(Expect>::all).withNullableSuffix(), "◆ ", "❗❗ ", "⚬ ", "» ", "▶ ", "◾ " ) { @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt index 867eda698..702158296 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt @@ -2,46 +2,26 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments -import ch.tutteli.atrium.specs.fun0 -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.fun2 -import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.* +import kotlin.jvm.JvmName import kotlin.reflect.KFunction3 +private fun mfun2( + f: KFunction3>, Pair, Array>, Expect>> +) = fun2(f) + class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( - fun2, Pair, Array>>(Expect>::contains), - fun2, Pair, Array>>(Expect>::contains), - "${containsKeyWithValueAssertionsFun.name} ${KeyValue::class.simpleName}" to Companion::containsKeyValue, - "${containsKeyWithNullableValueAssertionsFun.name} ${KeyValue::class.simpleName}" to Companion::containsNullable, + mfun2(Expect>::contains), + mfun2(Expect>::contains).withNullableSuffix(), + mfun2.() -> Unit>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, + mfun2.() -> Unit)?>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }.withNullableSuffix(), fun1(Expect>::containsKey), - fun1(Expect>::containsKey), + fun1(Expect>::containsKey).withNullableSuffix(), fun1(Expect>::containsNotKey), - fun1(Expect>::containsNotKey), + fun1(Expect>::containsNotKey).withNullableSuffix(), fun0(Expect>::isEmpty), fun0(Expect>::isNotEmpty) ) { - companion object { - //@formatter:off - private val containsKeyWithValueAssertionsFun : KFunction3>, KeyValue, Array>, Expect>> = Expect>::contains - private val containsKeyWithNullableValueAssertionsFun : KFunction3>, KeyValue, Array>, Expect>> = Expect>::contains - //@formatter:on - - fun containsKeyValue( - expect: Expect>, - keyValue: Pair.() -> Unit>, - otherKeyValues: Array.() -> Unit>> - ) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect.contains(first, *others) - } - - fun containsNullable( - expect: Expect>, - keyValue: Pair.() -> Unit)?>, - otherKeyValues: Array.() -> Unit)?>> - ) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect.contains(first, *others) - } - } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -208,3 +188,20 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( } } + +private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit>, + otherKeyValues: Array.() -> Unit>> +) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect.contains(first, *others) +} + +@JvmName("containsNullable") +private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit)?>, + otherKeyValues: Array.() -> Unit)?>> +) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect.contains(first, *others) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt new file mode 100644 index 000000000..caa8a9d4f --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt @@ -0,0 +1,18 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.feature + +import kotlin.reflect.KProperty1 + +/** + * Parameter object which contains a [description] of a feature along with an [extractor] + * which actually extracts the feature out of a subject of an assertion. + * + * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX` and the remaining arguments are the required arguments in case of a `KFunctionX` + * where `X` > 1. + * + * @property description The description of the feature. + * @property extractor The extractor which extracts the feature out of the subject of the assertion. + + * @since 0.10.0 + */ +data class Feature(val description: String, val extractor: (T) -> R) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt new file mode 100644 index 000000000..3aeddb1ce --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt @@ -0,0 +1,25 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.feature + +import ch.tutteli.atrium.creating.Expect +import kotlin.reflect.KProperty1 + +/** + * Parameter object which contains a [description] of a feature along with an [extractor] + * which actually extracts the feature out of a subject of an assertion + an [assertionCreator] + * which defines assertions for the feature. + * + * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX`, the last an [assertionCreator]-lambda and the remaining arguments in-between the + * required arguments in case of a `KFunctionX` where `X` > 1. + * + * @property description The description of the feature. + * @property extractor The extractor which extracts the feature out of the subject of the assertion. + * @property assertionCreator The `assertionCreator`-lambda which defines assertions for the feature. + * + * @since 0.10.0 + */ +data class FeatureWithCreator( + val description: String, + val extractor: (T) -> R, + val assertionCreator: Expect.() -> Unit +) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt new file mode 100644 index 000000000..4b8097530 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt @@ -0,0 +1,22 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.feature + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.creating.MetaFeatureOption +import ch.tutteli.atrium.domain.creating.MetaFeature + +/** + * Parameter object which combines a lambda with a [MetaFeatureOption] receiver (called [provider]) + * and an [assertionCreator]. + * + * Use the function `of({ ... }) { ... }` to create this representation where the first + * argument is a lambda with a [MetaFeatureOption] as receiver which has to create a [MetaFeature] + * where the subject of the assertion is available via implicit parameter `it`. + * Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], + * e.g. `feature of({ f(it::size) }) { o toBe 3 }` + * + * @since 0.10.0 + */ +data class MetaFeatureOptionWithCreator( + val provider: MetaFeatureOption.(T) -> MetaFeature, + val assertionCreator: Expect.() -> Unit +) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt new file mode 100644 index 000000000..efb18670a --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.list + +import ch.tutteli.atrium.creating.Expect + + +/** + * Parameter object which combines an [index] of type [Int] with an [assertionCreator] which defines assertions for + * a resulting feature of type [E]. + * + * Use the function `index(Int) { ... }` to create this representation. + * + * @since 0.10.0 + */ +data class IndexWithCreator(val index: Int, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt deleted file mode 100644 index ffc070a8b..000000000 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/ListGetStep.kt +++ /dev/null @@ -1,40 +0,0 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders - -import ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.impl.ListGetStepImpl -import ch.tutteli.atrium.creating.Expect - -/** - * Represents the extension point for another step after a `get index`-step within a - * sophisticated `get` assertion building process for [List]. - * - * @param E The element type of the [List]. - * @param T A subtype of [List]. - */ -interface ListGetStep> { - /** - * The [Expect] for which this assertion is created - */ - val expect: Expect - - /** - * The given index which will be used to perform the [List.get]. - */ - val index: Int - - /** - * Makes the assertion that the given [index] is within the bounds of [Expect.subject] and that - * the corresponding entry holds all assertions the given [assertionCreator] creates for it. - * - * @return An [Expect] for the current subject of the assertion. - * @throws AssertionError Might throw an [AssertionError] if a created [Expect]s (by calling [assertionCreator]) - * does not hold. - * @throws IllegalArgumentException in case the given [assertionCreator] did not create a single assertion. - */ - infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect - - companion object { - fun > create(expect: Expect, index: Int): ListGetStep = - ListGetStepImpl(expect, index) - } -} - diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt deleted file mode 100644 index a8f7a637d..000000000 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/get/builders/impl/ListGetStepImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.impl - -import ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.ListGetStep -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.builders.ExpectImpl - -internal class ListGetStepImpl>( - override val expect: Expect, - override val index: Int -) : ListGetStep { - - override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect = - ExpectImpl.list.get(expect, index).addToInitial(assertionCreator) -} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt new file mode 100644 index 000000000..853472d2d --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.map + +import ch.tutteli.atrium.creating.Expect + +/** + * Parameter object which combines an [key] of type [K] with an [assertionCreator] which defines assertions for + * a resulting feature of type [V]. + * + * Use the function `key(...) { ... }` to create this representation where the first parameter corresponds + * to the [key] and the second is the [assertionCreator] + * + * @since 0.10.0 + */ +data class KeyWithCreator(val key: K, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt deleted file mode 100644 index 179fb375b..000000000 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/MapGetOption.kt +++ /dev/null @@ -1,47 +0,0 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders - -import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.impl.MapGetOptionImpl -import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.creating.AssertionPlant -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.creating.SubjectProvider - -/** - * Represents the extension point for another option after a `get key`-step within a - * sophisticated `get` assertion building process for [Map]. - * - * @param K The key type of the [Map]. - * @param V the value type of the [Map]. - * @param T A subtype of [Map]. - */ -interface MapGetOption> { - /** - * The [AssertionPlant] for which this assertion is created - */ - val expect: Expect - - /** - * The given key which will be used to perform the [Map.get]. - */ - val key: K - - /** - * Makes the assertion that the [Assert.subject][SubjectProvider.subject] contains the previously specified [key] and that the - * corresponding value holds all assertions the given [assertionCreator] might create for it. - * - * @return This expect to support a fluent API. - * @throws AssertionError Might throw an [AssertionError] if a created [Assertion]s (by calling [assertionCreator]) - * does not hold. - * @throws IllegalArgumentException in case the given [assertionCreator] did not create a single assertion. - */ - infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect - - companion object { - /** - * Creates a [MapGetOption] based on the given [expect] and [key]. - */ - fun > create(expect: Expect, key: K): MapGetOption = - MapGetOptionImpl(expect, key) - } -} - diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt deleted file mode 100644 index ae34f177f..000000000 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/get/builders/impl/MapGetOptionImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.impl - -import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.MapGetOption -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.builders.ExpectImpl - -internal class MapGetOptionImpl>( - override val expect: Expect, - override val key: K -) : MapGetOption { - - override infix fun assertIt(assertionCreator: Expect.() -> Unit): Expect = - expect.addAssertion(ExpectImpl.map.getExisting(expect, key).collect(assertionCreator)) -} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt index 5c0c7abb3..dfe813e4d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt @@ -1,5 +1,8 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.feature.Feature +import ch.tutteli.atrium.api.infix.en_GB.creating.feature.FeatureWithCreator +import ch.tutteli.atrium.api.infix.en_GB.creating.feature.MetaFeatureOptionWithCreator import ch.tutteli.atrium.assertions.AssertionGroup import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.FeatureExpect @@ -41,8 +44,11 @@ infix fun Expect.feature(f: KFunction1): FeatureExpect = * creates a new [Expect] for it and * returns it so that subsequent calls are based on the feature. * - * Use `of(K..., ...)` to create this representation where the first argument is the extractor in form of a - * [KProperty1] or a `KFunctionX` and potentially the required arguments for a `KFunctionX` where `X` > 1. + * Use `of(K..., ...)` to create a [Feature] where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX` and potentially the required arguments for a `KFunctionX` where `X` > 1. + * + * @param of Use `of(K..., ...)` to create a [Feature] where the first argument is the extractor in form of a + * [KProperty1] or a `KFunctionX` and potentially the required arguments for a `KFunctionX` where `X` > 1. * * @return The newly created [Expect] for the extracted feature. * @@ -57,9 +63,13 @@ infix fun Expect.feature(of: Feature): FeatureExpect = * applies an assertion group based on the given [FeatureWithCreator.assertionCreator] for the feature and * returns the initial [Expect] with the current subject. * - * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a - * [KProperty1] or a `KFunctionX`, the last an `assertionCreator`-lambda and the remaining arguments in-between the - * required arguments in case of a `KFunctionX` where `X` > 1. + * Use `of(K..., ...) { ... }` to create a [FeatureWithCreator] where the first argument is the extractor in + * form of a [KProperty1] or a `KFunctionX`, the last an `assertionCreator`-lambda and the remaining arguments + * in-between the required arguments in case of a `KFunctionX` where `X` > 1. + * + * @param of Use `of(K..., ...) { ... }` to create a [FeatureWithCreator] where the first argument is the extractor in + * form of a [KProperty1] or a `KFunctionX`, the last an `assertionCreator`-lambda and the remaining arguments + * in-between the required arguments in case of a `KFunctionX` where `X` > 1. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. @@ -138,43 +148,6 @@ infix fun Expect.feature(of: MetaFeatureOptionWithCreator): Expe fun MetaFeatureOption.f(description: String, provider: R): MetaFeature = MetaFeature(description, provider) -/** - * Parameter object which contains a [description] of a feature along with an [extractor] - * which actually extracts the feature out of a subject of an assertion. - * - * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a - * [KProperty1] or a `KFunctionX` and the remaining arguments are the required arguments in case of a `KFunctionX` - * where `X` > 1. - * - * @property description The description of the feature. - * @property extractor The extractor which extracts the feature out of the subject of the assertion. - - * @since 0.10.0 - */ -data class Feature(val description: String, val extractor: (T) -> R) - -/** - * Parameter object which contains a [description] of a feature along with an [extractor] - * which actually extracts the feature out of a subject of an assertion + an [assertionCreator] - * which defines assertions for the feature. - * - * Use `of(K..., ...) { ... }` to create this representation where the first argument is the extractor in form of a - * [KProperty1] or a `KFunctionX`, the last an [assertionCreator]-lambda and the remaining arguments in-between the - * required arguments in case of a `KFunctionX` where `X` > 1. - * - * @property description The description of the feature. - * @property extractor The extractor which extracts the feature out of the subject of the assertion. - * @property assertionCreator The `assertionCreator`-lambda which defines assertions for the feature. - * - * @since 0.10.0 - */ -data class FeatureWithCreator( - val description: String, - val extractor: (T) -> R, - val assertionCreator: Expect.() -> Unit -) - - //@formatter:off /** * Helper function to create a [Feature] based on a [KFunction2] + arguments. @@ -244,23 +217,6 @@ fun of(f: KFunction5, a1: A1, a2: A //@formatter:on -/** - * Parameter object which combines a lambda with a [MetaFeatureOption] receiver (called [provider]) - * and an [assertionCreator]. - * - * Use the function `of({ ... }) { ... }` to create this representation where the first - * argument is a lambda with a [MetaFeatureOption] as receiver which has to create a [MetaFeature] - * where the subject of the assertion is available via implicit parameter `it`. - * Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], - * e.g. `feature of({ f(it::size) }) { o toBe 3 }` - * - * @since 0.10.0 - */ -data class MetaFeatureOptionWithCreator( - val provider: MetaFeatureOption.(T) -> MetaFeature, - val assertionCreator: Expect.() -> Unit -) - /** * Helper function to create a [MetaFeatureOptionWithCreator] based on a lambda with * [MetaFeatureOption] receiver (has to return a [MetaFeature]) and an [assertionCreator]. @@ -268,4 +224,8 @@ data class MetaFeatureOptionWithCreator( fun of( provider: MetaFeatureOption.(T) -> MetaFeature, assertionCreator: Expect.() -> Unit -): MetaFeatureOptionWithCreator = MetaFeatureOptionWithCreator(provider, assertionCreator) +): MetaFeatureOptionWithCreator = + MetaFeatureOptionWithCreator( + provider, + assertionCreator + ) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt index 01344b2d9..946d6e502 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt @@ -1,6 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.ListGetStep +import ch.tutteli.atrium.api.infix.en_GB.creating.list.IndexWithCreator import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -9,15 +9,26 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * returns an [Expect] for the element at that position. * * @return The newly created [Expect] for the element at position [index]. - * @throws AssertionError if the given [index] is out of bound. + * @throws AssertionError Might throw an [AssertionError] if the given [index] is out of bound. */ infix fun > Expect.get(index: Int): Expect = ExpectImpl.list.get(this, index).getExpectOfFeature() /** - * Prepares the assertion about the return value of calling [get][List.get] with the given [index]. + * Expects that the given [index][IndexWithCreator.index] is within the bounds of the subject of the assertion + * (a [List]) and that the element at that position holds all assertions the given + * [IndexWithCreator.assertionCreator] creates for it. * - * @return A fluent builder to finish the assertion. + * Use the function `index(Int) { ... }` to create an [IndexWithCreator]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the given [index] is out of bound or + * if the assertion made is not correct. */ -infix fun > Expect.get(index: Index): ListGetStep = - ListGetStep.create(this, index.index) +infix fun > Expect.get(index: IndexWithCreator): Expect = + ExpectImpl.list.get(this, index.index).addToInitial(index.assertionCreator) + +/** + * Helper function to create an [IndexWithCreator] based on the given [index] and [assertionCreator]. + */ +fun index(index: Int, assertionCreator: Expect.() -> Unit) = IndexWithCreator(index, assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index 48f30c173..072a7c081 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.map.get.builders.MapGetOption +import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyWithCreator +import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -87,12 +88,23 @@ infix fun > Expect.getExisting(key: K): Expect = ExpectImpl.map.getExisting(this, key).getExpectOfFeature() /** - * Prepares the assertion about the return value of calling [get][Map.get] with the given [key]. + * Expects that the subject of the assertion (a [Map]) contains the given [key] and that + * the corresponding value holds all assertions the given [KeyWithCreator.assertionCreator] creates for it. * - * @return A fluent builder to finish the assertion. - * */ -infix fun > Expect.getExisting(key: Key): MapGetOption = - MapGetOption.create(this, key.key) + * @param key Use the function `key(...) { ... }` to create a [KeyWithCreator] where the first parameter corresponds + * to the key and the second is the `assertionCreator`-lambda + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] the given [key] does not exist or + * if the assertion made is not correct. + */ +infix fun > Expect.getExisting(key: KeyWithCreator): Expect = + ExpectImpl.map.getExisting(this, key.key).addToInitial(key.assertionCreator) + +/** + * Helper function to create an [KeyWithCreator] based on the given [key] and [assertionCreator]. + */ +fun key(key: K, assertionCreator: Expect.() -> Unit) = KeyWithCreator(key, assertionCreator) /** @@ -178,3 +190,4 @@ fun > Expect.asEntries(): Expect> infix fun > Expect.asEntries( assertionCreator: Expect>>.() -> Unit ): Expect = apply { asEntries().addAssertionsCreatedBy(assertionCreator) } + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt index bcd7cef2b..aeb3f4cde 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt @@ -9,14 +9,7 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper class All(override val expected: T, override vararg val otherExpected: T) : VarArgHelper /** - * Wrapper for a single index -- can be used as distinguishable type for an overload where Int is already in use. - */ -data class Index(val index: Int) - -data class Key(val key: K) - -/** - * Parameter object to express a key/value [Pair] whose value type is a lambda with an + * Parameter object to express a key/value [Pair] whose value type is a nullable lambda with an * [Expect] receiver, which means one can either pass a lambda or `null`. */ data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { @@ -25,8 +18,6 @@ data class KeyValue(val key: K, val valueAssertionCreatorOrNull: "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" } - - /** * Parameter object to express `Pair, vararg Pair`. */ diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt index b96d9c2d6..54338cc49 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt @@ -81,7 +81,7 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( //regression for #298, should compile without the need for E : Any or List @Suppress("unused") - fun Expect>.firstIs(value: E) = o get Index(0) assertIt { o toBe value } + fun Expect>.firstIs(value: E) = o get index(0) { o toBe value } } private fun toBeNull(expect: Expect) = expect toBe null diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt index a630924a9..ea4802747 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt @@ -6,7 +6,7 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionAssertionsSpec( "toBe ${Empty::class.simpleName}" to ::isEmpty, - "toBe ${Empty::class.simpleName}" to ::isNotEmpty + "notToBe ${Empty::class.simpleName}" to ::isNotEmpty ) { companion object : WithAsciiReporter() @@ -28,5 +28,5 @@ class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionA } } -fun isEmpty(expect: Expect>) = expect toBe Empty -fun isNotEmpty(expect: Expect>) = expect notToBe Empty +private fun isEmpty(expect: Expect>) = expect toBe Empty +private fun isNotEmpty(expect: Expect>) = expect notToBe Empty diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt index 606753783..4fcbc4b91 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt @@ -1,15 +1,14 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.specs.withNullableSuffix class IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAllAssertionsSpec( - fun1(Expect>::all).name to ::all, - fun1(Expect>::all).withNullableSuffix().name to ::allNullable, + fun1(Expect>::all), + fun1(Expect>::all).withNullableSuffix(), "* ", "(!) ", "- ", "» ", ">> ", "=> " ) { companion object : WithAsciiReporter() @@ -21,17 +20,11 @@ class IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAl var star: Expect> = notImplemented() - a1 = a1.all {} + a1 = a1 all {} - a1b = a1b.all {} - a1b = a1b.all(null) + a1b = a1b all {} + a1b = a1b all null - star = star.all {} + star = star all {} } } - -private fun all(expect: Expect>, assertionCreator: Expect.() -> Unit) = - expect all assertionCreator - -private fun allNullable(expect: Expect>, assertionCreator: (Expect.() -> Unit)?) = - expect all assertionCreator diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt index f4fd936c2..4441ce7bc 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt @@ -1,18 +1,18 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.list.get.builders.ListGetStep -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.feature1 +import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.specs.withNullableSuffix -import kotlin.reflect.KFunction2 +import kotlin.jvm.JvmName class ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatureAssertionsSpec( feature1, Int, Int>(Expect>::get), - getIndexPair(), + fun2, Int, Expect.() -> Unit>(::get), feature1, Int, Int?>(Expect>::get).withNullableSuffix(), - getIndexNullablePair() + fun2, Int, Expect.() -> Unit>(::get).withNullableSuffix() ) { companion object : WithAsciiReporter() @@ -24,29 +24,22 @@ class ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatur var star: Expect> = notImplemented() a1 get 1 - a1 = a1 get Index(1) assertIt { } + a1 = a1 get index(1) { } a1b get 1 - a1b = a1b get Index(1) assertIt { } + a1b = a1b get index(1) { } star get 1 - star = star get Index(1) assertIt { } + star = star get index(1) { } } } -private val getIndexFun: KFunction2>, Index, ListGetStep>> = Expect>::get -private fun getIndexPair() = getIndexFun.name to ::getIndex +private fun get(expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit) = + expect get index(index) { assertionCreator() } -private fun getIndex(expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit) = - expect get Index(index) assertIt { assertionCreator() } - -private val getIndexNullableFun: KFunction2>, Index, ListGetStep>> = - Expect>::get - -private fun getIndexNullablePair() = getIndexNullableFun.name to ::getIndexNullable - -private fun getIndexNullable( +@JvmName("getNullable") +private fun get( expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit -) = expect get Index(index) assertIt { assertionCreator() } +) = expect get index(index) { assertionCreator() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index 14ec68fc6..ff1091d90 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -3,86 +3,27 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import kotlin.jvm.JvmName +import kotlin.reflect.KFunction3 + +private fun mfun2( + f: KFunction3>, Pair, Array>, Expect>> +) = fun2(f) class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( - fun2(Companion::contains), - fun2(Companion::contains).name to Companion::containsNullable, - "${fun2(Companion::contains).name} ${KeyValue::class.simpleName}" to Companion::containsKeyWithValueAssertions, - "${fun2(Companion::contains).name} ${KeyValue::class.simpleName}" to Companion::containsKeyWithNullableValueAssertions, - fun1(Companion::containsKey), - fun1(Companion::containsNullableKey), - fun1(Companion::containsNotKey), - fun1(Companion::containsNotNullableKey), - /* string toBe, notToBe to avoid ambiguity error */ - "toBe ${Empty::class.simpleName}" to Companion::isEmpty, - "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty + mfun2(::contains), + mfun2(::contains).withNullableSuffix(), + mfun2.() -> Unit>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, + mfun2.() -> Unit)?>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }.withNullableSuffix(), + fun1, String>(::containsKey), + fun1, String?>(::containsKey).withNullableSuffix(), + fun1, String>(::containsNotKey), + fun1, String?>(::containsNotKey).withNullableSuffix(), + "toBe ${Empty::class.simpleName}" to ::isEmpty, + "notToBe ${Empty::class.simpleName}" to ::isNotEmpty ) { - companion object { - private fun contains( - expect: Expect>, - pair: Pair, - otherPairs: Array> - ): Expect> { - return if (otherPairs.isEmpty()) { - expect contains (pair.first to pair.second) - } else { - expect contains Pairs(pair, *otherPairs) - } - } - - private fun containsNullable( - expect: Expect>, - pair: Pair, - otherPairs: Array> - ): Expect> { - return if (otherPairs.isEmpty()) { - expect contains (pair.first to pair.second) - } else { - expect contains Pairs(pair, *otherPairs) - } - } - - private fun containsKeyWithValueAssertions( - expect: Expect>, - keyValue: Pair.() -> Unit>, - otherKeyValues: Array.() -> Unit>> - ): Expect> { - return if (otherKeyValues.isEmpty()) { - expect contains KeyValue(keyValue.first, keyValue.second) - } else { - mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect contains All(first, *others) - } - } - } - - private fun containsKeyWithNullableValueAssertions( - expect: Expect>, - keyValue: Pair.() -> Unit)?>, - otherKeyValues: Array.() -> Unit)?>> - ): Expect> { - return if (otherKeyValues.isEmpty()) { - expect contains KeyValue(keyValue.first, keyValue.second) - } else { - mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect contains All(first, *others) - } - } - } - - private fun containsKey(expect: Expect>, key: String) = expect containsKey key - - private fun containsNullableKey(expect: Expect>, key: String?) = expect containsKey key - - private fun containsNotKey(expect: Expect>, key: String) = expect containsNotKey key - - private fun containsNotNullableKey(expect: Expect>, key: String?) = - expect containsNotKey key - - private fun isEmpty(expect: Expect>) = expect toBe Empty - - private fun isNotEmpty(expect: Expect>) = expect notToBe Empty - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -249,3 +190,76 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( } } + +private fun contains( + expect: Expect>, + pair: Pair, + otherPairs: Array> +): Expect> { + return if (otherPairs.isEmpty()) { + expect contains (pair.first to pair.second) + } else { + expect contains Pairs(pair, *otherPairs) + } +} + +@JvmName("containsNullable") +private fun contains( + expect: Expect>, + pair: Pair, + otherPairs: Array> +): Expect> { + return if (otherPairs.isEmpty()) { + expect contains (pair.first to pair.second) + } else { + expect contains Pairs(pair, *otherPairs) + } +} + +@JvmName("containsKeyWithValueAssertions") +private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit>, + otherKeyValues: Array.() -> Unit>> +): Expect> { + return if (otherKeyValues.isEmpty()) { + expect contains KeyValue(keyValue.first, keyValue.second) + } else { + mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect contains All(first, *others) + } + } +} + +@JvmName("containsKeyWithNullableValueAssertions") +private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit)?>, + otherKeyValues: Array.() -> Unit)?>> +): Expect> { + return if (otherKeyValues.isEmpty()) { + expect contains KeyValue(keyValue.first, keyValue.second) + } else { + mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect contains All(first, *others) + } + } +} + +private fun containsKey(expect: Expect>, key: String) = + expect containsKey key + +@JvmName("containsKeyNullable") +private fun containsKey(expect: Expect>, key: String?) = + expect containsKey key + +private fun containsNotKey(expect: Expect>, key: String) = + expect containsNotKey key + +@JvmName("containsNotKeyNullable") +private fun containsNotKey(expect: Expect>, key: String?) = + expect containsNotKey key + +private fun isEmpty(expect: Expect>) = expect toBe Empty + +private fun isNotEmpty(expect: Expect>) = expect notToBe Empty diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt index 20ef9dbf2..4e3532f5b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt @@ -2,6 +2,8 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import kotlin.jvm.JvmName class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureAssertionsSpec( property, Set>(Expect>::keys), @@ -9,23 +11,11 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA property, Collection>(Expect>::values), fun1, Expect>.() -> Unit>(Expect>::values), feature1, String, Int>(Expect>::getExisting), - fun2, String, Expect.() -> Unit>(Companion::getExisting), + fun2, String, Expect.() -> Unit>(::getExisting), feature1, String?, Int?>(Expect>::getExisting).withNullableSuffix(), - fun2(Companion::getExisting).name to Companion::getExistingNullable + fun2, String?, Expect.() -> Unit>(::getExisting).withNullableSuffix() ) { - companion object { - private fun getExisting( - expect: Expect>, - key: String, - assertionCreator: Expect.() -> Unit - ): Expect> = expect getExisting Key(key) assertIt { assertionCreator() } - - private fun getExistingNullable( - expect: Expect>, - key: String?, - assertionCreator: Expect.() -> Unit - ): Expect> = expect getExisting Key(key) assertIt { assertionCreator() } - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -40,9 +30,22 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA a3 getExisting null as String? star getExisting "a" - a1 = a1 getExisting Key("a") assertIt { } - a2 = a2 getExisting Key(1) assertIt { } - a3 = a3 getExisting Key(null) assertIt { } - star = star getExisting Key("a") assertIt { } + a1 = a1 getExisting key("a") { } + a2 = a2 getExisting key(1) { } + a3 = a3 getExisting key(null) { } + star = star getExisting key("a") { } } } + +private fun getExisting( + expect: Expect>, + key: String, + assertionCreator: Expect.() -> Unit +): Expect> = expect getExisting key(key) { assertionCreator() } + +@JvmName("getExistingNullable") +private fun getExisting( + expect: Expect>, + key: String?, + assertionCreator: Expect.() -> Unit +): Expect> = expect getExisting key(key) { assertionCreator() } diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt index a73e9c06c..34f69587c 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt @@ -19,7 +19,7 @@ interface VarArgHelper { /** * Creates an [ArgumentMapperBuilder] which allows to map [expected] and [otherExpected]. */ - val mapArguments get() = ArgumentMapperBuilder(expected, otherExpected) + val mapArguments: ArgumentMapperBuilder get() = ArgumentMapperBuilder(expected, otherExpected) /** * Returns the arguments as [List]. From f3fee7cb4cc829798778c1f75cf4fbc4fa5985c5 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 1 Mar 2020 21:27:02 +0100 Subject: [PATCH 059/142] cleanup, remove `returns this`, order fun In detail: - follow up to a352716d, we still use `returns this` in the description change to `an [Expect] for the current subject of the assertion` - fix KDoc of min and max, they are not properties but method calls - get rid of private funs `values` and `keys` -> not worth the code duplication reduction --- .../api/fluent/en_GB/collectionAssertions.kt | 3 +- .../api/fluent/en_GB/iterableAssertions.kt | 39 ++++++++++++------- .../atrium/api/fluent/en_GB/listAssertions.kt | 3 +- .../atrium/api/fluent/en_GB/mapAssertions.kt | 22 +++++------ .../api/fluent/en_GB/mapEntryAssertions.kt | 6 ++- .../atrium/api/fluent/en_GB/pairAssertions.kt | 14 ++++--- .../api/fluent/en_GB/throwableAssertions.kt | 3 +- .../fluent/en_GB/jdk8/localDateAssertions.kt | 12 ++++-- .../en_GB/jdk8/localDateTimeAssertions.kt | 12 ++++-- .../api/fluent/en_GB/jdk8/pathAssertions.kt | 12 +++--- .../en_GB/jdk8/zonedDateTimeAssertions.kt | 12 ++++-- .../api/infix/en_GB/collectionAssertions.kt | 3 +- .../atrium/api/infix/en_GB/mapAssertions.kt | 23 +++++------ .../api/infix/en_GB/mapEntryAssertions.kt | 6 ++- .../atrium/api/infix/en_GB/pairAssertions.kt | 12 ++++-- .../api/infix/en_GB/MapAssertionsSpec.kt | 18 ++++----- .../infix/en_GB/jdk8/localDateAssertions.kt | 12 ++++-- .../en_GB/jdk8/localDateTimeAssertions.kt | 12 ++++-- .../api/infix/en_GB/jdk8/pathAssertions.kt | 10 +++-- .../en_GB/jdk8/zonedDateTimeAssertions.kt | 12 ++++-- .../domain/creating/ComparableAssertions.kt | 4 +- 21 files changed, 148 insertions(+), 102 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt index 46913253a..77bb3107c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/collectionAssertions.kt @@ -40,7 +40,8 @@ val > Expect.size: Expect /** * Expects that the property [Collection.size] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt index a28eb79df..e1b8a46f6 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableAssertions.kt @@ -27,45 +27,54 @@ val > Expect.containsNot: NotCheckerOption, T : Iterable> Expect.min(): Expect = + ExpectImpl.iterable.min(this).getExpectOfFeature() + +/** + * Expects that the result of calling `min()` on the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * * @since 0.9.0 */ fun , T : Iterable> Expect.min(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.iterable.min(this).addToInitial(assertionCreator) + /** - * Creates an [Expect] for the property min of the subject of the assertion, + * Creates an [Expect] for the result of calling `max()` on the subject of the assertion, * so that further fluent calls are assertions about it. * * @return The newly created [Expect] for the extracted feature. + * * @since 0.9.0 */ -fun , T : Iterable> Expect.min(): Expect = ExpectImpl.iterable.min(this).getExpectOfFeature() +fun , T : Iterable> Expect.max(): Expect = + ExpectImpl.iterable.max(this).getExpectOfFeature() /** - * Expects that the property max of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * Expects that the result of calling `max()` on the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * * @since 0.9.0 */ fun , T : Iterable> Expect.max(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.iterable.max(this).addToInitial(assertionCreator) -/** - * Creates an [Expect] for the property max of the subject of the assertion, - * so that further fluent calls are assertions about it. - * - * @return The newly created [Expect] for the extracted feature. - * @since 0.9.0 - */ -fun , T : Iterable> Expect.max(): Expect = ExpectImpl.iterable.max(this).getExpectOfFeature() - /** * Expects that the subject of the assertion (an [Iterable]) contains the * [expected] value and the [otherExpected] values (if given). diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt index 9b8d8a1ab..edfc888a1 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/listAssertions.kt @@ -10,7 +10,8 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * @return The newly created [Expect] for the element at position [index]. * @throws AssertionError Might throw an [AssertionError] if the given [index] is out of bound. */ -fun > Expect.get(index: Int): Expect = ExpectImpl.list.get(this, index).getExpectOfFeature() +fun > Expect.get(index: Int): Expect = + ExpectImpl.list.get(this, index).getExpectOfFeature() /** * Expects that the given [index] is within the bounds of the subject of the assertion (a [List]) and that diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt index ca97d4319..236c44237 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapAssertions.kt @@ -106,19 +106,18 @@ fun > Expect.getExisting(key: K, assertionCreator: Ex * @return The newly created [Expect] for the extracted feature. */ val > Expect.keys: Expect> - get() = keys(this).getExpectOfFeature() + get() = ExpectImpl.feature.property(this, Map::keys).getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.keys(assertionCreator: Expect>.() -> Unit): Expect = - keys(this).addToInitial(assertionCreator) - -private fun > keys(e: Expect) = ExpectImpl.feature.property(e, Map::keys) + ExpectImpl.feature.property(this, Map::keys).addToInitial(assertionCreator) /** * Creates an [Expect] for the property [Map.values] of the subject of the assertion, @@ -127,19 +126,18 @@ private fun > keys(e: Expect) = ExpectImpl.feature.prope * @return The newly created [Expect] for the extracted feature. */ val > Expect.values: Expect> - get() = values().getExpectOfFeature() + get() = ExpectImpl.feature.property(this, Map::values).getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Expect.values(assertionCreator: Expect>.() -> Unit): Expect = - values().addToInitial(assertionCreator) - -private fun > Expect.values() = ExpectImpl.feature.property(this, Map::values) + ExpectImpl.feature.property(this, Map::values).addToInitial(assertionCreator) /** * Turns `Expect>` into `Expect>>`. @@ -154,12 +152,12 @@ fun > Expect.asEntries(): Expect> /** * Turns `Expect>` into `Expect>>` and expects that it holds all assertions the given - * [assertionCreator] creates. + * [assertionCreator] creates for it. * * The transformation as such is not reflected in reporting. * Use `feature { f(it::entries) }` if you want to show the transformation in reporting. * - * @return The newly created [Expect] for the transformed subject. + * @return An [Expect] for the current subject of the assertion. */ fun > Expect.asEntries( assertionCreator: Expect>>.() -> Unit diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt index e00f14bdb..3a344eb6a 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapEntryAssertions.kt @@ -28,7 +28,8 @@ val > Expect.key: Expect /** * Expects that the property [Map.Entry.key] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val > Expect.value: Expect /** * Expects that the property [Map.Entry.value] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt index 1b2fa6bee..e584f7ffa 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/pairAssertions.kt @@ -9,12 +9,13 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * * @return The newly created [Expect] for the extracted feature. */ -val > Expect.first: Expect - get() = ExpectImpl.pair.first(this).getExpectOfFeature() +val > Expect.first + get() : Expect = ExpectImpl.pair.first(this).getExpectOfFeature() /** * Expects that the property [Pair.first] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -28,12 +29,13 @@ fun > Expect.first(assertionCreator: Expect.() -> Uni * * @return The newly created [Expect] for the extracted feature. */ -val > Expect.second: Expect - get() = ExpectImpl.pair.second(this).getExpectOfFeature() +val > Expect.second + get() : Expect = ExpectImpl.pair.second(this).getExpectOfFeature() /** * Expects that the property [Pair.second] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt index 98d3fe72b..250d81860 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt @@ -14,7 +14,8 @@ val Expect.message: Expect /** * Expects that the property [Throwable.message] of the subject of the assertion is not null and - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt index adc5e74c8..50286d416 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateAssertions.kt @@ -24,7 +24,8 @@ val Expect.year: Expect /** * Expects that the property [LocalDate.year][LocalDate.getYear]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val Expect.month: Expect /** * Expects that the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -70,7 +72,8 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDate.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -94,7 +97,8 @@ val Expect.day: Expect /** * Expects that the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt index 7704555ec..aa3bc0d3e 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/localDateTimeAssertions.kt @@ -24,7 +24,8 @@ val Expect.year: Expect /** * Expects that the property [LocalDateTime.year][LocalDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val Expect.month: Expect /** * Expects that the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -70,7 +72,8 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -93,7 +96,8 @@ val Expect.day: Expect /** * Expects that the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt index 73fc6c2f9..445fe5071 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt @@ -95,7 +95,8 @@ val Expect.fileName: Expect /** * Expects that the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -122,7 +123,7 @@ val Expect.fileNameWithoutExtension: Expect * Expects that the property [Path.fileNameWithoutExtension][ch.tutteli.niok.fileNameWithoutExtension] * (provided via [niok](https://github.com/robstoll/niok)) * of the subject of the assertion holds all assertions the given [assertionCreator] creates for it - * and returns this [Expect]. + * and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -146,7 +147,7 @@ val Expect.parent: Expect /** * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the - * given [assertionCreator] creates for it and returns this [Expect]. + * given [assertionCreator] creates for it and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -170,7 +171,7 @@ fun Expect.resolve(other: String): Expect = /** * Expects that [other] resolves against this [Path] and that the resolved [Path] holds all assertions the - * given [assertionCreator] creates for it and returns this [Expect]. + * given [assertionCreator] creates for it and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -269,7 +270,8 @@ val Expect.extension: Expect /** * Expects that the property [Path.extension][ch.tutteli.niok.extension] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt index 88dab2dbd..20740d426 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/zonedDateTimeAssertions.kt @@ -24,7 +24,8 @@ val Expect.year: Expect /** * Expects that the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val Expect.month: Expect /** * Expects that the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -70,7 +72,8 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -93,7 +96,8 @@ val Expect.day: Expect /** * Expects that the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt index d200e747c..eeb129f49 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt @@ -31,7 +31,8 @@ val > Expect.size get(): Expect = ExpectImpl.collectio /** * Expects that the property [Collection.size] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index 072a7c081..0ca4cb5f0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -1,7 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyWithCreator -import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -114,19 +113,18 @@ fun key(key: K, assertionCreator: Expect.() -> Unit) = KeyWithCreator( * @return The newly created [Expect] for the extracted feature. */ val > Expect.keys: Expect> - get() = keys(this).getExpectOfFeature() + get() = ExpectImpl.feature.property(this, Map::keys).getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.keys(assertionCreator: Expect>.() -> Unit): Expect = - keys(this).addToInitial(assertionCreator) - -private fun > keys(e: Expect) = ExpectImpl.feature.property(e, Map::keys) + ExpectImpl.feature.property(this, Map::keys).addToInitial(assertionCreator) /** * Expects that the subject of the assertion (a [Map]) is an empty [Map]. @@ -153,19 +151,18 @@ infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: * @return The newly created [Expect] for the extracted feature. */ val > Expect.values: Expect> - get() = values().getExpectOfFeature() + get() = ExpectImpl.feature.property(this, Map::values).getExpectOfFeature() /** * Expects that the property [Map.keys] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Expect.values(assertionCreator: Expect>.() -> Unit): Expect = - values().addToInitial(assertionCreator) - -private fun > Expect.values() = ExpectImpl.feature.property(this, Map::values) + ExpectImpl.feature.property(this, Map::values).addToInitial(assertionCreator) /** * Turns `Expect>` into `Expect>>`. @@ -180,12 +177,12 @@ fun > Expect.asEntries(): Expect> /** * Turns `Expect>` into `Expect>>` and expects that it holds all assertions the given - * [assertionCreator] creates. + * [assertionCreator] creates for it. * * The transformation as such is not reflected in reporting. * Use `feature { f(it::entries) }` if you want to show the transformation in reporting. * - * @return The newly created [Expect] for the transformed subject. + * @return An [Expect] for the current subject of the assertion. */ infix fun > Expect.asEntries( assertionCreator: Expect>>.() -> Unit diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt index 499d296b8..b4fc7adce 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt @@ -28,7 +28,8 @@ val > Expect.key: Expect /** * Expects that the property [Map.Entry.key] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val > Expect.value: Expect /** * Expects that the property [Map.Entry.value] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt index e19b5cef8..825476346 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/pairAssertions.kt @@ -9,11 +9,13 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * * @return The newly created [Expect] for the extracted feature. */ -val > Expect.first get() : Expect = ExpectImpl.pair.first(this).getExpectOfFeature() +val > Expect.first: Expect + get() = ExpectImpl.pair.first(this).getExpectOfFeature() /** * Expects that the property [Pair.first] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -27,11 +29,13 @@ infix fun > Expect.first(assertionCreator: Expect.() * * @return The newly created [Expect] for the extracted feature. */ -val > Expect.second get() : Expect = ExpectImpl.pair.second(this).getExpectOfFeature() +val > Expect.second: Expect + get() = ExpectImpl.pair.second(this).getExpectOfFeature() /** * Expects that the property [Pair.second] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index ff1091d90..b048a2057 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -37,25 +37,25 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( map contains (1 to "a") map contains Pairs(1 to "a", 2 to "b") - map contains (KeyValue(1) {}) + map contains KeyValue(1) {} map contains All(KeyValue(1) {}, KeyValue(2) {}) map contains Pairs(1.0 to StringBuilder("a")) map contains Pairs(12f to "a", 2L to StringBuilder("b")) - map contains (KeyValue(1) {}) + map contains KeyValue(1) {} map contains All(KeyValue(1) {}, KeyValue(2) {}) subMap contains (1 to "a") subMap contains Pairs(1 to "a", 2 to "b") - subMap contains (KeyValue(1) {}) + subMap contains KeyValue(1) {} subMap contains All(KeyValue(1) {}, KeyValue(2) {}) subMap contains (1.0 to StringBuilder("a")) subMap contains Pairs(12f to "a", 2L to StringBuilder("b")) - subMap contains (KeyValue(1) {}) + subMap contains KeyValue(1) {} subMap contains All(KeyValue(1) {}, KeyValue(2) {}) nullableKeyMap contains (1 to "a") nullableKeyMap contains Pairs(1 to "a", 2 to "b") - nullableKeyMap contains (KeyValue(1) {}) + nullableKeyMap contains KeyValue(1) {} nullableKeyMap contains All(KeyValue(1) {}, KeyValue(2) {}) nullableKeyMap contains (null to "a") nullableKeyMap contains Pairs(null to "a", null to "b") @@ -66,7 +66,7 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( nullableValueMap contains (1 to "a") nullableValueMap contains Pairs(1 to "a", 2 to "b") - nullableValueMap contains (KeyValue(1) {}) + nullableValueMap contains KeyValue(1) {} nullableValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) nullableValueMap contains (1 to null) nullableValueMap contains Pairs(1 to null, 2 to null) @@ -77,7 +77,7 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( nullableKeyValueMap contains (1 to "a") nullableKeyValueMap contains Pairs(1 to "a", 2 to "b") - nullableKeyValueMap contains (KeyValue(1) {}) + nullableKeyValueMap contains KeyValue(1) {} nullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) nullableKeyValueMap contains (null to "a") @@ -103,7 +103,7 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( readOnlyNullableKeyValueMap contains (1 to "a") readOnlyNullableKeyValueMap contains Pairs(1 to "a", 2 to "b") - readOnlyNullableKeyValueMap contains (KeyValue(1) {}) + readOnlyNullableKeyValueMap contains KeyValue(1) {} readOnlyNullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) readOnlyNullableKeyValueMap contains (null to "a") @@ -129,7 +129,7 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( readOnlyNullableKeyValueMap contains (1 to "a") readOnlyNullableKeyValueMap contains Pairs(1 to "a", 2 to "b") - readOnlyNullableKeyValueMap contains (KeyValue(1) {}) + readOnlyNullableKeyValueMap contains KeyValue(1) {} readOnlyNullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) starMap contains (null to "a") diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt index d43f73233..c343bfa2f 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt @@ -24,7 +24,8 @@ val Expect.year: Expect /** * Expects that the property [LocalDate.year][LocalDate.getYear]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val Expect.month: Expect /** * Expects that the property [LocalDate.monthValue][LocalDate.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -70,7 +72,8 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDate.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -94,7 +97,8 @@ val Expect.day: Expect /** * Expects that the property [LocalDate.dayOfMonth][LocalDate.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt index 02149102e..4cf14c207 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt @@ -24,7 +24,8 @@ val Expect.year: Expect /** * Expects that the property [LocalDateTime.year][LocalDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val Expect.month: Expect /** * Expects that the property [LocalDateTime.monthValue][LocalDateTime.getMonthValue]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -70,7 +72,8 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [LocalDateTime.dayOfWeek][LocalDateTime.getDayOfWeek]of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -93,7 +96,8 @@ val Expect.day: Expect /** * Expects that the property [LocalDateTime.dayOfMonth][LocalDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index bddfed398..7dbb7645f 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -97,7 +97,8 @@ val Expect.fileName: Expect /** * Expects that the property [Path.fileNameAsString][ch.tutteli.niok.fileNameAsString] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -124,7 +125,7 @@ val Expect.fileNameWithoutExtension: Expect * Expects that the property [Path.fileNameWithoutExtension][ch.tutteli.niok.fileNameWithoutExtension] * (provided via [niok](https://github.com/robstoll/niok)) * of the subject of the assertion holds all assertions the given [assertionCreator] creates for it - * and returns this [Expect]. + * and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -148,7 +149,7 @@ val Expect.parent: Expect /** * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the - * given [assertionCreator] creates for it and returns this [Expect]. + * given [assertionCreator] creates for it and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -263,7 +264,8 @@ val Expect.extension: Expect /** * Expects that the property [Path.extension][ch.tutteli.niok.extension] * (provided via [niok](https://github.com/robstoll/niok)) of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt index 4714c3c69..c89144591 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt @@ -24,7 +24,8 @@ val Expect.year: Expect /** * Expects that the property [ZonedDateTime.year][ZonedDateTime.getYear] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -47,7 +48,8 @@ val Expect.month: Expect /** * Expects that the property [ZonedDateTime.monthValue][ZonedDateTime.getMonthValue] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -70,7 +72,8 @@ val Expect.dayOfWeek: Expect /** * Expects that the property [ZonedDatetime.dayOfWeek][ZonedDateTime.getDayOfWeek] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -93,7 +96,8 @@ val Expect.day: Expect /** * Expects that the property [ZonedDateTime.dayOfMonth][ZonedDateTime.getDayOfMonth] of the subject of the assertion - * holds all assertions the given [assertionCreator] creates for it and returns this [Expect]. + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ComparableAssertions.kt b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ComparableAssertions.kt index 3f0774a93..a667941bd 100644 --- a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ComparableAssertions.kt +++ b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ComparableAssertions.kt @@ -19,12 +19,12 @@ val comparableAssertions by lazy { loadSingleService(ComparableAssertions::class interface ComparableAssertions { fun , T2 : Any?> isLessThan(subjectProvider: SubjectProvider, expected: T2): Assertion - //TODO rename to isLessThanOrEqual with 0.1.0 + //TODO rename to isLessThanOrEqual with 1.0.0 fun , T2 : Any?> isLessOrEquals(subjectProvider: SubjectProvider, expected: T2): Assertion fun , T2 : Any?> isGreaterThan(subjectProvider: SubjectProvider, expected: T2): Assertion - //TODO rename to isGreaterThanOrEqual with 0.1.0 + //TODO rename to isGreaterThanOrEqual with 1.0.0 fun , T2 : Any?> isGreaterOrEquals( subjectProvider: SubjectProvider, expected: T2 From 46a3b714ef8d9374c7a343fc24210cff515d5e54 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 29 Feb 2020 20:30:56 +0100 Subject: [PATCH 060/142] add withOptions as experimental to new infix API --- .../api/infix/en_GB/expectExtensions.kt | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt new file mode 100644 index 000000000..d2a53ae34 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt @@ -0,0 +1,122 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.core.None +import ch.tutteli.atrium.core.coreFactory +import ch.tutteli.atrium.creating.* +import ch.tutteli.atrium.domain.builders.creating.changers.FeatureExtractorBuilder +import ch.tutteli.atrium.domain.builders.creating.changers.FeatureOptions +import ch.tutteli.atrium.domain.builders.reporting.ExpectBuilder +import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.reporting.reporter + +@Experimental +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.FUNCTION) +annotation class ExperimentalWithOptions + +/** + * Wraps the given [textRepresentation] into a [RawString] and uses it as representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + */ +@ExperimentalWithOptions +infix fun RootExpect.withRepresentation(textRepresentation: String): Expect = + withOptions { withRepresentation(textRepresentation) } + +/** + * Uses the given [representationProvider] to retrieve a representation which can be based on the current + * subject where it is used as new representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * 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. + * If your text does not include the current subject, then we recommend to use the other overload which expects + * a `String` and does the wrapping for you. + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + */ +@ExperimentalWithOptions +infix fun RootExpect.withRepresentation(representationProvider: (T) -> Any): Expect = + withOptions { withRepresentation(representationProvider) } + +/** + * Uses the given [configuration]-lambda to create an [ExpectOptions] which in turn is used + * to override (parts) of the existing configuration. + */ +@ExperimentalWithOptions +infix fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser.() -> Unit): Expect = + withOptions(ExpectBuilder.OptionsChooser.createAndBuild(configuration)) + +//TODO #280 get rid of AssertionChecker, that's one root of a bug (which is more a nice to have but still) roadmap#11 +//in the same go we should get rid of ReportingAssertionContainer.AssertionCheckerDecorator, rename it respectively. +/** + * Uses the given [options] to override (parts) of the existing configuration. + */ +@ExperimentalWithOptions +@UseExperimental(ExperimentalExpectConfig::class) +infix fun RootExpect.withOptions(options: ExpectOptions): Expect = + coreFactory.newReportingAssertionContainer( + ReportingAssertionContainer.AssertionCheckerDecorator.create( + options.assertionVerb ?: this.config.description, + this.maybeSubject, + options.representationInsteadOfSubject?.let { provider -> + this.maybeSubject.fold({ null }) { provider(it) } + } ?: this.config.representation, + //TODO #280 reporter should be configurable as well + coreFactory.newThrowingAssertionChecker(options.reporter ?: reporter) + ) + ) + +/** + * Wraps the given [textRepresentation] into a [RawString] and uses it as representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + */ +@ExperimentalWithOptions +infix fun FeatureExpect.withRepresentation(textRepresentation: String): Expect = + withOptions { withRepresentation(textRepresentation) } + +/** + * Uses the given [representationProvider] to retrieve a representation which can be based on the current + * subject where it is used as new representation of the subject + * instead of the representation that has been defined so far (which defaults to the subject itself). + * + * 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. + * If your text does not include the current subject, then we recommend to use the other overload which expects + * a `String` and does the wrapping for you. + * + * In case [Expect.maybeSubject] is not defined i.e. [None], then the previous representation is used. + */ +@ExperimentalWithOptions +infix fun FeatureExpect.withRepresentation(representationProvider: (R) -> Any): Expect = + withOptions { withRepresentation(representationProvider) } + +/** + * Uses the given [configuration]-lambda to create an [ExpectOptions] which in turn is used + * to override (parts) of the existing configuration. + */ +@ExperimentalWithOptions +infix fun FeatureExpect.withOptions(configuration: FeatureExtractorBuilder.OptionsChooser.() -> Unit): Expect = + withOptions(FeatureExtractorBuilder.OptionsChooser.createAndBuild(configuration)) + +/** + * Uses the given [options] to override (parts) of the existing configuration. + */ +@ExperimentalWithOptions +@UseExperimental(ExperimentalExpectConfig::class) +infix fun FeatureExpect.withOptions(options: FeatureOptions): Expect = + coreFactory.newFeatureExpect( + previousExpect, + maybeSubject, + FeatureExpectConfig.create( + options.description ?: config.description, + options.representationInsteadOfFeature?.let { provider -> + this.maybeSubject.fold({ null }) { provider(it) } + } ?: this.config.representation + ), + getAssertions() + ) From 20a38b5801ba30dac33249d3665c775d782f821d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 3 Mar 2020 21:50:47 +0100 Subject: [PATCH 061/142] add throwable and charSequenceAssertions to the new infix API moreover: - add ambiguityTest to CharSequenceSpecBase - introduce toVarArg which incorporates the hasNext check - make feature KProperty contra-variant -> otherwise something like Throwable::message does not work - unfortunately same for Feature and FeatureWithCreator but due to a Kotlin bug (would not be necessary - also the same for the param object Values (also a Kotlin bug) --- .../fluent/en_GB/charSequenceAssertions.kt | 4 + .../en_GB/charSequenceContainsCreators.kt | 42 +- .../iterableContainsInAnyOrderCreators.kt | 5 +- .../iterableContainsInAnyOrderOnlyCreators.kt | 5 +- .../iterableContainsInOrderOnlyCreators.kt | 5 +- .../en_GB/CharSequenceAssertionsSpec.kt | 27 +- ...arSequenceContainsAtLeastAssertionsSpec.kt | 2 +- ...quenceContainsContainsNotAssertionsSpec.kt | 25 +- .../en_GB/CharSequenceContainsSpecBase.kt | 28 ++ .../api/infix/en_GB/charSequenceAssertions.kt | 324 +++++++++++++++ .../en_GB/charSequenceContainsCheckers.kt | 90 +++++ .../en_GB/charSequenceContainsCreators.kt | 376 ++++++++++++++++++ .../charSequenceContainsSearchBehaviours.kt | 33 ++ .../contains.builders/AtLeastCheckerOption.kt | 14 + .../contains.builders/AtMostCheckerOption.kt | 13 + .../ButAtMostCheckerOption.kt | 13 + .../contains.builders/ExactlyCheckerOption.kt | 13 + .../contains.builders/NotCheckerOption.kt | 13 + .../NotOrAtMostCheckerOption.kt | 13 + .../impl/AtLeastCheckerOptionImpl.kt | 29 ++ .../impl/AtMostCheckerOptionImpl.kt | 33 ++ .../impl/ButAtMostCheckerOptionImpl.kt | 39 ++ .../impl/ExactlyCheckerOptionImpl.kt | 29 ++ .../impl/NotCheckerOptionImpl.kt | 21 + .../impl/NotOrAtMostCheckerOptionImpl.kt | 29 ++ .../impl/nameContainsNotFun.kt | 11 + .../api/infix/en_GB/featureAssertions.kt | 14 +- .../atrium/api/infix/en_GB/keywords.kt | 21 + .../api/infix/en_GB/parameterObjects.kt | 25 ++ .../api/infix/en_GB/throwableAssertions.kt | 50 +++ .../infix/en_GB/CharSequenceAssertionsSpec.kt | 50 +++ ...arSequenceContainsAtLeastAssertionsSpec.kt | 174 ++++++++ ...harSequenceContainsAtMostAssertionsSpec.kt | 42 ++ ...quenceContainsContainsNotAssertionsSpec.kt | 31 ++ ...arSequenceContainsExactlyAssertionsSpec.kt | 40 ++ .../CharSequenceContainsNotAssertionsSpec.kt | 29 ++ ...quenceContainsNotOrAtMostAssertionsSpec.kt | 42 ++ ...CharSequenceContainsRegexAssertionsSpec.kt | 139 +++++++ .../en_GB/CharSequenceContainsSpecBase.kt | 60 +++ .../infix/en_GB/ThrowableAssertionsSpec.kt | 29 ++ .../domain/builders/utils/VarArgHelper.kt | 11 + ...CharSequenceContainsRegexAssertionsSpec.kt | 20 +- 42 files changed, 1955 insertions(+), 58 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCheckers.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsSearchBehaviours.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtLeastCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtMostCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ButAtMostCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ExactlyCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotOrAtMostCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt index 49ca8b16c..ca4754012 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt @@ -229,6 +229,8 @@ fun Expect.isNotBlank() = addAssertion(ExpectImpl.charSequ /** * Expects that the subject of the assertion (a [CharSequence]) matches the given [expected] [Regex]. * + * In contrast to [containsRegex] it does not look for a partial match but for an entire match. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @@ -240,6 +242,8 @@ fun Expect.matches(expected: Regex) = /** * Expects that the subject of the assertion (a [CharSequence]) mismatches the given [expected] [Regex]. * + * In contrast to `containsNot.regex` it does not look for a partial match but for an entire match. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt index 639b35b56..59814f748 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt @@ -3,7 +3,8 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion -import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains +import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.* import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.IgnoringCaseSearchBehaviour import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour import ch.tutteli.kbox.glue @@ -26,7 +27,7 @@ import kotlin.jvm.JvmName * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ -fun CharSequenceContains.CheckerOption.value(expected: Any): Expect = +fun CheckerOption.value(expected: Any): Expect = values(expected) /** @@ -55,7 +56,7 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption.values( +fun CheckerOption.values( expected: Any, vararg otherExpected: Any ): Expect = addAssertion(ExpectImpl.charSequence.contains.values(this, expected glue otherExpected)) @@ -79,7 +80,7 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption.value( +fun CheckerOption.value( expected: Any ): Expect = values(expected) @@ -110,7 +111,7 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption.values( +fun CheckerOption.values( expected: Any, vararg otherExpected: Any ): Expect = addAssertion(ExpectImpl.charSequence.contains.valuesIgnoringCase(this, expected glue otherExpected)) @@ -120,7 +121,7 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption CharSequenceContains.Builder.value(expected: Any): Expect = +fun Builder.value(expected: Any): Expect = atLeast(1).value(expected) /** @@ -159,7 +160,7 @@ fun CharSequenceContains.Builder CharSequenceContains.Builder.values( +fun Builder.values( expected: Any, vararg otherExpected: Any ): Expect = atLeast(1).values(expected, *otherExpected) @@ -185,13 +186,13 @@ fun CharSequenceContains.Builder CharSequenceContains.CheckerOption.regex( +fun CheckerOption.regex( pattern: String, vararg otherPatterns: String ): Expect = addAssertion(ExpectImpl.charSequence.contains.regex(this, pattern glue otherPatterns)) /** - * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] + * Finishes the specification of the sophisticated `contains` assertion where the given [Regex] [pattern] * as well as the [otherPatterns] are expected to have a match, using a non disjoint search. * * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. @@ -213,7 +214,8 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption.regex( +//TODO rename to `matchFor` with 1.0.0 +fun CheckerOption.regex( pattern: Regex, vararg otherPatterns: Regex ): Expect = addAssertion(ExpectImpl.charSequence.contains.regex(this, pattern glue otherPatterns)) @@ -240,7 +242,7 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption.regex( +fun CheckerOption.regex( pattern: String, vararg otherPatterns: String ): Expect = addAssertion(ExpectImpl.charSequence.contains.regexIgnoringCase(this, pattern glue otherPatterns)) @@ -269,7 +271,7 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.Builder.regex( +fun Builder.regex( pattern: String, vararg otherPatterns: String ): Expect = atLeast(1).regex(pattern, *otherPatterns) @@ -292,13 +294,14 @@ fun CharSequenceContains.Builder CharSequenceContains.CheckerOption.elementsOf( +fun CheckerOption.elementsOf( expectedIterable: Iterable ): Expect { - require(expectedIterable.iterator().hasNext()) { "Iterable without elements are not allowed." } - return values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) + val (first, rest) = toVarArg(expectedIterable) + return values(first, *rest) } /** @@ -319,12 +322,13 @@ fun CharSequenceContains.CheckerOption CharSequenceContains.CheckerOption.elementsOf( +fun CheckerOption.elementsOf( expectedIterable: Iterable ): Expect { - require(expectedIterable.iterator().hasNext()) { "Iterable without elements are not allowed." } - return values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) + val (first, rest) = toVarArg(expectedIterable) + return values(first, *rest) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt index 4411dd470..4169c4434 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour import ch.tutteli.kbox.glue @@ -107,6 +108,6 @@ fun > IterableContains.CheckerOption> IterableContains.CheckerOption.elementsOf( expectedIterable: Iterable ): Expect { - require(expectedIterable.iterator().hasNext()) { "Iterable without elements are not allowed." } - return values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) + val (first, rest) = toVarArg(expectedIterable) + return values(first, *rest) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt index dd2e7d7da..3efb58d6a 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour import ch.tutteli.kbox.glue @@ -128,6 +129,6 @@ fun > IterableContains.Builder> IterableContains.Builder.elementsOf( expectedIterable: Iterable ): Expect { - require(expectedIterable.iterator().hasNext()) { "Iterable without elements are not allowed" } - return values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) + val (first, rest) = toVarArg(expectedIterable) + return values(first, *rest) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt index 55d400301..dda601b0d 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour import ch.tutteli.kbox.glue @@ -118,6 +119,6 @@ fun > IterableContains.Builder> IterableContains.Builder.elementsOf( expectedIterable: Iterable ): Expect { - require(expectedIterable.iterator().hasNext()) { "Iterable without elements are not allowed." } - return values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray()) + val (first, rest) = toVarArg(expectedIterable) + return values(first, *rest) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceAssertionsSpec.kt index f2615bb64..9ae85d4af 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceAssertionsSpec.kt @@ -3,8 +3,9 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun0 import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented -object CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec( +class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec( fun0(Expect::isEmpty), fun0(Expect::isNotEmpty), fun0(Expect::isNotBlank), @@ -18,4 +19,26 @@ object CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequ fun1(Expect::endsNotWith), fun1(Expect::matches), fun1(Expect::mismatches) -) +) { + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1.isEmpty() + a1.isNotEmpty() + a1.isNotBlank() + + a1.startsWith("expected") + a1.startsNotWith("expected") + a1.endsWith("expected") + a1.endsNotWith("expected") + + a1.startsWith('a') + a1.startsNotWith('a') + a1.endsWith('a') + a1.endsNotWith('a') + + a1.matches(Regex("a")) + a1.mismatches(Regex("a")) + } +} diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index 8c40b75b1..6de3cb375 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -155,7 +155,7 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ) = expect.contains.ignoringCase.atLeast(atLeast).butAtMost(butAtMost).elementsOf(listOf(a, *aX)) - private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot + private fun getContainsNotPair() = containsNot to ::getErrorMsgContainsNot private fun getErrorMsgContainsNot(times: Int) = "use $containsNot instead of $atLeast($times)" diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index a6708ee78..8ea1a64ec 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -1,28 +1,21 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect -import kotlin.reflect.KFunction3 +import ch.tutteli.atrium.specs.fun2 +import ch.tutteli.atrium.specs.notImplemented class CharSequenceContainsContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( - getContainsPair(), - getContainsNotPair(), + fun2>(Expect::contains), + fun2>(Expect::containsNot), "◆ ", "⚬ ", "▶ " ) { - companion object : CharSequenceContainsSpecBase() { - private val containsFun: KFunction3, Any, Array, Expect> = - Expect::contains - fun getContainsPair() = containsFun.name to Companion::containsShortcut + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() - private fun containsShortcut(expect: Expect, a: Any, aX: Array) = expect.contains(a, *aX) - - private val containsNotFun: KFunction3, Any, Array, Expect> = - Expect::containsNot - - private fun getContainsNotPair() = containsNotFun.name to Companion::containsNotShortcut - - private fun containsNotShortcut(expect: Expect, a: Any, aX: Array) = - expect.containsNot(a, *aX) + a1.contains(1, "a", 'c') + a1.containsNot(1, "a", 'c') } } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt index 0298ff043..f7c2f6886 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceConta import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.name +import ch.tutteli.atrium.specs.notImplemented import kotlin.reflect.KFunction3 import kotlin.reflect.KProperty @@ -28,4 +29,31 @@ abstract class CharSequenceContainsSpecBase { > = CharSequenceContains.CheckerOption<*, NoOpSearchBehaviour>::regex protected val regex = regexKFun.name protected val ignoringCase = CharSequenceContains.Builder<*, NoOpSearchBehaviour>::ignoringCase.name + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1.contains.atLeast(1).value(1) + a1.contains.atMost(2).values("a", 1) + a1.contains.notOrAtMost(2).regex("h|b") + a1.contains.exactly(2).regex("h|b", "b") + a1.contains.atLeast(2).regex(Regex("bla")) + a1.contains.atLeast(2).regex(Regex("bla"), Regex("b")) + a1.contains.atLeast(2).elementsOf(listOf("a", 2)) + + a1.contains.ignoringCase.atLeast(1).value("a") + a1.contains.ignoringCase.atLeast(1).values("a", 'b') + a1.contains.ignoringCase.atLeast(1).regex("a") + a1.contains.ignoringCase.atLeast(1).regex("a", "bl") + a1.contains.ignoringCase.atLeast(1).elementsOf(listOf(1, 2)) + + // skip atLeast + a1.contains.ignoringCase.value("a") + a1.contains.ignoringCase.values("a", 'b') + a1.contains.ignoringCase.regex("a") + a1.contains.ignoringCase.regex("a", "bl") + //TODO add to infix as well as fluent +// a1.contains.ignoringCase.elementsOf(listOf(1, 2))("a", "bl") + } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt new file mode 100644 index 000000000..46370d8fe --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -0,0 +1,324 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.NotCheckerOptionImpl +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NotSearchBehaviour + + +/** + * Creates a [CharSequenceContains.Builder] based on this [Expect] which allows to define + * a sophisticated `contains` assertion. + * + * @param o The filler object [o]; use [O] in case you are in an [Expect] context due to a Kotlin bug + * (see type alias for more information) + * + * @return The newly created builder. + */ +infix fun Expect.contains( + @Suppress("UNUSED_PARAMETER") o: o +): CharSequenceContains.Builder = ExpectImpl.charSequence.containsBuilder(this) + +/** + * Creates a [CharSequenceContains.Builder] based on this [Expect] which allows to define + * more sophisticated `contains not` assertion. + * + * @return The newly created builder. + */ +infix fun Expect.contains( + @Suppress("UNUSED_PARAMETER") not: not +): NotCheckerOption = NotCheckerOptionImpl(ExpectImpl.charSequence.containsNotBuilder(this)) + + +/** + * Expects that the subject of the assertion (a [CharSequence]) contains the [expected]'s [toString] representation. + * + * It is a shortcut for `contains o atLeast 1 value expected`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case [expected] is not a + * [CharSequence], [Number] or [Char]. + */ +infix fun Expect.contains(expected: Any): Expect = + this contains O atLeast 1 value expected + +/** + * Expects that the subject of the assertion (a [CharSequence]) contains the [toString] representation of the + * given [values] using a non disjoint search. + * + * It is a shortcut for `contains o atLeast 1 the Values(expected, *otherExpected)`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and + * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, + * even though they match the same sequence in the input of the search. Use the property `contains` to create + * a more sophisticated `contains` assertion where you can use options such as [atLeast], [atMost] and [exactly] + * to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `contains o exactly 2 value 'a'` + * instead of: + * `contains Values('a', 'a')` + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case one of the [values] is not a + * [CharSequence], [Number] or [Char]. + */ +infix fun Expect.contains(values: Values): Expect = + this contains O atLeast 1 the values + +/** + * Expects that the subject of the assertion (a [CharSequence]) does not contain [expected]'s [toString] representation. + * + * It is a shortcut for `contains not value expected`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.containsNot(expected: Any) = + this contains not value expected + +/** + * Expects that the subject of the assertion (a [CharSequence]) does not contain the [toString] representation + * of the given [values]. + * + * It is a shortcut for `contains not the Values(expected, *otherExpected)`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.containsNot(values: Values) = + this contains not the values + +/** + * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given + * regular expression [pattern]. + * + * It is a shortcut for `contains o atLeast 1 regex pattern`. + * + * @param pattern The pattern which is expected to have a match against the input of the search. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.containsRegex(pattern: String): Expect = + this contains O atLeast 1 regex pattern + +/** + * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given + * regular expression [pattern]. + * + * It is a shortcut for `contains o atLeast 1 regex pattern`. + * + * @param pattern The pattern which is expected to have a match against the input of the search. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.contains(pattern: Regex): Expect = + this contains O atLeast 1 matchFor pattern + +/** + * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given + * regular expression [patterns], using a non disjoint search. + * + * It is a shortcut for `contains o atLeast 1 the RegexPatterns(pattern, *otherPatterns)`. + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and + * [RegexPatterns.expected] is defined as `'a(b)?'` and one of the [RegexPatterns.otherExpected] is defined + * as `'a(b)?'` as well, then both match, even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `contains o exactly 2 regex "a(b)?"` + * instead of: + * `contains o atLeast 1 the RegexPatterns("a(b)?", "a(b)?")` + * + * @param patterns The patterns which are expected to have a match against the input of the search. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.containsRegex(patterns: RegexPatterns): Expect = + this contains O atLeast 1 the patterns + +/** + * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given + * regular expression [patterns], using a non disjoint search. + * + * It is a shortcut for `contains o atLeast 1 regex All(pattern, *otherPatterns)`. + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and + * [RegexPatterns.expected] is defined as `'a(b)?'` and one of the [RegexPatterns.otherExpected] is defined + * as `'a(b)?'` as well, then both match, even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `contains o exactly 2 regex "a(b)?"` + * instead of: + * `contains o atLeast 1 the RegexPatterns("a(b)?", "a(b)?")` + * + * @param patterns The patterns which are expected to have a match against the input of the search. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.contains(patterns: All): Expect = + this contains O atLeast 1 matchFor patterns +/** + * Expects that the subject of the assertion (a [CharSequence]) starts with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.startsWith(expected: CharSequence) = + addAssertion(ExpectImpl.charSequence.startsWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) starts with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.startsWith(expected: Char) = + o startsWith expected.toString() + +/** + * Expects that the subject of the assertion (a [CharSequence]) does not start with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.startsNotWith(expected: CharSequence) = + addAssertion(ExpectImpl.charSequence.startsNotWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) does not start with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.startsNotWith(expected: Char) = + o startsNotWith expected.toString() + + +/** + * Expects that the subject of the assertion (a [CharSequence]) ends with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.endsWith(expected: CharSequence) = + addAssertion(ExpectImpl.charSequence.endsWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) ends with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.endsWith(expected: Char) = + o endsWith expected.toString() + +/** + * Expects that the subject of the assertion (a [CharSequence]) does not end with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.endsNotWith(expected: CharSequence) = + addAssertion(ExpectImpl.charSequence.endsNotWith(this, expected)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) does not end with [expected]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.endsNotWith(expected: Char) = + o endsNotWith expected.toString() + + +/** + * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isEmpty]. + * + * @param Empty Has to be `Empty`. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = + addAssertion(ExpectImpl.charSequence.isEmpty(this)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isNotEmpty]. + * + * @param Empty Has to be `Empty`. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = + addAssertion(ExpectImpl.charSequence.isNotEmpty(this)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isNotBlank]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") Blank: Blank) = + addAssertion(ExpectImpl.charSequence.isNotBlank(this)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) matches the given [expected] [Regex]. + * + * In contrast to [containsRegex] it does not look for a partial match but for an entire match. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.matches(expected: Regex) = + addAssertion(ExpectImpl.charSequence.matches(this, expected)) + +/** + * Expects that the subject of the assertion (a [CharSequence]) mismatches the given [expected] [Regex]. + * + * In contrast to `containsNot.regex` it does not look for a partial match but for an entire match. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun Expect.mismatches(expected: Regex) = + addAssertion(ExpectImpl.charSequence.mismatches(this, expected)) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCheckers.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCheckers.kt new file mode 100644 index 000000000..be8e9797b --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCheckers.kt @@ -0,0 +1,90 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.* +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.* +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.SearchBehaviour + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the value which we are looking + * for occurs `at least` number of [times] within the search input. + * + * @param times The number which the check will compare against the actual number of times an expected value is + * found in the input of the search. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + */ +infix fun CharSequenceContains.Builder.atLeast( + times: Int +): AtLeastCheckerOption = AtLeastCheckerOptionImpl(times, this) + +/** + * Restricts a `contains at least` assertion by specifying that the number of occurrences of the value which we + * are looking for occurs `at most` number of [times] within the search input. + * + * The resulting restriction will be a `contains at least but at most` assertion. + * + * @param times The number which the check will compare against the actual number of times an expected value is + * found in the input of the search. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + * @throws IllegalArgumentException In case [times] of this `at most` restriction equals to the number of the + * `at least` restriction; use the [exactly] restriction instead. + */ +infix fun AtLeastCheckerOption.butAtMost( + times: Int +): ButAtMostCheckerOption = ButAtMostCheckerOptionImpl(times, this, containsBuilder) + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the value which we + * are looking for occurs `exactly` number of [times] within the search input. + * + * @param times The number which the check will compare against the actual number of times an expected value is + * found in the input of the search. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + */ +infix fun CharSequenceContains.Builder.exactly( + times: Int +): ExactlyCheckerOption = ExactlyCheckerOptionImpl(times, this) + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the value which we + * are looking for occurs `at least` once but `at most` number of [times] within the search input. + * + * If you want to use a higher lower bound than one, then use `atLeast(2).butAtMost(3)` instead of `atMost(3)`. + * And in case you want to state that it is either not contained at all or at most a certain number of times, + * then use `notOrAstMost(2)` instead. + * + * @param times The number which the check will compare against the actual number of times an expected value is + * found in the input of the search. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + * @throws IllegalArgumentException In case [times] equals to one; use [exactly] instead. + */ +infix fun CharSequenceContains.Builder.atMost( + times: Int +): AtMostCheckerOption = AtMostCheckerOptionImpl(times, this) + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the value which we + * are looking for occurs `not at all or at most` number of [times] within the search input. + * + * @param times The number which the check will compare against the actual number of times an expected value is + * found in the input of the search. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + */ +infix fun CharSequenceContains.Builder.notOrAtMost( + times: Int +): NotOrAtMostCheckerOption = NotOrAtMostCheckerOptionImpl(times, this) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt new file mode 100644 index 000000000..06eea54f4 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -0,0 +1,376 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.Builder +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.CheckerOption +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.IgnoringCaseSearchBehaviour +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour +import kotlin.jvm.JvmName + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [expected] object shall be searched, + * using a non disjoint search. + * + * Delegates to `the Values(expected)`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * + * @param expected The value which is expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. + */ +infix fun CheckerOption.value(expected: Any): Expect = + this the Values(expected) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given [values] + * shall be searched, using a non disjoint search. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and + * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, + * even though they match the same sequence in the input of the search. Use an option such as + * [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain exactly 2 the value 'a'` + * instead of: + * `to contain atLeast 1 the Values('a', 'a')` + * + * @param values The values which are expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case one of the [values] is not a [CharSequence], [Number] or [Char]. + */ +infix fun CheckerOption.the(values: Values): Expect = + addAssertion(ExpectImpl.charSequence.contains.values(this, values.toList())) + + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [expected] value shall be searched + * (ignoring case), using a non disjoint search. + * + * Delegates to `the Values(expected)`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * + * @param expected The value which is expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. + */ +@JvmName("valueIgnoringCase") +infix fun CheckerOption.value(expected: Any): Expect = + this the Values(expected) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [values] + * shall be searched (ignoring case), using a non disjoint search. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and + * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, + * even though they match the same sequence in the input of the search. Use an option such as + * [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain ignoring case exactly 2 the value 'a'` + * instead of: + * `to contain ignoring case atLeast 1 the Values('a', 'a')` + * + * @param values The values which are expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case one of the [values] is not a [CharSequence], [Number] or [Char]. + */ +@JvmName("valuesIgnoringCase") +infix fun CheckerOption.the(values: Values): Expect = + addAssertion(ExpectImpl.charSequence.contains.valuesIgnoringCase(this, values.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [expected] value shall be searched + * (ignoring case), using a non disjoint search where it needs to be contained at least once. + * + * Delegates to `atLeast 1 value expected`. + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * + * @param expected The value which is expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. + */ +infix fun Builder.value(expected: Any): Expect = + this atLeast 1 value expected + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [values] + * shall be searched (ignoring case), using a non disjoint search + * where each need to be contained at least once. + * + * Delegates to `atLeast 1 the value` + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and + * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain ignoring case exactly 2 the value 'a'` + * instead of: + * `to contain ignoring case atLeast 1 the Values('a', 'a')` + * + * @param values The values which are expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case one of the [values] is not a [CharSequence], [Number] or [Char]. + */ +infix fun Builder.the(values: Values): Expect = + this atLeast 1 the values + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] + * is expected to have a match, using a non disjoint search. + * + * Delegates to `the RegexPatterns(pattern)`. + * + * @param pattern The pattern which is expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun CheckerOption.regex(pattern: String): Expect = + this the RegexPatterns(pattern) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given [Regex] [pattern] + * is expected to have a match. + * + * Delegates to `All(pattern)` + * + * @param pattern The pattern which is expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun CheckerOption.matchFor( + pattern: Regex +): Expect = this matchFor All(pattern) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [patterns] + * are expected to have a match, using a non disjoint search. + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and + * [patterns].[pattern][RegexPatterns.expected] is defined as `'a(b)?'` and one of the + * [patterns].[otherPatterns][RegexPatterns.otherExpected] is defined as `'a(b)?'` as well, then both match, even though + * they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain exactly 2 the regex 'a(b)?'` + * instead of: + * `to contain atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')` + * + * @param patterns The patterns which are expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun CheckerOption.the(patterns: RegexPatterns): Expect = + addAssertion(ExpectImpl.charSequence.contains.regex(this, patterns.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given [Regex] [patterns] + * are expected to have a match, using a non disjoint search. + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and the first + * pattern in [patterns] is defined as `'a(b)?'` and one of the other patterns is defined as `'a(b)?'` as well, + * then both match, even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to + * control the number of occurrences you expect. + * + * Meaning you might want to use: + * `contains o exactly 2 matchFor Regex("a(b)?")` + * instead of: + * `contains o atLeast 1 matchFor All(Regex("a(b)?"), Regex("a(b)?")) + * + * @param patterns The patterns which are expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +infix fun CheckerOption.matchFor(patterns: All): Expect = + addAssertion(ExpectImpl.charSequence.contains.regex(this, patterns.toList())) + + + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] + * is expected to have a match (ignoring case), using a non disjoint search. + * + * Delegates to `the RegexPatterns(pattern)`. + * + * @param pattern The patterns which is expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +@JvmName("regexIgnoringCase") +infix fun CheckerOption.regex(pattern: String): Expect = + this the RegexPatterns(pattern) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [patterns] + * are expected to have a match (ignoring case), using a non disjoint search. + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and + * [patterns].[pattern][RegexPatterns.expected] is defined as `'a(b)?'` and one of the + * [patterns].[otherPatterns][RegexPatterns.otherExpected] is defined as `'a(b)?'` as well, then both match, even though + * they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain ignoring case exactly 2 the regex 'a(b)?'` + * instead of: + * `to contain ignoring case atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')` + * + * @param patterns The patterns which are expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +@JvmName("regexIgnoringCase") +infix fun CheckerOption.the(patterns: RegexPatterns): Expect = + addAssertion(ExpectImpl.charSequence.contains.regexIgnoringCase(this, patterns.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] + * is expected to have at least one match (ignoring case), using a non disjoint search. + * + * Delegates to `atLeast 1 regex pattern`. + * + * @param pattern The patterns which is expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Builder.regex(pattern: String): Expect = + this atLeast 1 regex pattern + +/** + * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [patterns] + * are expected to have at least one match (ignoring case), using a non disjoint search. + * + * Delegates to `atLeast 1 the patterns`. + * + * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and + * [patterns].[pattern][RegexPatterns.expected] is defined as `'a(b)?'` and one of the + * [patterns].[otherPatterns][RegexPatterns.otherExpected] is defined as `'a(b)?'` as well, then both match, even though + * they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain ignoring case exactly 2 the regex 'a(b)?'` + * instead of: + * `to contain ignoring case atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')` + * + * @param patterns The patterns which are expected to have a match against the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Builder.the(patterns: RegexPatterns): Expect = + this atLeast 1 the patterns + +/** + * Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable] + * shall be searched, using a non disjoint search. + * + * Delegates to `the Values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray())` + * (see [the] for more information). + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * + * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given + * [expectedIterable] does not have elements (is empty). + * + * @since 0.10.0 + */ +infix fun CheckerOption.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return this the Values(first, *rest) +} + + +/** + * Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable] + * shall be searched (ignoring case), using a non disjoint search. + * + * Delegates to `the Values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray())` + * (see [the] for more information). + * + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this + * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * + * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given + * [expectedIterable] does not have elements (is empty). + * + * @since 0.10.0 + */ +@JvmName("elementsOfIgnoringCase") +infix fun CheckerOption.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return this the Values(first, *rest) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsSearchBehaviours.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsSearchBehaviours.kt new file mode 100644 index 000000000..122367303 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsSearchBehaviours.kt @@ -0,0 +1,33 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.NotCheckerOptionImpl +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.IgnoringCaseSearchBehaviour +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NotSearchBehaviour + +/** + * Defines that the search behaviour `ignore case` shall be applied to this sophisticated `contains` assertion. + * + * @param case Has to be `case`. + * + * @return The newly created builder. + */ +infix fun CharSequenceContains.Builder.ignoring( + @Suppress("UNUSED_PARAMETER") case: case +): CharSequenceContains.Builder = + ExpectImpl.charSequence.contains.searchBehaviours.ignoringCase(this) + +/** + * Defines that the search behaviour `ignore case` shall be applied to this sophisticated `contains not` assertion. + * + * @param case Has to be `case`. + * + * @return The newly created builder. + */ +infix fun NotCheckerOption.ignoring( + @Suppress("UNUSED_PARAMETER") case: case +): NotCheckerOption = + NotCheckerOptionImpl(containsBuilder ignoring case) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtLeastCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtLeastCheckerOption.kt new file mode 100644 index 000000000..3b6cc2866 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtLeastCheckerOption.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders + +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.WithTimesCheckerOption +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the extension point for another option after a `contains at least`-check within a sophisticated + * `contains` assertion building process for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface AtLeastCheckerOption + : WithTimesCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtMostCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtMostCheckerOption.kt new file mode 100644 index 000000000..b9b942050 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/AtMostCheckerOption.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders + +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the extension point for another option after a `contains at least once but at most`-check within + * a sophisticated `contains` assertion building process for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface AtMostCheckerOption + : CharSequenceContains.CheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ButAtMostCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ButAtMostCheckerOption.kt new file mode 100644 index 000000000..a67f28ad4 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ButAtMostCheckerOption.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders + +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the extension point for another option after a `contains at least but at most`-check within + * a sophisticated `contains` assertion building process for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface ButAtMostCheckerOption + : CharSequenceContains.CheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ExactlyCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ExactlyCheckerOption.kt new file mode 100644 index 000000000..f0175cbe2 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/ExactlyCheckerOption.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders + +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the extension point for another option after a `contains exactly`-check within + * a sophisticated `contains` assertion building process for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface ExactlyCheckerOption + : CharSequenceContains.CheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotCheckerOption.kt new file mode 100644 index 000000000..7895f6c3e --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotCheckerOption.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders + +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the extension point for another option after a `contains not at all`-check within + * a sophisticated `contains` assertion building process for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface NotCheckerOption + : CharSequenceContains.CheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotOrAtMostCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotOrAtMostCheckerOption.kt new file mode 100644 index 000000000..105459299 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/NotOrAtMostCheckerOption.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders + +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the extension point for another option after a `contains not or at most`-check within + * a sophisticated `contains` assertion building process for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface NotOrAtMostCheckerOption + : CharSequenceContains.CheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt new file mode 100644 index 000000000..d90b1662d --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt @@ -0,0 +1,29 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.atLeast +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.AtLeastCheckerOptionBase +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the builder of a `contains at least`-check within the fluent API of a sophisticated + * `contains` assertion for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + * + * @constructor Represents the builder of a `contains at least` check within the fluent API of a sophisticated + * `contains` assertion for [CharSequence]. + * @param times The number which the check will compare against the actual number of times an expected object is + * found in the input of the search. + * @param containsBuilder The previously used [CharSequenceContains.Builder]. + */ +internal class AtLeastCheckerOptionImpl( + times: Int, + containsBuilder: CharSequenceContains.Builder +) : AtLeastCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun(), + { "`${containsBuilder::atLeast.name} $it`" } +), AtLeastCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt new file mode 100644 index 000000000..4d361dcd8 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt @@ -0,0 +1,33 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.atLeast +import ch.tutteli.atrium.api.infix.en_GB.atMost +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.exactly +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.AtMostCheckerOptionBase +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the builder of a `contains at least once but at most` check within the fluent API of a + * sophisticated `contains` assertion for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + * + * @constructor Represents the builder of a `contains at least once but at most` check within the fluent API of a + * sophisticated `contains` assertion for [CharSequence]. + * @param times The number which the check will compare against the actual number of times an expected object is + * found in the input of the search. + * @param containsBuilder The previously used [CharSequenceContains.Builder]. + */ +internal class AtMostCheckerOptionImpl( + times: Int, + containsBuilder: CharSequenceContains.Builder +) : AtMostCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun(), + { "`${containsBuilder::atMost.name} $it`" }, + { "`${containsBuilder::atLeast.name} $it`" }, + { "`${containsBuilder::exactly.name} $it`" } +), AtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt new file mode 100644 index 000000000..be601909c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt @@ -0,0 +1,39 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.atLeast +import ch.tutteli.atrium.api.infix.en_GB.atMost +import ch.tutteli.atrium.api.infix.en_GB.butAtMost +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.ButAtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.exactly +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.ButAtMostCheckerOptionBase +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the builder of the second step of a `contains at least but at most` check within the + * fluent API of a sophisticated `contains` assertion for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied to the input of the search. + * + * @constructor Represents the builder of the second step of a `contains at least but at most` check within the + * fluent API of a sophisticated `contains` assertion for [CharSequence]. + * @param times The number which the check will compare against the actual number of times an expected object is + * found in the input of the search. + * @param containsBuilder The previously used [CharSequenceContains.Builder]. + */ +internal class ButAtMostCheckerOptionImpl( + times: Int, + atLeastBuilder: AtLeastCheckerOption, + containsBuilder: CharSequenceContains.Builder +) : ButAtMostCheckerOptionBase( + times, + atLeastBuilder, + containsBuilder, + nameContainsNotValuesFun(), + { l, u -> "`${containsBuilder::atLeast.name} $l ${atLeastBuilder::butAtMost.name} $u`" }, + { "`${containsBuilder::atMost.name} $it`" }, + { "`${containsBuilder::atLeast.name} $it`" }, + { "`${atLeastBuilder::butAtMost.name} $it`" }, + { "`${containsBuilder::exactly.name} $it`" } +), ButAtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt new file mode 100644 index 000000000..bcc2e9822 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt @@ -0,0 +1,29 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.ExactlyCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.exactly +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.ExactlyCheckerOptionBase +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the builder of a `contains exactly` check within the fluent API of a sophisticated + * `contains` assertion for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + * + * @constructor Represents the builder of a `contains exactly` check within the fluent API of a sophisticated + * `contains` assertion for [CharSequence]. + * @param times The number which the check will compare against the actual number of times an expected object is + * found in the input of the search. + * @param containsBuilder The previously used [CharSequenceContains.Builder]. + */ +internal class ExactlyCheckerOptionImpl( + times: Int, + containsBuilder: CharSequenceContains.Builder +) : ExactlyCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun(), + { "`${containsBuilder::exactly.name} $it`" } +), ExactlyCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotCheckerOptionImpl.kt new file mode 100644 index 000000000..81aac3823 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotCheckerOptionImpl.kt @@ -0,0 +1,21 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.NotCheckerOptionBase +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the builder of a `contains not at all` check within the fluent API of a sophisticated + * `contains` assertion for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + * + * @constructor Represents the builder of a `contains not at all` check within the fluent API of a sophisticated + * `contains` assertion for [CharSequence]. + * @param containsBuilder The previously used [CharSequenceContains.Builder]. + */ +internal class NotCheckerOptionImpl( + containsBuilder: CharSequenceContains.Builder +) : NotCheckerOptionBase(containsBuilder), + NotCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt new file mode 100644 index 000000000..bb2b455b6 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt @@ -0,0 +1,29 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotOrAtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.notOrAtMost +import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.NotOrAtMostCheckerOptionBase +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains + +/** + * Represents the builder of a `contains not or at most` check within the fluent API of a + * sophisticated `contains` assertion for [CharSequence]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + * + * @constructor Represents the builder of a `contains not or at most` check within the fluent API of a + * sophisticated `contains` assertion for [CharSequence]. + * @param times The number which the check will compare against the actual number of times an expected object is + * found in the input of the search. + * @param containsBuilder The previously used [CharSequenceContains.Builder]. + */ +internal class NotOrAtMostCheckerOptionImpl( + times: Int, + containsBuilder: CharSequenceContains.Builder +) : NotOrAtMostCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun(), + { "`${containsBuilder::notOrAtMost.name} $it`" } +), NotOrAtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt new file mode 100644 index 000000000..d5757867f --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt @@ -0,0 +1,11 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.Values +import ch.tutteli.atrium.api.infix.en_GB.containsNot +import ch.tutteli.atrium.creating.Expect +import kotlin.reflect.KFunction2 + +internal fun nameContainsNotValuesFun(): String { + val f: KFunction2, Values, Expect> = Expect::containsNot + return "`${f.name} ${Values::class.simpleName}`" +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt index dfe813e4d..4b3c61686 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt @@ -20,7 +20,7 @@ import kotlin.reflect.* * * @since 0.10.0 */ -infix fun Expect.feature(property: KProperty1): FeatureExpect = +infix fun Expect.feature(property: KProperty1): FeatureExpect = ExpectImpl.feature.property(this, property).getExpectOfFeature() /** @@ -47,6 +47,8 @@ infix fun Expect.feature(f: KFunction1): FeatureExpect = * Use `of(K..., ...)` to create a [Feature] where the first argument is the extractor in form of a * [KProperty1] or a `KFunctionX` and potentially the required arguments for a `KFunctionX` where `X` > 1. * + * Note, [Feature] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) + * * @param of Use `of(K..., ...)` to create a [Feature] where the first argument is the extractor in form of a * [KProperty1] or a `KFunctionX` and potentially the required arguments for a `KFunctionX` where `X` > 1. * @@ -54,7 +56,8 @@ infix fun Expect.feature(f: KFunction1): FeatureExpect = * * @since 0.10.0 */ -infix fun Expect.feature(of: Feature): FeatureExpect = +//TODO remove `in` with Kotlin 1.4 (most likely with Atrium 1.0.0) +infix fun Expect.feature(of: Feature): FeatureExpect = ExpectImpl.feature.manualFeature(this, of.description, of.extractor).getExpectOfFeature() /** @@ -67,6 +70,8 @@ infix fun Expect.feature(of: Feature): FeatureExpect = * form of a [KProperty1] or a `KFunctionX`, the last an `assertionCreator`-lambda and the remaining arguments * in-between the required arguments in case of a `KFunctionX` where `X` > 1. * + * Note, [FeatureWithCreator] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) + * * @param of Use `of(K..., ...) { ... }` to create a [FeatureWithCreator] where the first argument is the extractor in * form of a [KProperty1] or a `KFunctionX`, the last an `assertionCreator`-lambda and the remaining arguments * in-between the required arguments in case of a `KFunctionX` where `X` > 1. @@ -76,7 +81,8 @@ infix fun Expect.feature(of: Feature): FeatureExpect = * * @since 0.10.0 */ -infix fun Expect.feature(of: FeatureWithCreator): Expect = +//TODO remove `in` with Kotlin 1.4 (most likely with Atrium 1.0.0) +infix fun Expect.feature(of: FeatureWithCreator): Expect = ExpectImpl.feature.manualFeature(this, of.description, of.extractor).addToInitial(of.assertionCreator) @@ -182,7 +188,7 @@ fun of(f: KFunction6, a1: A /** * Helper function to create a [FeatureWithCreator] based on a [KProperty1] + [assertionCreator]. */ -fun of(property: KProperty1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = +fun of(property: KProperty1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(property.name, { property.invoke(it) }, assertionCreator) /** diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index e6b45b239..16647ec91 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -2,6 +2,8 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.creating.Expect + /** * Marker interface for keywords. * @@ -10,6 +12,7 @@ package ch.tutteli.atrium.api.infix.en_GB */ interface Keyword +//TODO not used yet, should be used though internal const val ERR_KEYWORD_GIVEN_COLLECTION_ASSUMED = "This call will most probably fail at runtime because the given subject is not a collection as you might have assumed. If you really want to compare the subject against the keyword, then cast the keyword to Any" @@ -49,6 +52,14 @@ object entries : Keyword */ object group : Keyword +/** + * Represents the pseudo keyword `not` as in [contains] `not`. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * + * @since 0.10.0 + */ +object not : Keyword + /** * Represents a filler, a pseudo keyword where there isn't really a good keyword. * A reader should skip this filler without reading it. For instance, `contains o atLeast 1...` should be read as @@ -60,6 +71,16 @@ object group : Keyword */ object o : Keyword +/** + * Workaround for https://youtrack.jetbrains.com/issue/KT-36624, extension property takes precedence over object. + * + * In case you want to refer to the pseudo-keyword `o` inside an [Expect] context, + * then you can use this type alias instead to circumvent the bug. + * + * @since 0.10.0 + */ +typealias O = o + /** * Represents the pseudo keyword `only` as in [and] `only`. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt index aeb3f4cde..7aff937a5 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt @@ -1,6 +1,10 @@ +@file:Suppress("DEPRECATION" /** TODO remove suppress with 1.0.0 */) package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries +import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries import ch.tutteli.atrium.domain.builders.utils.VarArgHelper /** @@ -25,3 +29,24 @@ class Pairs( override val expected: Pair, override vararg val otherExpected: Pair ) : VarArgHelper> + +/** + * Parameter object to express `String, vararg String` in the infix-api. + */ +class RegexPatterns(pattern: String, vararg otherPatterns: String) : VarArgHelper { + override val expected = pattern + override val otherExpected = otherPatterns +} + +/** + * Represents a [Group] of multiple values. + * + * Note, [Values] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) + */ +//TODO remove `out` with Kotlin 1.4 (most likely with Atrium 1.0.0) +class Values( + override val expected: T, + override vararg val otherExpected: T +) : GroupWithoutNullableEntries, GroupWithNullableEntries, VarArgHelper { + override fun toList() = listOf(expected, *otherExpected) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt new file mode 100644 index 000000000..e5e12e58b --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -0,0 +1,50 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +/** + * Expects that the property [Throwable.message] of the subject of the assertion is not null, + * creates an [Expect] for it and returns it. + * + * @return The newly created [Expect] for the property [Throwable.message] of the subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +val Expect.message: Expect + get() = o feature Throwable::message notToBeNull O + +/** + * Expects that the property [Throwable.message] of the subject of the assertion is not null and + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.message(assertionCreator: Expect.() -> Unit): Expect = + o feature of(Throwable::message) { o notToBeNull assertionCreator } + +/** + * Expects that the property [Throwable.message] of the subject of the assertion is not null and contains + * [expected]'s [toString] representation using a non disjoint search. + ** + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed + * (this function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.messageContains(expected: Any): Expect = + this messageContains Values(expected) + +/** + * Expects that the property [Throwable.message] of the subject of the assertion is not null and contains + * [values]'s [toString] representation using a non disjoint search. + ** + * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed + * (this function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun Expect.messageContains(values: Values): Expect = + message { contains(values) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt new file mode 100644 index 000000000..59a7deb8f --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt @@ -0,0 +1,50 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + +class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec( + "toBe ${Empty::class.simpleName}" to ::toBeEmpty, + "notToBe ${Empty::class.simpleName}" to ::notToBeEmpty, + "notToBe ${Blank::class.simpleName}" to ::notToBeBlank, + fun1(Expect::startsWith), + fun1(Expect::startsWith), + fun1(Expect::startsNotWith), + fun1(Expect::startsNotWith), + fun1(Expect::endsWith), + fun1(Expect::endsWith), + fun1(Expect::endsNotWith), + fun1(Expect::endsNotWith), + fun1(Expect::matches), + fun1(Expect::mismatches) +) { + companion object : WithAsciiReporter() + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1 toBe Empty + a1 notToBe Empty + a1 notToBe Blank + + a1 startsWith "expected" + a1 startsNotWith "expected" + a1 endsWith "expected" + a1 endsNotWith "expected" + + a1 startsWith 'a' + a1 startsNotWith 'a' + a1 endsWith 'a' + a1 endsNotWith 'a' + + a1 matches Regex("a") + a1 mismatches Regex("a") + } +} + +private fun toBeEmpty(expect: Expect) = expect toBe Empty +private fun notToBeEmpty(expect: Expect) = expect notToBe Empty +private fun notToBeBlank(expect: Expect) = expect notToBe Blank diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt new file mode 100644 index 000000000..47cbe2149 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -0,0 +1,174 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.verbs.internal.expect +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +class CharSequenceContainsAtLeastAssertionsSpec : Spek({ + include(object : ch.tutteli.atrium.specs.integration.CharSequenceContainsAtLeastAssertionsSpec( + getAtLeastValuesTriple(), + getAtLeastIgnoringCaseValuesTriple(), + getAtLeastButAtMostValuesTriple(), + getAtLeastBustAtMostIgnoringCaseValuesTriple(), + getContainsNotPair(), + getExactlyPair(), + CharSequenceContainsAtLeastAssertionsSpec.Companion::getErrorMsgAtLeastButAtMost, + "* ", "- " + ) {}) + + include(object : ch.tutteli.atrium.specs.integration.CharSequenceContainsAtLeastAssertionsSpec( + getAtLeastElementsOfTriple(), + getAtLeastIgnoringCaseElementsOfTriple(), + getAtLeastButAtMostElementsOfTriple(), + getAtLeastButAtMostIgnoringCaseElementsOfTriple(), + getContainsNotPair(), + getExactlyPair(), + CharSequenceContainsAtLeastAssertionsSpec.Companion::getErrorMsgAtLeastButAtMost, + "* ", "- " + ) {}) + + include(object : Spek({ + describe("elementsOf") { + it("passing an empty iterable throws an IllegalArgumentException") { + expect { + expect("test") contains o atLeast 1 elementsOf emptyList() + }.toThrow { o messageContains "Iterable without elements are not allowed" } + } + } + describe("elementsOf ignoring case") { + it("passing an empty iterable throws an IllegalArgumentException") { + expect { + expect("test") contains o ignoring case atLeast 1 elementsOf emptyList() + }.toThrow { o messageContains "Iterable without elements are not allowed" } + } + } + }) {}) +}) { + + companion object : CharSequenceContainsSpecBase() { + + private val atLeastDescr = { what: String, times: String -> "$contains $what $atLeast $times" } + internal fun getAtLeastValuesTriple() = + atLeastDescr to ("$contains o $atLeast" to Companion::containsAtLeast) + + private fun containsAtLeast( + expect: Expect, + atLeast: Int, + a: Any, + aX: Array + ): Expect = + if (aX.isEmpty()) expect contains o atLeast atLeast value a + else expect contains o atLeast atLeast the Values(a, *aX) + + internal fun getAtLeastElementsOfTriple() = + atLeastDescr to ("$contains o $atLeast" to Companion::containsAtLeastElementsOf) + + private fun containsAtLeastElementsOf( + expect: Expect, + atLeast: Int, + a: Any, + aX: Array + ): Expect = + expect contains o atLeast atLeast elementsOf listOf(a, *aX) + + private val atLeastIgnoringCaseDescr = + { what: String, times: String -> "$contains o $ignoringCase $what $atLeast $times" } + + private fun getAtLeastIgnoringCaseValuesTriple() = + atLeastIgnoringCaseDescr to ("$contains o $ignoringCase $atLeast" to Companion::containsAtLeastIgnoringCaseValues) + + private fun containsAtLeastIgnoringCaseValues( + expect: Expect, + atLeast: Int, + a: Any, + aX: Array + ): Expect = + if (aX.isEmpty()) { + if (atLeast == 1) expect contains o ignoring case value a + else expect contains o ignoring case atLeast atLeast value a + } else { + if (atLeast == 1) expect contains o ignoring case the Values(a, *aX) + else expect contains o ignoring case atLeast atLeast the Values(a, *aX) + } + + private fun getAtLeastIgnoringCaseElementsOfTriple() = + atLeastIgnoringCaseDescr to ("$contains o $ignoringCase $atLeast" to Companion::containsAtLeastIgnoringCaseElementsOf) + + private fun containsAtLeastIgnoringCaseElementsOf( + expect: Expect, + atLeast: Int, + a: Any, + aX: Array + ): Expect = + expect contains o ignoring case atLeast atLeast elementsOf listOf(a, *aX) + + private val atLeastButAtMostDescr = { what: String, timesAtLeast: String, timesAtMost: String -> + "$contains o $what $atLeast $timesAtLeast $butAtMost $timesAtMost" + } + + private fun getAtLeastButAtMostElementsOfTriple() = + atLeastButAtMostDescr to ("$contains o $atLeast o $butAtMost" to Companion::containsAtLeastButAtMostElementsOf) + + private fun containsAtLeastButAtMostElementsOf( + expect: Expect, + atLeast: Int, + butAtMost: Int, + a: Any, + aX: Array + ) = expect contains o atLeast atLeast butAtMost butAtMost elementsOf listOf(a, *aX) + + private fun getAtLeastButAtMostValuesTriple() = + atLeastButAtMostDescr to ("$contains o $atLeast o $butAtMost" to Companion::containsAtLeastButAtMostValues) + + private fun containsAtLeastButAtMostValues( + expect: Expect, + atLeast: Int, + butAtMost: Int, + a: Any, + aX: Array + ) = + if (aX.isEmpty()) expect contains o atLeast atLeast butAtMost butAtMost value a + else expect contains o atLeast atLeast butAtMost butAtMost the Values(a, *aX) + + private val atLeastButAtMostIgnoringCaseDescr = { what: String, timesAtLeast: String, timesAtMost: String -> + "$contains $ignoringCase $what $atLeast $timesAtLeast $butAtMost $timesAtMost" + } + + private fun getAtLeastBustAtMostIgnoringCaseValuesTriple() = + atLeastButAtMostIgnoringCaseDescr to ("$contains o $ignoringCase $atLeast $butAtMost" to Companion::containsAtLeastButAtMostIgnoringCaseValues) + + private fun containsAtLeastButAtMostIgnoringCaseValues( + expect: Expect, + atLeast: Int, + butAtMost: Int, + a: Any, + aX: Array + ) = + if (aX.isEmpty()) expect contains o ignoring case atLeast atLeast butAtMost butAtMost value a + else expect contains o ignoring case atLeast atLeast butAtMost butAtMost the Values(a, *aX) + + private fun getAtLeastButAtMostIgnoringCaseElementsOfTriple() = + atLeastButAtMostIgnoringCaseDescr to ("$contains o $ignoringCase $atLeast $butAtMost" to Companion::containsAtLeastButAtMostIgnoringCaseElementsOf) + + private fun containsAtLeastButAtMostIgnoringCaseElementsOf( + expect: Expect, + atLeast: Int, + butAtMost: Int, + a: Any, + aX: Array + ) = expect contains o ignoring case atLeast atLeast butAtMost butAtMost elementsOf listOf(a, *aX) + + private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNotValues` instead of `$atLeast $times`" + + private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly + + private fun getErrorMsgExactly(times: Int) = + "use `$exactly $times` instead of `$atLeast $times $butAtMost $times`" + + internal fun getErrorMsgAtLeastButAtMost(timesAtLeast: Int, timesButAtMost: Int) = + "specifying `$butAtMost $timesButAtMost` does not make sense if `$atLeast $timesAtLeast` was used before" + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt new file mode 100644 index 000000000..ad05a8949 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt @@ -0,0 +1,42 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + + +class CharSequenceContainsAtMostAssertionsSpec : + ch.tutteli.atrium.specs.integration.CharSequenceContainsAtMostAssertionsSpec( + getAtMostTriple(), + getAtMostIgnoringCaseTriple(), + getContainsNotPair(), + getExactlyPair(), + "* ", "- " + ) { + + companion object : CharSequenceContainsSpecBase() { + + private fun getAtMostTriple() = + { what: String, times: String -> "$contains $what $atMost $times" } to + ("$contains o $atMost" to Companion::containsAtMost) + + private fun containsAtMost(expect: Expect, atMost: Int, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains o atMost atMost value a + else expect contains o atMost atMost the Values(a, *aX) + + private fun getAtMostIgnoringCaseTriple() = + { what: String, times: String -> "$contains $ignoringCase $what $atMost $times" } to + ("$contains o $ignoringCase $atMost" to Companion::containsAtMostIgnoringCase) + + private fun containsAtMostIgnoringCase(expect: Expect, atMost: Int, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains o ignoring case atMost atMost value a + else expect contains o ignoring case atMost atMost the Values(a, *aX) + + private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNotValues` instead of `$atMost $times`" + + private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly + + private fun getErrorMsgExactly(times: Int) = + "use `$exactly $times` instead of `$atMost $times`; `$atMost $times` defines implicitly `$atLeast $times` as well" + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt new file mode 100644 index 000000000..0f195dc14 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -0,0 +1,31 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun2 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + +class CharSequenceContainsContainsNotAssertionsSpec : + ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( + fun2>(::contains), + fun2>(::containsNot), + "* ", "- ", ">> " + ) { + companion object : WithAsciiReporter() + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1 contains Values(1, "a", 'c') + a1 containsNot Values(1, "a", 'c') + } +} + +private fun contains(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains a + else expect contains Values(a, *aX) + +private fun containsNot(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect containsNot a + else expect containsNot Values(a, *aX) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt new file mode 100644 index 000000000..0cdcd4ae7 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt @@ -0,0 +1,40 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class CharSequenceContainsExactlyAssertionsSpec : + ch.tutteli.atrium.specs.integration.CharSequenceContainsExactlyAssertionsSpec( + getExactlyTriple(), + getExactlyIgnoringCaseTriple(), + getContainsNotPair(), + "* ", "- " + ) { + + companion object : CharSequenceContainsSpecBase() { + + private fun getExactlyTriple() = + { what: String, times: String -> "$contains $what $exactly $times" } to + ("$contains o $exactly" to Companion::containsExactly) + + private fun containsExactly(expect: Expect, exactly: Int, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains o exactly exactly value a + else expect contains o exactly exactly the Values(a, *aX) + + private fun getExactlyIgnoringCaseTriple() = + { what: String, times: String -> "$contains $ignoringCase $what $exactly $times" } to + ("$contains o $ignoringCase $exactly" to Companion::containsExactlyIgnoringCase) + + + private fun containsExactlyIgnoringCase( + expect: Expect, + exactly: Int, + a: Any, + aX: Array + ) = + if (aX.isEmpty()) expect contains o ignoring case exactly exactly value a + else expect contains o ignoring case exactly exactly the Values(a, *aX) + + private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNotValues` instead of `$exactly $times`" + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt new file mode 100644 index 000000000..6a83923e7 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt @@ -0,0 +1,29 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsNotAssertionsSpec( + getContainsNotTriple(), + getContainsNotIgnoringCaseTriple(), + "* ", "- " +) { + + companion object : CharSequenceContainsSpecBase() { + + private fun getContainsNotTriple() = + { what: String -> "$containsNotValues $what" } to + (containsNotValues to Companion::containsNotFun) + + private fun containsNotFun(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains not value a + else expect contains not the Values(a, *aX) + + private fun getContainsNotIgnoringCaseTriple() = + { what: String -> "$containsNotValues $ignoringCase $what" } to + ("$containsNotValues o $ignoringCase" to Companion::containsNotIgnoringCase) + + private fun containsNotIgnoringCase(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains not ignoring case value a + else expect contains not ignoring case the Values(a, *aX) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt new file mode 100644 index 000000000..954ba37cc --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt @@ -0,0 +1,42 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class CharSequenceContainsNotOrAtMostAssertionsSpec : + ch.tutteli.atrium.specs.integration.CharSequenceContainsNotOrAtMostAssertionsSpec( + getNotOrAtMostTriple(), + getNotOrAtMostIgnoringCaseTriple(), + getContainsNotPair(), + "* ", "- " + ) { + + companion object : CharSequenceContainsSpecBase() { + + private fun getNotOrAtMostTriple() = + { what: String, times: String -> "$contains $what $notOrAtMost $times" } to + ("$contains o $notOrAtMost" to Companion::containsNotOrAtMost) + + private fun containsNotOrAtMost(expect: Expect, atMost: Int, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains o notOrAtMost atMost value a + else expect contains o notOrAtMost atMost the Values(a, *aX) + + private fun getNotOrAtMostIgnoringCaseTriple() = + { what: String, times: String -> "$contains $ignoringCase $what $notOrAtMost $times" } to + ("$contains o $ignoringCase $notOrAtMost" to Companion::containsNotOrAtMostIgnoringCase) + + private fun containsNotOrAtMostIgnoringCase( + expect: Expect, + atMost: Int, + a: Any, + aX: Array + ) = + if (aX.isEmpty()) expect contains o ignoring case notOrAtMost atMost value a + else expect contains o ignoring case notOrAtMost atMost the Values(a, *aX) + + + private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNotValues` instead of `$notOrAtMost $times`" + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt new file mode 100644 index 000000000..3b4d48db5 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt @@ -0,0 +1,139 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek + +class CharSequenceContainsRegexAssertionsSpec : Spek({ + include(StringSpec) + include(RegexSpec) +}) { + object StringSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsRegexAssertionsSpec( + getNameContainsRegex(), + getAtLeastTripleString(), + getAtLeastIgnoringCaseTripleString(), + getShortcutTripleString(), + getAtMostTripleString(), + getAtMostIgnoringCaseTripleString(), + "* ", "- ", + "[StringSpec] " + ) + + object RegexSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsRegexAssertionsSpec( + getNameContainsRegex(), + getAtLeastTripleRegex(), + getAtLeastIgnoringCaseTripleString(), + getShortcutTripleRegex(), + getAtMostTripleRegex(), + getAtMostIgnoringCaseTripleString(), + "* ", "- ", + "[RegexSpec] " + ) + + companion object : CharSequenceContainsSpecBase() { + + private fun getNameContainsRegex() = "$contains with search mode $regex" + + private fun getAtLeastTripleString() = + { what: String, times: String -> "$contains $what $atLeast $times" } to + ("$contains o $atLeast $regex" to ::containsAtLeastString) + + private fun getAtLeastTripleRegex() = + { what: String, times: String -> "$contains $what $atLeast $times" } to + ("$contains o $atLeast $regex" to ::containsAtLeastRegex) + + private fun containsAtLeastString( + expect: Expect, + atLeast: Int, + a: String, + aX: Array + ) = + if (aX.isEmpty()) expect contains o atLeast atLeast regex a + else expect contains o atLeast atLeast the RegexPatterns(a, *aX) + + private fun containsAtLeastRegex(expect: Expect, atLeast: Int, a: String, aX: Array) = + if (aX.isEmpty()) expect contains o atLeast atLeast matchFor Regex(a) + else expect contains o atLeast atLeast matchFor All(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) + + private fun getAtLeastIgnoringCaseTripleString() = + { what: String, times: String -> "$contains $ignoringCase $what $atLeast $times" } to + ("$contains o $atLeast $ignoringCase $regex" to ::containsAtLeastIgnoringCase) + + private fun containsAtLeastIgnoringCase( + expect: Expect, + atLeast: Int, + a: String, + aX: Array + ) = + if (aX.isEmpty()) { + if (atLeast == 1) expect contains o ignoring case regex a + else expect contains o ignoring case atLeast atLeast regex a + } else { + if (atLeast == 1) expect contains o ignoring case the RegexPatterns(a, *aX) + else expect contains o ignoring case atLeast atLeast the RegexPatterns(a, *aX) + } + + private fun getShortcutTripleString() = + { what: String, times: String -> "$contains $what $atLeast $times" } to + (containsRegex to ::containsShortcutString) + + private fun getShortcutTripleRegex() = + { what: String, times: String -> "$contains $what $atLeast $times" } to + (containsRegex to ::containsShortcutRegex) + + private fun containsShortcutString( + expect: Expect, + a: String, + aX: Array + ) = + if (aX.isEmpty()) expect containsRegex a + else expect containsRegex RegexPatterns(a, *aX) + + private fun containsShortcutRegex( + expect: Expect, + a: String, + aX: Array + ) = + if (aX.isEmpty()) expect contains Regex(a) + else expect contains All(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) + + + private fun getAtMostTripleString() = + { what: String, times: String -> "$contains $what $atMost $times" } to + ("$contains o $atMost $regex" to ::containsAtMostString) + + private fun getAtMostTripleRegex() = + { what: String, times: String -> "$contains $what $atMost $times" } to + ("$contains o $atMost $regex" to ::containsAtMostRegex) + + private fun containsAtMostString( + expect: Expect, + atMost: Int, + a: String, + aX: Array + ) = + if (aX.isEmpty()) expect contains o atMost atMost regex a + else expect contains o atMost atMost the RegexPatterns(a, *aX) + + private fun getAtMostIgnoringCaseTripleString() = + { what: String, times: String -> "$contains $ignoringCase $what $atMost $times" } to + ("$contains o $ignoringCase $atMost $regex" to ::containsAtMostIgnoringCase) + + private fun containsAtMostRegex( + expect: Expect, + atMost: Int, + a: String, + aX: Array + ) = + if (aX.isEmpty()) expect contains o atMost atMost matchFor Regex(a) + else expect contains o atMost atMost matchFor All(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) + + private fun containsAtMostIgnoringCase( + expect: Expect, + atMost: Int, + a: String, + aX: Array + ) = + if (aX.isEmpty()) expect contains o ignoring case atMost atMost regex a + else expect contains o ignoring case atMost atMost the RegexPatterns(a, *aX) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt new file mode 100644 index 000000000..b28852362 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -0,0 +1,60 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.name +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import kotlin.reflect.KFunction2 + +abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { + private val containsProp: KFunction2, o, CharSequenceContains.Builder> = + Expect::contains + protected val contains = containsProp.name + private val containsNotFun: KFunction2, Any, Expect> = Expect::containsNot + protected val containsNotValues = "${containsNotFun.name} ${Values::class.simpleName}" + protected val containsRegex = fun1(Expect::containsRegex).name + protected val atLeast = CharSequenceContains.Builder<*, *>::atLeast.name + protected val butAtMost = AtLeastCheckerOption<*, *>::butAtMost.name + protected val exactly = CharSequenceContains.Builder<*, *>::exactly.name + protected val atMost = CharSequenceContains.Builder<*, *>::atMost.name + protected val notOrAtMost = CharSequenceContains.Builder<*, *>::notOrAtMost.name + private val regexKFun: KFunction2< + CharSequenceContains.CheckerOption<*, NoOpSearchBehaviour>, + String, + Expect<*> + > = CharSequenceContains.CheckerOption<*, NoOpSearchBehaviour>::regex + protected val regex = regexKFun.name + protected val ignoringCase = + "${CharSequenceContains.Builder<*, NoOpSearchBehaviour>::ignoring.name} ${case::class.simpleName}" + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect = notImplemented() + + a1 contains o atLeast 1 value 1 + a1 contains o atMost 2 the Values("a", 1) + a1 contains o notOrAtMost 2 regex "h|b" + a1 contains o exactly 2 the RegexPatterns("h|b", "b") + a1 contains o atLeast 2 matchFor Regex("bla") + a1 contains o atLeast 2 matchFor All(Regex("bla"), Regex("b")) + a1 contains o atLeast 2 elementsOf listOf(1, 2) + + a1 contains o ignoring case atLeast 1 value "a" + a1 contains o ignoring case atLeast 1 the Values("a", 'b') + a1 contains o ignoring case atLeast 1 regex "a" + a1 contains o ignoring case atLeast 1 the RegexPatterns("a", "bl") + a1 contains o ignoring case atLeast 1 elementsOf listOf(1, 2) + + // skip atLeast + a1 contains o ignoring case value "a" + a1 contains o ignoring case the Values("a", 'b') + a1 contains o ignoring case regex "a" + a1 contains o ignoring case the RegexPatterns("a", "bl") + //TODO add to infix as well as fluent + //a1 contains o ignoring case elementsOf listOf(1, 2) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt new file mode 100644 index 000000000..825c4a4cf --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -0,0 +1,29 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.fun2 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.property + +class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAssertionsSpec( + property(Expect::message), + fun1.() -> Unit>(Expect::message), + fun2(::messageContains) +) { + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect = notImplemented() + + a1.message + a1 = a1 message {} + a1 = a1 messageContains "a" + a1 = a1 messageContains 'a' + a1 = a1 messageContains Values("a", 1, 'b') + } +} + +private fun messageContains(expect: Expect, expected: Any, vararg otherExpected: Any): Expect = + if (otherExpected.isEmpty()) expect messageContains expected + else expect messageContains Values(expected, *otherExpected) diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt index 34f69587c..0c795e12c 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt @@ -26,3 +26,14 @@ interface VarArgHelper { */ fun toList(): List = expected glue otherExpected } + +/** + * Transforms the given [iterable] to `Pair>` with the intend that it can be easily used for a function + * requiring `T, vararg T` + * + * @throws IllegalArgumentException in case the iterable is empty. + */ +inline fun toVarArg(iterable: Iterable): Pair> { + require(iterable.iterator().hasNext()) { "Iterable without elements are not allowed for this function." } + return iterable.first() to iterable.drop(1).toTypedArray() +} diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsRegexAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsRegexAssertionsSpec.kt index aa00b115c..37273873f 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsRegexAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsRegexAssertionsSpec.kt @@ -66,55 +66,55 @@ abstract class CharSequenceContainsRegexAssertionsSpec( describeFun(containsRegex) { context("throws an ${IllegalArgumentException::class.simpleName}") { - it("if an erroneous pattern is passed to `$containsAtLeast` as first argument") { + it("if an erroneous pattern is passed to `${containsAtLeast.name}` as first argument") { expect { expect("a" as CharSequence).containsAtLeastFun(1, "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtLeast` as second argument") { + it("if an erroneous pattern is passed to `${containsAtLeast.name}` as second argument") { expect { expect("a" as CharSequence).containsAtLeastFun(1, "h(a|e)llo", "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtLeastIgnoringCase` as first argument") { + it("if an erroneous pattern is passed to `${containsAtLeastIgnoringCase.name}` as first argument") { expect { expect("a" as CharSequence).containsAtLeastIgnoringCaseFun(1, "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtLeastIgnoringCase` as second argument") { + it("if an erroneous pattern is passed to `${containsAtLeastIgnoringCase.name}` as second argument") { expect { expect("a" as CharSequence).containsAtLeastIgnoringCaseFun(1, "h(a|e)llo", "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsShortcut` as first argument") { + it("if an erroneous pattern is passed to `${containsShortcut.name}` as first argument") { expect { expect("a" as CharSequence).containsShortcutFun("notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsShortcut` as second argument") { + it("if an erroneous pattern is passed to `${containsShortcut.name}` as second argument") { expect { expect("a" as CharSequence).containsShortcutFun("h(a|e)llo", "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtMost` as first argument") { + it("if an erroneous pattern is passed to `${containsAtMost.name}` as first argument") { expect { expect("a" as CharSequence).containsAtMostFun(2, "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtMost` as second argument") { + it("if an erroneous pattern is passed to `${containsAtMost.name}` as second argument") { expect { expect("a" as CharSequence).containsAtMostFun(2, "h(a|e)llo", "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtMostIgnoringCase` as first argument") { + it("if an erroneous pattern is passed to `${containsAtMostIgnoringCase.name}` as first argument") { expect { expect("a" as CharSequence).containsAtMostIgnoringCaseFun(2, "notA(validPattern") }.toThrow() } - it("if an erroneous pattern is passed to `$containsAtMostIgnoringCase` as second argument") { + it("if an erroneous pattern is passed to `${containsAtMostIgnoringCase.name}` as second argument") { expect { expect("a" as CharSequence).containsAtMostIgnoringCaseFun(2, "h(a|e)llo", "notA(validPattern") }.toThrow() From cedef07f46e686edde04c106c22982568142f63e Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Wed, 26 Feb 2020 12:29:24 -0500 Subject: [PATCH 062/142] add shortcut fun `cause` for Throwable::getCause (#31) --- .../api/fluent/en_GB/throwableAssertions.kt | 34 +++++++++ .../fluent/en_GB/ThrowableAssertionsSpec.kt | 19 ++++- .../robstoll/lib/reporting/AdjustStackSpec.kt | 3 +- .../domain/creating/ThrowableAssertions.kt | 8 +++ .../creating/throwableAssertionsBuilders.kt | 10 +++ .../lib/creating/throwableAssertions.kt | 26 +++++++ .../creating/ThrowableAssertionsImpl.kt | 11 +++ .../integration/ThrowableAssertionsSpec.kt | 69 +++++++++++++++++++ 8 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt index 250d81860..ef1bbb998 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl /** * Expects that the property [Throwable.message] of the subject of the assertion is not null, @@ -39,3 +40,36 @@ fun Expect.message(assertionCreator: Expect.() -> Uni */ fun Expect.messageContains(expected: Any, vararg otherExpected: Any): Expect = message { contains(expected, *otherExpected) } + + +/** + * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type), + * creates an [Expect] of the [TSub] type for it and returns it. + * + * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +@Suppress("RemoveExplicitTypeArguments") +inline fun Expect.cause(): Expect = + ExpectImpl.throwable.cause(this, TSub::class).getExpectOfFeature() + +/** + * + * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type) and + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * Notice, in contrast to other assertion functions which expect an [assertionCreator], this function returns not + * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TSub]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +@Suppress("RemoveExplicitTypeArguments") +inline fun Expect.cause( + noinline assertionCreator: Expect.() -> Unit +): Expect = + ExpectImpl.throwable.cause(this, TSub::class).addToFeature(assertionCreator) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt index 7607a7431..ce0e27a76 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt @@ -5,13 +5,26 @@ import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.withFeatureSuffix class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAssertionsSpec( property(Expect::message), fun1.() -> Unit>(Expect::message), - fun2(Expect::messageContains) + fun2(Expect::messageContains), + ("cause" to Companion::causeFeature).withFeatureSuffix(), + "cause" to Companion::cause ) { + companion object { + + @Suppress("RemoveExplicitTypeArguments") + private fun causeFeature(expect: Expect): Expect = expect.cause() + + @Suppress("RemoveExplicitTypeArguments") + private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = + expect.cause(assertionCreator) + } + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var a1: Expect = notImplemented() @@ -19,5 +32,9 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1.message a1 = a1.message {} a1 = a1.messageContains("asdf") + + var a2: Expect = notImplemented() + a2.cause().message { } + a2.cause { message { }} } } diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackSpec.kt index 4133782f1..f365d6ae2 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackSpec.kt @@ -108,8 +108,7 @@ class AdjustStackSpec : Spek({ throwable.addSuppressed(throwable2) adjuster.adjust(throwable) expect(throwable.suppressed).asList().all { - //TODO #31 replace with shortcut fun - feature { f(it::cause) }.notToBeNull { + cause { feature { f(it::stackBacktrace) } .containsNot.entries(containsNotFirst, *containsNotRest) .contains(containsFirst, *containsRest) diff --git a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt index 52851d4ec..09c6efca9 100644 --- a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt +++ b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt @@ -1,9 +1,12 @@ package ch.tutteli.atrium.domain.creating import ch.tutteli.atrium.core.polyfills.loadSingleService +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.creating.changers.ChangedSubjectPostStep import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.reporting.translating.Untranslatable +import kotlin.reflect.KClass /** * The access point to an implementation of [ThrowableAssertions]. @@ -19,6 +22,11 @@ val throwableAssertions by lazy { loadSingleService(ThrowableAssertions::class) //TODO remove with 1.0.0 if there aren't any non-deprecated functions added interface ThrowableAssertions { + fun cause( + expect: Expect, + expectedType: KClass + ): ChangedSubjectPostStep + /** * Turns the given [assertionVerb] into an [Untranslatable] and delegates to the other overload. */ diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/throwableAssertionsBuilders.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/throwableAssertionsBuilders.kt index 2e278e0da..2dd9be25c 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/throwableAssertionsBuilders.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/creating/throwableAssertionsBuilders.kt @@ -4,7 +4,10 @@ package ch.tutteli.atrium.domain.builders.creating import ch.tutteli.atrium.core.polyfills.loadSingleService import ch.tutteli.atrium.creating.AssertionPlant +import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.creating.ThrowableAssertions +import ch.tutteli.atrium.domain.creating.changers.ChangedSubjectPostStep +import ch.tutteli.atrium.domain.creating.listAssertions import ch.tutteli.atrium.domain.creating.throwable.thrown.ThrowableThrown import ch.tutteli.atrium.domain.creating.throwable.thrown.creators.ThrowableThrownAssertions import ch.tutteli.atrium.domain.creating.throwable.thrown.creators.throwableThrownAssertions @@ -21,6 +24,13 @@ import kotlin.reflect.KClass */ object ThrowableAssertionsBuilder : ThrowableAssertions { + override inline fun cause( + expect: Expect, + expectedType: KClass + ): ChangedSubjectPostStep = + throwableAssertions.cause(expect, expectedType) + + @Deprecated( "Use Expect instead; will be removed with 1.0.0", ReplaceWith( diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt new file mode 100644 index 000000000..fb47c56ac --- /dev/null +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt @@ -0,0 +1,26 @@ +package ch.tutteli.atrium.domain.robstoll.lib.creating + +import ch.tutteli.atrium.api.fluent.en_GB.ExperimentalWithOptions +import ch.tutteli.atrium.api.fluent.en_GB.withRepresentation +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.creating.changers.ChangedSubjectPostStep +import ch.tutteli.atrium.domain.robstoll.lib.creating.throwable.thrown.creators.ThrowableThrownFailureHandler +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.translations.DescriptionThrowableAssertion +import kotlin.reflect.KClass + +@UseExperimental(ExperimentalWithOptions::class) +fun _cause( + expect: Expect, + expectedType: KClass +): ChangedSubjectPostStep = + ExpectImpl.feature.manualFeature(expect, DescriptionThrowableAssertion.OCCURRED_EXCEPTION_CAUSE) { cause } + .getExpectOfFeature() + .withRepresentation { it ?: RawString.create(DescriptionThrowableAssertion.NO_EXCEPTION_OCCURRED) } + .let { + ExpectImpl.changeSubject(it).reportBuilder() + .downCastTo(expectedType) + .withFailureHandler(ThrowableThrownFailureHandler(maxStackTrace = 7)) + .build() + } diff --git a/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt b/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt index e27ef97d7..d6375ea0a 100644 --- a/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt +++ b/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt @@ -1,12 +1,23 @@ package ch.tutteli.atrium.domain.robstoll.creating +import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.creating.ThrowableAssertions +import ch.tutteli.atrium.domain.creating.changers.ChangedSubjectPostStep +import ch.tutteli.atrium.domain.robstoll.lib.creating._cause import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.Translatable +import kotlin.reflect.KClass //TODO remove with 1.0.0 if there aren't any non-deprecated functions added class ThrowableAssertionsImpl : ThrowableAssertions { + override fun cause( + expect: Expect, + expectedType: KClass + ): ChangedSubjectPostStep = + _cause(expect, expectedType) + + @Suppress("OverridingDeprecatedMember", "DEPRECATION") override fun thrownBuilder( assertionVerb: Translatable, diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt index e84c8cdad..3dc81e282 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt @@ -10,6 +10,7 @@ import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionAnyAssertion import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion.CONTAINS import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion.VALUE +import ch.tutteli.atrium.translations.DescriptionThrowableAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite @@ -17,6 +18,10 @@ abstract class ThrowableAssertionsSpec( messageFeature: Feature0, message: Fun1.() -> Unit>, messageContains: Fun2>, + + causeFeature: Feature0, + cause: Feature1.() -> Unit, IllegalArgumentException>, + describePrefix: String = "[Atrium] " ) : Spek({ @@ -144,6 +149,7 @@ abstract class ThrowableAssertionsSpec( it("${messageContains.name} - does not throw if the assertion holds") { expect(throwable).messageContainsFun(1, arrayOf(2.3, 'z', "hello")) } + } it("${messageContains.name} - throws an IllegalArgumentException if an object is passed") { @@ -153,4 +159,67 @@ abstract class ThrowableAssertionsSpec( }.toThrow() } } + + describeFun(causeFeature, cause) { + val causeFunctions= unifySignatures(causeFeature, cause) + + context("Throwable.cause is not null") { + val exceptionCause = IllegalArgumentException("Hello from the Cause") + val throwable: Throwable = + RuntimeException("Outer exception message", exceptionCause) + + causeFunctions.forEach { (name, causeFun) -> + it("$name - does not throw if the assertion holds") { + expect(throwable).causeFun { toBe(exceptionCause) } + } + + it("$name - throws an AssertionError") { + expect { + expect(throwable).causeFun { messageContains("WRONG message") } + }.toThrow { + messageContains( + DescriptionThrowableAssertion.OCCURRED_EXCEPTION_CAUSE.getDefault() + ": java.lang.IllegalArgumentException", + VALUE.getDefault() + ": \"WRONG message\"" + ) + } + } + + it("$name - throws if wrong type is expected") { + val throwableWithDifferentCauseType: Throwable = + RuntimeException( + "Outer exception message", + UnsupportedOperationException("Cause exception: UNSUPPORTED OPERATION") + ) + expect { + expect(throwableWithDifferentCauseType).causeFun { messageContains("Cause exception") } + }.toThrow { + messageContains( + String.format( + DescriptionThrowableAssertion.OCCURRED_EXCEPTION_PROPERTIES.getDefault(), + UnsupportedOperationException::class.simpleName!! + ) + ) + } + } + } + + } + + context("Throwable.cause is null") { + val throwable: Throwable = RuntimeException("Outer exception message") + causeFunctions.forEach { (name, causeFun) -> + it("$name - throws an AssertionError") { + expect { + expect(throwable).causeFun { messageContains("Hello") } + }.toThrow { + messageContains( + DescriptionThrowableAssertion.NO_EXCEPTION_OCCURRED.getDefault(), + IllegalArgumentException::class.fullName + ) + } + } + } + } + + } }) From 86f9c596752b34152bb2e5897c393e7279839129 Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Wed, 4 Mar 2020 15:03:54 -0500 Subject: [PATCH 063/142] add shortcut for clause also to the new infix API --- .../api/infix/en_GB/throwableAssertions.kt | 33 +++++++++++++++++++ .../infix/en_GB/ThrowableAssertionsSpec.kt | 24 +++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt index e5e12e58b..75a2daf4d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl /** * Expects that the property [Throwable.message] of the subject of the assertion is not null, @@ -48,3 +49,35 @@ infix fun Expect.messageContains(expected: Any): Expect = */ infix fun Expect.messageContains(values: Values): Expect = message { contains(values) } + +/** + * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type), + * creates an [Expect] of the [TSub] type for it and returns it. + * + * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +@Suppress("RemoveExplicitTypeArguments") +inline fun Expect.cause(): Expect = + ExpectImpl.throwable.cause(this, TSub::class).getExpectOfFeature() + +/** + * + * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type) and + * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. + * + * Notice, in contrast to other assertion functions which expect an [assertionCreator], this function returns not + * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TSub]. + * + * @return This assertion container to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.10.0 + */ +@Suppress("RemoveExplicitTypeArguments") +inline infix fun Expect.cause( + noinline assertionCreator: Expect.() -> Unit +): Expect = + ExpectImpl.throwable.cause(this, TSub::class).addToFeature(assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt index 825c4a4cf..84589ac02 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -1,17 +1,27 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.fun2 -import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.withFeatureSuffix class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAssertionsSpec( property(Expect::message), fun1.() -> Unit>(Expect::message), - fun2(::messageContains) + fun2(::messageContains), + ("cause" to Companion::causeFeature).withFeatureSuffix(), + "cause" to Companion::cause ) { + companion object { + + @Suppress("RemoveExplicitTypeArguments") + private fun causeFeature(expect: Expect): Expect = expect.cause() + + @Suppress("RemoveExplicitTypeArguments") + private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = + expect.cause(assertionCreator) + } + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var a1: Expect = notImplemented() @@ -21,6 +31,10 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1 = a1 messageContains "a" a1 = a1 messageContains 'a' a1 = a1 messageContains Values("a", 1, 'b') + + var a2: Expect = notImplemented() + a2.cause() + a2.cause { message { }} } } From e8649a5723a3973a254ef4c56c01afdf85f0205f Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Thu, 5 Mar 2020 19:17:49 -0500 Subject: [PATCH 064/142] address comments to PR #377 --- .../api/fluent/en_GB/throwableAssertions.kt | 22 +++++++++---------- .../fluent/en_GB/ThrowableAssertionsSpec.kt | 7 +++--- .../api/infix/en_GB/throwableAssertions.kt | 20 ++++++++--------- .../infix/en_GB/ThrowableAssertionsSpec.kt | 7 +++--- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt index ef1bbb998..e1b38a175 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt @@ -43,33 +43,31 @@ fun Expect.messageContains(expected: Any, vararg otherExpecte /** - * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type), - * creates an [Expect] of the [TSub] type for it and returns it. + * Expects that the property [Throwable.cause] of the subject *is a* [TExpected] (the same type or a sub-type), + * creates an [Expect] of the [TExpected] type for it and returns it. * * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 */ -@Suppress("RemoveExplicitTypeArguments") -inline fun Expect.cause(): Expect = - ExpectImpl.throwable.cause(this, TSub::class).getExpectOfFeature() +inline fun Expect.cause(): Expect = + ExpectImpl.throwable.cause(this, TExpected::class).getExpectOfFeature() /** * - * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type) and + * Expects that the property [Throwable.cause] of the subject *is a* [TExpected] (the same type or a sub-type) and * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. * * Notice, in contrast to other assertion functions which expect an [assertionCreator], this function returns not - * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TSub]. + * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TExpected]. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 */ -@Suppress("RemoveExplicitTypeArguments") -inline fun Expect.cause( - noinline assertionCreator: Expect.() -> Unit -): Expect = - ExpectImpl.throwable.cause(this, TSub::class).addToFeature(assertionCreator) +inline fun Expect.cause( + noinline assertionCreator: Expect.() -> Unit +): Expect = + ExpectImpl.throwable.cause(this, TExpected::class).addToFeature(assertionCreator) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt index ce0e27a76..d22fa7d1c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt @@ -27,14 +27,13 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect = notImplemented() + var a1: Expect = notImplemented() a1.message a1 = a1.message {} a1 = a1.messageContains("asdf") - var a2: Expect = notImplemented() - a2.cause().message { } - a2.cause { message { }} + a1.cause().message { } + a1.cause { message { }} } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt index 75a2daf4d..e678900e8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -51,8 +51,8 @@ infix fun Expect.messageContains(values: Values): Expect message { contains(values) } /** - * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type), - * creates an [Expect] of the [TSub] type for it and returns it. + * Expects that the property [Throwable.cause] of the subject *is a* [TExpected] (the same type or a sub-type), + * creates an [Expect] of the [TExpected] type for it and returns it. * * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -60,16 +60,16 @@ infix fun Expect.messageContains(values: Values): Expect * @since 0.10.0 */ @Suppress("RemoveExplicitTypeArguments") -inline fun Expect.cause(): Expect = - ExpectImpl.throwable.cause(this, TSub::class).getExpectOfFeature() +inline fun Expect.cause(): Expect = + ExpectImpl.throwable.cause(this, TExpected::class).getExpectOfFeature() /** * - * Expects that the property [Throwable.cause] of the subject *is a* [TSub] (the same type or a sub-type) and + * Expects that the property [Throwable.cause] of the subject *is a* [TExpected] (the same type or a sub-type) and * holds all assertions the given [assertionCreator] creates for it and returns this assertion container. * * Notice, in contrast to other assertion functions which expect an [assertionCreator], this function returns not - * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TSub]. + * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TExpected]. * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -77,7 +77,7 @@ inline fun Expect.cause(): Expect Expect.cause( - noinline assertionCreator: Expect.() -> Unit -): Expect = - ExpectImpl.throwable.cause(this, TSub::class).addToFeature(assertionCreator) +inline infix fun Expect.cause( + noinline assertionCreator: Expect.() -> Unit +): Expect = + ExpectImpl.throwable.cause(this, TExpected::class).addToFeature(assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt index 84589ac02..e368a15f3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -24,7 +24,7 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect = notImplemented() + var a1: Expect = notImplemented() a1.message a1 = a1 message {} @@ -32,9 +32,8 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1 = a1 messageContains 'a' a1 = a1 messageContains Values("a", 1, 'b') - var a2: Expect = notImplemented() - a2.cause() - a2.cause { message { }} + a1.cause() + a1.cause { message { }} } } From 1510bd2629a5175ab34870d4e0b973324465cfe3 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 6 Mar 2020 07:45:56 +0100 Subject: [PATCH 065/142] cleanup and change representation in case no cause occurred --- .../fluent/en_GB/ThrowableAssertionsSpec.kt | 25 ++++++++----------- .../domain/creating/ThrowableAssertions.kt | 1 - .../lib/creating/throwableAssertions.kt | 2 +- .../creating/ThrowableAssertionsImpl.kt | 1 - .../integration/ThrowableAssertionsSpec.kt | 7 +++--- .../DescriptionThrowableAssertion.kt | 2 ++ .../DescriptionThrowableAssertion.kt | 2 ++ 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt index d22fa7d1c..3fba5a683 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt @@ -11,20 +11,10 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss property(Expect::message), fun1.() -> Unit>(Expect::message), fun2(Expect::messageContains), - ("cause" to Companion::causeFeature).withFeatureSuffix(), - "cause" to Companion::cause + ("cause" to ::causeFeature).withFeatureSuffix(), + "cause" to ::cause ) { - companion object { - - @Suppress("RemoveExplicitTypeArguments") - private fun causeFeature(expect: Expect): Expect = expect.cause() - - @Suppress("RemoveExplicitTypeArguments") - private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = - expect.cause(assertionCreator) - } - @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var a1: Expect = notImplemented() @@ -33,7 +23,14 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1 = a1.message {} a1 = a1.messageContains("asdf") - a1.cause().message { } - a1.cause { message { }} + a1.cause() + a1.cause { } } } + +@Suppress("RemoveExplicitTypeArguments") +private fun causeFeature(expect: Expect): Expect = expect.cause() + +@Suppress("RemoveExplicitTypeArguments") +private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = + expect.cause(assertionCreator) diff --git a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt index 09c6efca9..4c06e1dca 100644 --- a/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt +++ b/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/ThrowableAssertions.kt @@ -19,7 +19,6 @@ val throwableAssertions by lazy { loadSingleService(ThrowableAssertions::class) * Defines the minimum set of assertion functions and builders applicable to [Throwable], * which an implementation of the domain of Atrium has to provide. */ -//TODO remove with 1.0.0 if there aren't any non-deprecated functions added interface ThrowableAssertions { fun cause( diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt index fb47c56ac..2a32fa23e 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt @@ -17,7 +17,7 @@ fun _cause( ): ChangedSubjectPostStep = ExpectImpl.feature.manualFeature(expect, DescriptionThrowableAssertion.OCCURRED_EXCEPTION_CAUSE) { cause } .getExpectOfFeature() - .withRepresentation { it ?: RawString.create(DescriptionThrowableAssertion.NO_EXCEPTION_OCCURRED) } + .withRepresentation { it ?: RawString.create(DescriptionThrowableAssertion.NOT_CAUSED) } .let { ExpectImpl.changeSubject(it).reportBuilder() .downCastTo(expectedType) diff --git a/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt b/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt index d6375ea0a..f22ced9ec 100644 --- a/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt +++ b/domain/robstoll/atrium-domain-robstoll-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/creating/ThrowableAssertionsImpl.kt @@ -8,7 +8,6 @@ import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.Translatable import kotlin.reflect.KClass -//TODO remove with 1.0.0 if there aren't any non-deprecated functions added class ThrowableAssertionsImpl : ThrowableAssertions { override fun cause( diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt index 3dc81e282..8b9ca19dd 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt @@ -149,7 +149,6 @@ abstract class ThrowableAssertionsSpec( it("${messageContains.name} - does not throw if the assertion holds") { expect(throwable).messageContainsFun(1, arrayOf(2.3, 'z', "hello")) } - } it("${messageContains.name} - throws an IllegalArgumentException if an object is passed") { @@ -161,10 +160,10 @@ abstract class ThrowableAssertionsSpec( } describeFun(causeFeature, cause) { - val causeFunctions= unifySignatures(causeFeature, cause) + val causeFunctions = unifySignatures(causeFeature, cause) context("Throwable.cause is not null") { - val exceptionCause = IllegalArgumentException("Hello from the Cause") + val exceptionCause = IllegalArgumentException("Hello from the Clause") val throwable: Throwable = RuntimeException("Outer exception message", exceptionCause) @@ -213,7 +212,7 @@ abstract class ThrowableAssertionsSpec( expect(throwable).causeFun { messageContains("Hello") } }.toThrow { messageContains( - DescriptionThrowableAssertion.NO_EXCEPTION_OCCURRED.getDefault(), + DescriptionThrowableAssertion.NOT_CAUSED.getDefault(), IllegalArgumentException::class.fullName ) } diff --git a/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt b/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt index fb841ada8..332a4b1d6 100644 --- a/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt +++ b/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt @@ -13,6 +13,8 @@ enum class DescriptionThrowableAssertion(override val value: String) : StringBas ) IS_A("ist eine"), NO_EXCEPTION_OCCURRED("keine Exception wurde geworfen"), + NOT_CAUSED("❗❗ nicht durch eine andere Exception verursacht"), + //TODO rename to CAUSE with 1.0.0 OCCURRED_EXCEPTION_CAUSE("cause"), OCCURRED_EXCEPTION_PROPERTIES("Eigenschaften der unerwarteten %s"), OCCURRED_EXCEPTION_MESSAGE("message"), diff --git a/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt b/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt index 61d74203f..a486a8551 100644 --- a/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt +++ b/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt @@ -13,6 +13,8 @@ enum class DescriptionThrowableAssertion(override val value: String) : StringBas ) IS_A("is a"), NO_EXCEPTION_OCCURRED("no exception occurred"), + NOT_CAUSED("❗❗ not caused by another exception"), + //TODO rename to CAUSE with 1.0.0 OCCURRED_EXCEPTION_CAUSE("cause"), OCCURRED_EXCEPTION_PROPERTIES("Properties of the unexpected %s"), OCCURRED_EXCEPTION_MESSAGE("message"), From 133148daa729ad67225612e89a9d76536a5fc17c Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 6 Mar 2020 08:20:11 +0100 Subject: [PATCH 066/142] cleanup ThrowableAssertionsSpec in infix API (use WithAsciiReporter) --- .../infix/en_GB/ThrowableAssertionsSpec.kt | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt index e368a15f3..dafb037b7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -2,25 +2,18 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.specs.withFeatureSuffix class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAssertionsSpec( property(Expect::message), fun1.() -> Unit>(Expect::message), fun2(::messageContains), - ("cause" to Companion::causeFeature).withFeatureSuffix(), - "cause" to Companion::cause + ("cause" to ::causeFeature).withFeatureSuffix(), + "cause" to ::cause ) { - companion object { - - @Suppress("RemoveExplicitTypeArguments") - private fun causeFeature(expect: Expect): Expect = expect.cause() - - @Suppress("RemoveExplicitTypeArguments") - private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = - expect.cause(assertionCreator) - } + companion object : WithAsciiReporter() @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -33,10 +26,18 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1 = a1 messageContains Values("a", 1, 'b') a1.cause() - a1.cause { message { }} + a1.cause { message { } } } } private fun messageContains(expect: Expect, expected: Any, vararg otherExpected: Any): Expect = if (otherExpected.isEmpty()) expect messageContains expected else expect messageContains Values(expected, *otherExpected) + +@Suppress("RemoveExplicitTypeArguments") +private fun causeFeature(expect: Expect): Expect = + expect.cause() + +@Suppress("RemoveExplicitTypeArguments") +private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = + expect.cause(assertionCreator) From a9ccdfcc52031cf318d01290993564f136d53900 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 6 Mar 2020 08:20:27 +0100 Subject: [PATCH 067/142] update npm dependencies --- gradle/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/package-lock.json b/gradle/package-lock.json index 92f9cd1db..d50014913 100644 --- a/gradle/package-lock.json +++ b/gradle/package-lock.json @@ -122,9 +122,9 @@ }, "dependencies": { "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { "fs.realpath": "^1.0.0", From 5ed2648aba03e12cb3eb4a310f3b3916c4ed7bb5 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 6 Mar 2020 08:33:59 +0100 Subject: [PATCH 068/142] deprecate DescriptionThrowableAssertion.NO_EXCEPTION_OCCURRED --- .../atrium/translations/DescriptionThrowableAssertion.kt | 3 +++ .../atrium/translations/DescriptionThrowableAssertion.kt | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt b/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt index 332a4b1d6..ad22ed228 100644 --- a/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt +++ b/translations/de_CH/atrium-translations-de_CH-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt @@ -12,6 +12,9 @@ enum class DescriptionThrowableAssertion(override val value: String) : StringBas ReplaceWith("ch.tutteli.atrium.translations.DescriptionAnyAssertion.IS_A") ) IS_A("ist eine"), + @Deprecated("Will be removed with 1.0.0", + ReplaceWith("ch.tutteli.atrium.translations.DescriptionFunLikeAssertion.NO_EXCEPTION_OCCURRED") + ) NO_EXCEPTION_OCCURRED("keine Exception wurde geworfen"), NOT_CAUSED("❗❗ nicht durch eine andere Exception verursacht"), //TODO rename to CAUSE with 1.0.0 diff --git a/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt b/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt index a486a8551..8fd76dc79 100644 --- a/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt +++ b/translations/en_GB/atrium-translations-en_GB-common/src/main/kotlin/ch/tutteli/atrium/translations/DescriptionThrowableAssertion.kt @@ -12,6 +12,10 @@ enum class DescriptionThrowableAssertion(override val value: String) : StringBas ReplaceWith("ch.tutteli.atrium.translations.DescriptionAnyAssertion.IS_A") ) IS_A("is a"), + @Deprecated( + "Will be removed with 1.0.0", + ReplaceWith("ch.tutteli.atrium.translations.DescriptionFunLikeAssertion.NO_EXCEPTION_OCCURRED") + ) NO_EXCEPTION_OCCURRED("no exception occurred"), NOT_CAUSED("❗❗ not caused by another exception"), //TODO rename to CAUSE with 1.0.0 From 7ddb2e973c33abfa5175a01454999b321e77072c Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 10 Mar 2020 16:56:14 +0100 Subject: [PATCH 069/142] add component diagram by tfesenko --- .github/CONTRIBUTING.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9577075ee..89b3d0185 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -96,7 +96,16 @@ Please write a comment such as `I am working on this` in the issue, this way we can assign the task to you (so that others know there is already someone working on the issue) and it gives us the chance to have a look at the description again and revise if necessary. +*Architecture* + +The following diagram illustrates the current architecture of Atrium and what it meant to add a shortcut for `Throwable.cause`. Many times, especially in [good first issues](https://github.com/robstoll/atrium/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) we refer to this names and they are also reflected in the directory structure of the project. + +![Component diagram](https://raw.githubusercontent.com/robstoll/atrium/gh-pages/components.png?sanitize=true6) + + +*Git* + Dealing with Git for the first time? Here are some recommendations for how to set up Git when working on an issue: - create a new branch for the issue using `git checkout -b ` (preferrably, the branch name should be descriptive of the issue or the change being made, e.g `#108-path-exists`.) Working From 037d336d7978fb0ec79ccbf15ccc350473fb2817 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 10 Mar 2020 21:02:06 +0100 Subject: [PATCH 070/142] mention that cc-infix specs don't need to be migrated to spek2 --- .../ch/tutteli/atrium/api/cc/infix/en_GB/AnyAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/ArrayAsIterableAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/BigDecimalAssertionsSpec.kt | 1 + .../tutteli/atrium/api/cc/infix/en_GB/BooleanAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/CharSequenceAssertionsSpec.kt | 1 + .../cc/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt | 1 + .../cc/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt | 1 + .../infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt | 1 + .../cc/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt | 1 + .../api/cc/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt | 1 + .../infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt | 1 + .../cc/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/CharSequenceContainsSpecBase.kt | 1 + .../atrium/api/cc/infix/en_GB/CollectionAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/CollectionFeatureAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/ComparableAssertionsSpec.kt | 1 + .../api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt | 1 + .../FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec.kt | 1 + .../api/cc/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/IterableAllAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/IterableAnyAssertionsSpec.kt | 1 + .../IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt | 1 + .../IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt | 1 + .../IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt | 1 + .../IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt | 1 + .../IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt | 1 + .../IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt | 1 + .../en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt | 1 + .../en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt | 1 + .../en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt | 1 + .../IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt | 1 + .../IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt | 1 + .../en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt | 1 + .../cc/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt | 1 + .../cc/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/IterableContainsSpecBase.kt | 1 + .../atrium/api/cc/infix/en_GB/IterableNoneAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/ListFeatureAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/MapAsEntriesAssertionsSpec.kt | 1 + .../ch/tutteli/atrium/api/cc/infix/en_GB/MapAssertionsSpec.kt | 1 + .../tutteli/atrium/api/cc/infix/en_GB/MapEntryAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/MapEntryFeatureAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/MapFeatureAssertionsSpec.kt | 1 + .../atrium/api/cc/infix/en_GB/PairFeatureAssertionsSpec.kt | 1 + .../tutteli/atrium/api/cc/infix/en_GB/ThrowableAssertionsSpec.kt | 1 + .../api/cc/infix/en_GB/TypeTransformationAssertionsSpec.kt | 1 + bundles/atrium-cc-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt | 1 + .../atrium-cc-infix-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt | 1 + 48 files changed, 48 insertions(+) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/AnyAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/AnyAssertionsSpec.kt index 7f99a86a3..cb4b15dab 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/AnyAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/AnyAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.creating.AssertionPlantNullable import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class AnyAssertionsSpec : ch.tutteli.atrium.spec.integration.AnyAssertionsSpec( AssertionVerbFactory, AnyAssertionsSpecFunFactory(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ArrayAsIterableAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ArrayAsIterableAssertionsSpec.kt index 1534eb02f..43a55beaf 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ArrayAsIterableAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ArrayAsIterableAssertionsSpec.kt @@ -4,6 +4,7 @@ package ch.tutteli.atrium.api.cc.infix.en_GB import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class ArrayAsIterableAssertionsSpec : ch.tutteli.atrium.spec.integration.ArrayAsIterableAssertionsSpec( AssertionVerbFactory, "asIterable", diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BigDecimalAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BigDecimalAssertionsSpec.kt index 1b6f4ba2f..71857e441 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BigDecimalAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BigDecimalAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.creating.Assert import java.math.BigDecimal import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class BigDecimalAssertionsSpec : ch.tutteli.atrium.spec.integration.BigDecimalAssertionsSpec( AssertionVerbFactory, toBePair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BooleanAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BooleanAssertionsSpec.kt index fd941b10d..83f4b0812 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BooleanAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/BooleanAssertionsSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.creating.Assert import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class BooleanAssertionsSpec : ch.tutteli.atrium.spec.integration.BooleanAssertionsSpec( AssertionVerbFactory, toBeName() to Companion::toBeTrue, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceAssertionsSpec.kt index 078b211d1..07c0d081c 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceAssertionsSpec.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.reporting.translating.Translatable import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceAssertionsSpec( AssertionVerbFactory, getContainsDefaultTranslationOfPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index ffb603708..8826501e4 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.case import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsAtLeastAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsAtLeastAssertionsSpec( AssertionVerbFactory, getAtLeastTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt index ac77043f5..dd1a60e43 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.case import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsAtMostAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsAtMostAssertionsSpec( AssertionVerbFactory, getAtMostTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index ba49143d9..fc70e3130 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.creating.Assert import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsContainsNotAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsContainsNotAssertionsSpec( AssertionVerbFactory, getContainsPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt index d8d3980d9..805e10e03 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.case import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsExactlyAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsExactlyAssertionsSpec( AssertionVerbFactory, getExactlyTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt index c925b24ec..6fceb4ff4 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.case import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsNotAssertionsSpec( AssertionVerbFactory, getContainsNotTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt index b08fd2514..ee01944e0 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.case import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsNotOrAtMostAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsNotOrAtMostAssertionsSpec( AssertionVerbFactory, getNotOrAtMostTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt index 31de2d036..bb0e73b0c 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.case import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CharSequenceContainsRegexAssertionsSpec : ch.tutteli.atrium.spec.integration.CharSequenceContainsRegexAssertionsSpec( AssertionVerbFactory, getNameContainsRegex(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsSpecBase.kt index dbcf98e71..8dcb75f8e 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -9,6 +9,7 @@ import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceConta import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 abstract class CharSequenceContainsSpecBase { private val containsNotFun: KFunction2, Any, Assert> = Assert::containsNot protected val toContain = "${Assert::to.name} ${contain::class.simpleName}" diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionAssertionsSpec.kt index 42b56250f..5dd41321e 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionAssertionsSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.Empty import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CollectionAssertionsSpec : ch.tutteli.atrium.spec.integration.CollectionAssertionsSpec( AssertionVerbFactory, Assert>::hasSize.name to Companion::hasSize, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionFeatureAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionFeatureAssertionsSpec.kt index 2d3d9c887..c7c8d6ac3 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionFeatureAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/CollectionFeatureAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import kotlin.reflect.KProperty1 import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class CollectionFeatureAssertionsSpec : ch.tutteli.atrium.spec.integration.CollectionFeatureAssertionsSpec( AssertionVerbFactory, sizeVal.name to sizeVal, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ComparableAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ComparableAssertionsSpec.kt index e933b627d..966c786f4 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ComparableAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ComparableAssertionsSpec.kt @@ -4,6 +4,7 @@ package ch.tutteli.atrium.api.cc.infix.en_GB import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class ComparableAssertionsSpec : ch.tutteli.atrium.spec.integration.ComparableAssertionsSpec( AssertionVerbFactory, Assert::isLessThan.name to Companion::isLessThan, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt index ec182dde1..d2cfff8e5 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.spec.integration.TestData internal typealias F = Assert.() -> Unit +//TODO remove with 1.0.0, no need to migrate to Spek 2 class FeatureAssertionsBoundedReferenceSpec : ch.tutteli.atrium.spec.integration.FeatureAssertionsSpec( AssertionVerbFactory, propertyImmediate, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec.kt index e83cb4d34..cac355b0b 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.creating.CollectingAssertionPlant import ch.tutteli.atrium.spec.integration.TestData import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec : ch.tutteli.atrium.spec.integration.FeatureAssertionsBoundedReferenceWhenCollectingPlantSpec( AssertionVerbFactory, propertyImmediate, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt index bf4080297..b377dbcb1 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.domain.builders.utils.subAssert import ch.tutteli.atrium.spec.integration.TestData import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class FeatureAssertionsClassReferenceSpec : ch.tutteli.atrium.spec.integration.FeatureAssertionsSpec( AssertionVerbFactory, propertyImmediate, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAllAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAllAssertionsSpec.kt index 727c95cdd..6105c8d99 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAllAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAllAssertionsSpec.kt @@ -7,6 +7,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableAllAssertionsSpec: Spek({ include(PredicateSpec) }) { diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAnyAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAnyAssertionsSpec.kt index 77f27ce0c..79d76e87a 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAnyAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableAnyAssertionsSpec.kt @@ -10,6 +10,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableAnyAssertionsSpec : Spek({ include(PredicateSpec) include(BuilderSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt index c32253cfa..94f7ad996 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt @@ -9,6 +9,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ include(BuilderSpec) include(ShortcutSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt index 715b089f7..870d88b0e 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt @@ -9,6 +9,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ include(BuilderSpec) include(ShortcutSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt index 61f99119c..ec09203d7 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.order import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInAnyOrderAtLeastValuesAssertionSpec( AssertionVerbFactory, getAtLeastTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt index 9aa4eeccd..7005a5c6e 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.order import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderAtMostValuesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInAnyOrderAtMostValuesAssertionSpec( AssertionVerbFactory, getAtMostTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt index 52c072596..1ec3531a6 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.order import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderExactlyValuesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInAnyOrderExactlyValuesAssertionsSpec( AssertionVerbFactory, getExactlyTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt index 0be3539b0..92ebdf998 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.order import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec( AssertionVerbFactory, getNotOrAtMostTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt index 0cc827383..0e8dc9f1f 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.only import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.order import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInAnyOrderOnlyEntriesAssertionsSpec( AssertionVerbFactory, getContainsPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt index 830206ccc..8513624d0 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.only import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.order import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInAnyOrderOnlyValuesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInAnyOrderOnlyValuesAssertionsSpec( AssertionVerbFactory, getContainsPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt index f0d72079f..c118e0ddd 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt @@ -10,6 +10,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ include(BuilderSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt index fb8c8159e..49eacecf0 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.domain.builders.utils.Group import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec( AssertionVerbFactory, getContainsPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt index 496e162b2..b3ccba247 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.domain.builders.utils.Group import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsInOrderOnlyGroupedValuesAssertionsSpec( AssertionVerbFactory, getContainsPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt index ad894571b..b98d5ecad 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt @@ -10,6 +10,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ include(BuilderSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt index 3cb4fd1f5..4029386f5 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.api.cc.infix.en_GB.keywords.contain import ch.tutteli.atrium.creating.Assert +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsNotEntriesAssertionsSpec : ch.tutteli.atrium.spec.integration.IterableContainsNotEntriesAssertionsSpec( AssertionVerbFactory, getContainsNotPair(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt index 2afdfecb7..520e36f6a 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt @@ -8,6 +8,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableContainsNotValuesAssertionsSpec : Spek({ include(BuilderSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsSpecBase.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsSpecBase.kt index 3e1727919..4f72e6d82 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsSpecBase.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableContainsSpecBase.kt @@ -15,6 +15,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.* import ch.tutteli.atrium.verbs.internal.assert import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 abstract class IterableContainsSpecBase { protected val Values = Values::class.simpleName private val Entries = Entries::class.simpleName diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableNoneAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableNoneAssertionsSpec.kt index bcecee904..4026db58e 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableNoneAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/IterableNoneAssertionsSpec.kt @@ -8,6 +8,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class IterableNoneAssertionsSpec : Spek({ include(PredicateSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ListFeatureAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ListFeatureAssertionsSpec.kt index fff8fe06b..f596156e5 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ListFeatureAssertionsSpec.kt @@ -12,6 +12,7 @@ import org.jetbrains.spek.api.Spek import org.jetbrains.spek.api.include import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class ListFeatureAssertionsSpec : Spek({ include(AtriumFeatureAssertionsSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAsEntriesAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAsEntriesAssertionsSpec.kt index 3184d4a98..8c343152c 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAsEntriesAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAsEntriesAssertionsSpec.kt @@ -4,6 +4,7 @@ package ch.tutteli.atrium.api.cc.infix.en_GB import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class MapAsEntriesAssertionsSpec : ch.tutteli.atrium.spec.integration.MapAsEntriesAssertionsSpec( AssertionVerbFactory, "asEntries", diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAssertionsSpec.kt index 5c9a0aca2..a398b227a 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapAssertionsSpec.kt @@ -8,6 +8,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.verbs.internal.assert import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class MapAssertionsSpec : ch.tutteli.atrium.spec.integration.MapAssertionsSpec( AssertionVerbFactory, containsFun.name to Companion::contains, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryAssertionsSpec.kt index 5f9a83a6c..9f10fbb06 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryAssertionsSpec.kt @@ -4,6 +4,7 @@ package ch.tutteli.atrium.api.cc.infix.en_GB import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory +//TODO remove with 1.0.0, no need to migrate to Spek 2 class MapEntryAssertionsSpec : ch.tutteli.atrium.spec.integration.MapEntryAssertionsSpec( AssertionVerbFactory, isKeyValueFun.name to Companion::isKeyValue diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryFeatureAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryFeatureAssertionsSpec.kt index 97bca9024..2c753ee99 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryFeatureAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapEntryFeatureAssertionsSpec.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import kotlin.reflect.KFunction2 import kotlin.reflect.KProperty1 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class MapEntryFeatureAssertionsSpec : ch.tutteli.atrium.spec.integration.MapEntryFeatureAssertionsSpec( AssertionVerbFactory, keyVal.name to keyVal, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapFeatureAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapFeatureAssertionsSpec.kt index 3b5476710..50570d239 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapFeatureAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/MapFeatureAssertionsSpec.kt @@ -15,6 +15,7 @@ import kotlin.reflect.KProperty1 import ch.tutteli.atrium.verbs.internal.assert import java.lang.IllegalArgumentException +//TODO remove with 1.0.0, no need to migrate to Spek 2 class MapFeatureAssertionsSpec : Spek({ include(AtriumMapFeatureAssertionsSpec) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/PairFeatureAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/PairFeatureAssertionsSpec.kt index 31ef93cbb..77c316d84 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/PairFeatureAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/PairFeatureAssertionsSpec.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import kotlin.reflect.KFunction2 import kotlin.reflect.KProperty1 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class PairFeatureAssertionsSpec : ch.tutteli.atrium.spec.integration.PairFeatureAssertionsSpec( AssertionVerbFactory, firstVal.name to firstVal, diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ThrowableAssertionsSpec.kt index c147004b0..cc726db40 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/ThrowableAssertionsSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.verbs.internal.AssertionVerbFactory import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.domain.creating.throwable.thrown.ThrowableThrown +//TODO remove with 1.0.0, no need to migrate to Spek 2 class ThrowableAssertionsSpec : ch.tutteli.atrium.spec.integration.ThrowableAssertionsSpec( AssertionVerbFactory, getToThrowTriple(), diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/TypeTransformationAssertionsSpec.kt b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/TypeTransformationAssertionsSpec.kt index a85ac0631..0ebb8eab3 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/TypeTransformationAssertionsSpec.kt +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/cc/infix/en_GB/TypeTransformationAssertionsSpec.kt @@ -8,6 +8,7 @@ import kotlin.reflect.KFunction import kotlin.reflect.KFunction2 +//TODO remove with 1.0.0, no need to migrate to Spek 2 class TypeTransformationAssertionsSpec : ch.tutteli.atrium.spec.integration.TypeTransformationAssertionsSpec( AssertionVerbFactory, getNotToBeNullPair(), diff --git a/bundles/atrium-cc-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt b/bundles/atrium-cc-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt index 0433e16ff..2dd4d0b07 100644 --- a/bundles/atrium-cc-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt +++ b/bundles/atrium-cc-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt @@ -9,6 +9,7 @@ import ch.tutteli.atrium.translations.DescriptionBasic import ch.tutteli.atrium.verbs.assertThat import org.jetbrains.spek.api.Spek +//TODO remove with 1.0.0, no need to migrate to Spek 2 object SmokeSpec : Spek({ test("see if `toBe` can be used") { @Suppress("DEPRECATION") diff --git a/bundles/atrium-cc-infix-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt b/bundles/atrium-cc-infix-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt index 75960dcfe..cf161f31a 100644 --- a/bundles/atrium-cc-infix-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt +++ b/bundles/atrium-cc-infix-en_UK-robstoll/src/test/kotlin/SmokeSpec.kt @@ -9,6 +9,7 @@ import ch.tutteli.atrium.translations.DescriptionBasic import ch.tutteli.atrium.verbs.expect import org.jetbrains.spek.api.Spek +//TODO remove with 1.0.0, no need to migrate to Spek 2 object SmokeSpec : Spek({ test("see if `toBe` can be used") { @Suppress("DEPRECATION") From 2404156e735c1e311a4cfca63bce72ca3f41d20a Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 10 Mar 2020 22:02:55 +0100 Subject: [PATCH 071/142] add missing specs for feature functions for the new infix API ...and fix some issues: - add the missing function for FeatureWithCreator for 5 params - use method call formatter for KFunctionX --- .../api/infix/en_GB/featureAssertions.kt | 31 +++-- ...sertionsBoundedReferenceAlternativeSpec.kt | 127 +++++++++++++++++ .../FeatureAssertionsBoundedReferenceSpec.kt | 130 ++++++++++++++++++ .../FeatureAssertionsClassReferenceSpec.kt | 126 +++++++++++++++++ .../en_GB/FeatureAssertionsManualSpec.kt | 118 ++++++++++++++++ .../api/infix/en_GB/FeatureWorstCaseTest.kt | 27 ++++ 6 files changed, 548 insertions(+), 11 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureWorstCaseTest.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt index 4b3c61686..3488d9004 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.api.infix.en_GB.creating.feature.Feature import ch.tutteli.atrium.api.infix.en_GB.creating.feature.FeatureWithCreator import ch.tutteli.atrium.api.infix.en_GB.creating.feature.MetaFeatureOptionWithCreator import ch.tutteli.atrium.assertions.AssertionGroup +import ch.tutteli.atrium.core.coreFactory import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.creating.FeatureExpect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -159,31 +160,31 @@ fun MetaFeatureOption.f(description: String, provider: R): MetaFeature * Helper function to create a [Feature] based on a [KFunction2] + arguments. */ fun of(f: KFunction2, a1: A1): Feature = - Feature(f.name) { f.invoke(it, a1) } + Feature(formatMethodCall(f, a1)) { f.invoke(it, a1) } /** * Helper function to create a [Feature] based on a [KFunction3] + arguments. */ fun of(f: KFunction3, a1: A1, a2: A2): Feature = - Feature(f.name) { f.invoke(it, a1, a2) } + Feature(formatMethodCall(f, a1, a2)) { f.invoke(it, a1, a2) } /** * Helper function to create a [Feature] based on a [KFunction4] + arguments. */ fun of(f: KFunction4, a1: A1, a2: A2, a3: A3): Feature = - Feature(f.name) { f.invoke(it, a1, a2, a3) } + Feature(formatMethodCall(f, a1, a2, a3)) { f.invoke(it, a1, a2, a3) } /** * Helper function to create a [Feature] based on a [KFunction5] + arguments. */ fun of(f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4): Feature = - Feature(f.name) { f.invoke(it, a1, a2, a3, a4) } + Feature(formatMethodCall(f, a1, a2, a3, a4)) { f.invoke(it, a1, a2, a3, a4) } /** - * Helper function to create a [Feature] based on a [KFunction5] + arguments. + * Helper function to create a [Feature] based on a [KFunction6] + arguments. */ fun of(f: KFunction6, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): Feature = - Feature(f.name) { f.invoke(it, a1, a2, a3, a4, a5) } + Feature(formatMethodCall(f, a1, a2, a3, a4, a5)) { f.invoke(it, a1, a2, a3, a4, a5) } /** * Helper function to create a [FeatureWithCreator] based on a [KProperty1] + [assertionCreator]. @@ -195,33 +196,41 @@ fun of(property: KProperty1, assertionCreator: Expect.() -> U * Helper function to create a [FeatureWithCreator] based on a [KFunction1] + [assertionCreator]. */ fun of(f: KFunction1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = - FeatureWithCreator(f.name, { f.invoke(it) }, assertionCreator) + FeatureWithCreator(formatMethodCall(f), { f.invoke(it) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction2] + arguments + [assertionCreator]. */ fun of(f: KFunction2, a1: A1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = - FeatureWithCreator(f.name, { f.invoke(it, a1) }, assertionCreator) + FeatureWithCreator(formatMethodCall(f, a1), { f.invoke(it, a1) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction3] + arguments + [assertionCreator]. */ fun of(f: KFunction3, a1: A1, a2: A2, assertionCreator: Expect.() -> Unit): FeatureWithCreator = - FeatureWithCreator(f.name, { f.invoke(it, a1, a2) }, assertionCreator) + FeatureWithCreator(formatMethodCall(f, a1, a2), { f.invoke(it, a1, a2) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction4] + arguments + [assertionCreator]. */ fun of(f: KFunction4, a1: A1, a2: A2, a3: A3, assertionCreator: Expect.() -> Unit): FeatureWithCreator = - FeatureWithCreator(f.name, { f.invoke(it, a1, a2, a3) }, assertionCreator) + FeatureWithCreator(formatMethodCall(f, a1, a2, a3), { f.invoke(it, a1, a2, a3) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction5] + arguments + [assertionCreator]. */ fun of(f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4, assertionCreator: Expect.() -> Unit): FeatureWithCreator = - FeatureWithCreator(f.name, { f.invoke(it, a1, a2, a3, a4) }, assertionCreator) + FeatureWithCreator(formatMethodCall(f, a1, a2, a3, a4), { f.invoke(it, a1, a2, a3, a4) }, assertionCreator) + +/** + * Helper function to create a [FeatureWithCreator] based on a [KFunction6] + arguments + [assertionCreator]. + */ +fun of(f: KFunction6, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, assertionCreator: Expect.() -> Unit): FeatureWithCreator = + FeatureWithCreator(formatMethodCall(f, a1, a2, a3, a4, a5), { f.invoke(it, a1, a2, a3, a4, a5) }, assertionCreator) //@formatter:on +private fun formatMethodCall(k: KCallable<*>, vararg args: Any?) = + coreFactory.newMethodCallFormatter().formatCall(k.name, args) /** * Helper function to create a [MetaFeatureOptionWithCreator] based on a lambda with diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt new file mode 100644 index 000000000..5019cbc67 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt @@ -0,0 +1,127 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.workaround.it +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.integration.TestData +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + +class FeatureAssertionsBoundedReferenceAlternativeSpec : ch.tutteli.atrium.specs.integration.FeatureAssertionsSpec( + propertyImmediate, + propertyLazy, + f0Immediate, + f1Immediate, + f2Immediate, + f3Immediate, + f4Immediate, + f5Immediate, + f0Lazy, + f1Lazy, + f2Lazy, + f3Lazy, + f4Lazy, + f5Lazy, + + propertyNullableDoesNotHold, + f0NullableDoesNotHold, + f1NullableDoesNotHold, + f2NullableDoesNotHold, + f3NullableDoesNotHold, + f4NullableDoesNotHold, + f5NullableDoesNotHold, + + propertyNullableHolds, + f0NullableHolds, + f1NullableHolds, + f2NullableHolds, + f3NullableHolds, + f4NullableHolds, + f5NullableHolds, + + propertyLazyWithNestedImmediate, + propertyLazyWithNestedLazy, + + propertyEmptyAssertionCreator, + f0EmptyAssertionCreator, + f1EmptyAssertionCreator, + f2EmptyAssertionCreator, + f3EmptyAssertionCreator, + f4EmptyAssertionCreator, + f5EmptyAssertionCreator, + + isAbleToEvaluateDescription = false +) { + + //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again + companion object : WithAsciiReporter() { + //@formatter:off + val propertyImmediate: F = { o feature { p(it::nonNullValue) } contains "hello" } + val propertyLazy: F = { o feature of({ p(it::nonNullValue) }) { o contains "hello" } } + val f0Immediate: F = { o feature { f0(it::return0) } contains "hello" } + val f1Immediate: F = { o feature { f1(it::return1, "a") } contains "hello" } + val f2Immediate: F = { o feature { f2(it::return2, "a", 1) } contains "hello" } + val f3Immediate: F = { o feature { f3(it::return3, "a", 1, true) } contains "hello" } + val f4Immediate: F = { o feature { f4(it::return4, "a", 1, true, 1.2) } contains "hello" } + val f5Immediate: F = { o feature { f5(it::return5, "a", 1, true, 1.2, 'b') } contains "hello" } + val f0Lazy: F = { o feature of({ f0(it::return0) }) { o contains "hello" } } + val f1Lazy: F = { o feature of({ f1(it::return1, "a") }) { o contains "hello" } } + val f2Lazy: F = { o feature of({ f2(it::return2, "a", 1) }) { o contains "hello" } } + val f3Lazy: F = { o feature of({ f3(it::return3, "a", 1, true) }) { o contains "hello" } } + val f4Lazy: F = { o feature of({ f4(it::return4, "a", 1, true, 1.2) }) { o contains "hello" } } + val f5Lazy: F = { o feature of({ f5(it::return5, "a", 1, true, 1.2, 'b') }) { o contains "hello" } } + + val propertyNullableDoesNotHold: F = { o feature { p(it::nullableValue) } toBe null } + val f0NullableDoesNotHold: F = { o feature { f0(it::returnNullable0) } toBe null } + val f1NullableDoesNotHold: F = { o feature { f1(it::returnNullable1, "a") } toBe null } + val f2NullableDoesNotHold: F = { o feature { f2(it::returnNullable2, "a", 1) } toBe null } + val f3NullableDoesNotHold: F = { o feature { f3(it::returnNullable3, "a", 1, true) } toBe null } + val f4NullableDoesNotHold: F = { o feature { f4(it::returnNullable4, "a", 1, true, 1.2) } toBe null } + val f5NullableDoesNotHold: F = { o feature { f5(it::returnNullable5, "a", 1, true, 1.2, 'b') } toBe null } + + val propertyNullableHolds: F = { o feature { p(it::nullableValue) } notToBeNull { o toBe 1 } } + val f0NullableHolds: F = { o feature { f0(it::returnNullable0) } notToBeNull { o toBe 1 } } + val f1NullableHolds: F = { o feature { f1(it::returnNullable1, "a") } notToBeNull { o toBe 1 } } + val f2NullableHolds: F = { o feature { f2(it::returnNullable2, "a", 1) } notToBeNull { o toBe 1 } } + val f3NullableHolds: F = { o feature { f3(it::returnNullable3, "a", 1, true) } notToBeNull { o toBe 1 } } + val f4NullableHolds: F = { o feature { f4(it::returnNullable4, "a", 1, true, 1.2) } notToBeNull { o toBe 1 } } + val f5NullableHolds: F = { o feature { f5(it::returnNullable5, "a", 1, true, 1.2, 'b') } notToBeNull { o toBe 1 } } + //@formatter:on + + val propertyLazyWithNestedImmediate: F = { + o feature { p(it::nonNullValue) } it { + o feature { p(it::length) } toBe 12 + } + } + val propertyLazyWithNestedLazy: F = { + o feature { p(it::nonNullValue) } it { + o feature { p(it::length) } it { o toBe 12 } + } + } + + val propertyEmptyAssertionCreator: F = { o feature of({ p(it::nonNullValue) }) {} } + val f0EmptyAssertionCreator: F = { o feature of({ f0(it::return0) }) {} } + val f1EmptyAssertionCreator: F = { o feature of({ f1(it::return1, "a") }) {} } + val f2EmptyAssertionCreator: F = { o feature of({ f2(it::return2, "a", 1) }) {} } + val f3EmptyAssertionCreator: F = { o feature of({ f3(it::return3, "a", 1, true) }) {} } + val f4EmptyAssertionCreator: F = { o feature of({ f4(it::return4, "a", 1, true, 1.2) }) {} } + val f5EmptyAssertionCreator: F = + { o feature (of({ f5(it::return5, "a", 1, true, 1.2, 'b') }) {}) } + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect> = notImplemented() + val a1b: Expect> = notImplemented() + + val star: Expect> = notImplemented() + + a1 feature { p(it::size) } + a1 feature { p(it::size) } it {} + + a1b feature { p(it::size) } + a1b feature { p(it::size) } it {} + + star feature { p(it::size) } + star feature { p(it::size) } it {} + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt new file mode 100644 index 000000000..9fa1463b9 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt @@ -0,0 +1,130 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.workaround.it +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.integration.TestData +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + +internal typealias F = Expect.() -> Unit + +class FeatureAssertionsBoundedReferenceSpec : ch.tutteli.atrium.specs.integration.FeatureAssertionsSpec( + propertyImmediate, + propertyLazy, + f0Immediate, + f1Immediate, + f2Immediate, + f3Immediate, + f4Immediate, + f5Immediate, + f0Lazy, + f1Lazy, + f2Lazy, + f3Lazy, + f4Lazy, + f5Lazy, + + propertyNullableDoesNotHold, + f0NullableDoesNotHold, + f1NullableDoesNotHold, + f2NullableDoesNotHold, + f3NullableDoesNotHold, + f4NullableDoesNotHold, + f5NullableDoesNotHold, + + propertyNullableHolds, + f0NullableHolds, + f1NullableHolds, + f2NullableHolds, + f3NullableHolds, + f4NullableHolds, + f5NullableHolds, + + propertyLazyWithNestedImmediate, + propertyLazyWithNestedLazy, + + propertyEmptyAssertionCreator, + f0EmptyAssertionCreator, + f1EmptyAssertionCreator, + f2EmptyAssertionCreator, + f3EmptyAssertionCreator, + f4EmptyAssertionCreator, + f5EmptyAssertionCreator, + + isAbleToEvaluateDescription = false +) { + + //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again + companion object : WithAsciiReporter() { + //@formatter:off + val propertyImmediate: F = { o feature { f(it::nonNullValue) } contains "hello" } + val propertyLazy: F = { o feature of({ f(it::nonNullValue) }) { o contains "hello" } } + val f0Immediate: F = { o feature { f(it::return0) } contains "hello" } + val f1Immediate: F = { o feature { f(it::return1, "a") } contains "hello" } + val f2Immediate: F = { o feature { f(it::return2, "a", 1) } contains "hello" } + val f3Immediate: F = { o feature { f(it::return3, "a", 1, true) } contains "hello" } + val f4Immediate: F = { o feature { f(it::return4, "a", 1, true, 1.2) } contains "hello" } + val f5Immediate: F = { o feature { f(it::return5, "a", 1, true, 1.2, 'b') } contains "hello" } + val f0Lazy: F = { o feature of({ f(it::return0) }) { o contains "hello" } } + val f1Lazy: F = { o feature of({ f(it::return1, "a") }) { o contains "hello" } } + val f2Lazy: F = { o feature of({ f(it::return2, "a", 1) }) { o contains "hello" } } + val f3Lazy: F = { o feature of({ f(it::return3, "a", 1, true) }) { o contains "hello" } } + val f4Lazy: F = { o feature of({ f(it::return4, "a", 1, true, 1.2) }) { o contains "hello" } } + val f5Lazy: F = { o feature of({ f(it::return5, "a", 1, true, 1.2, 'b') }) { o contains "hello" } } + + val propertyNullableDoesNotHold: F = { o feature { f(it::nullableValue) } toBe null } + val f0NullableDoesNotHold: F = { o feature { f(it::returnNullable0) } toBe null } + val f1NullableDoesNotHold: F = { o feature { f(it::returnNullable1, "a") } toBe null } + val f2NullableDoesNotHold: F = { o feature { f(it::returnNullable2, "a", 1) } toBe null } + val f3NullableDoesNotHold: F = { o feature { f(it::returnNullable3, "a", 1, true) } toBe null } + val f4NullableDoesNotHold: F = { o feature { f(it::returnNullable4, "a", 1, true, 1.2) } toBe null } + val f5NullableDoesNotHold: F = { o feature { f(it::returnNullable5, "a", 1, true, 1.2, 'b') } toBe null } + + val propertyNullableHolds: F = { o feature { f(it::nullableValue) } notToBeNull { o toBe 1 } } + val f0NullableHolds: F = { o feature { f(it::returnNullable0) } notToBeNull { o toBe 1 } } + val f1NullableHolds: F = { o feature { f(it::returnNullable1, "a") } notToBeNull { o toBe 1 } } + val f2NullableHolds: F = { o feature { f(it::returnNullable2, "a", 1) } notToBeNull { o toBe 1 } } + val f3NullableHolds: F = { o feature { f(it::returnNullable3, "a", 1, true) } notToBeNull { o toBe 1 } } + val f4NullableHolds: F = { o feature { f(it::returnNullable4, "a", 1, true, 1.2) } notToBeNull { o toBe 1 } } + val f5NullableHolds: F = { o feature { f(it::returnNullable5, "a", 1, true, 1.2, 'b') } notToBeNull { o toBe 1 } } + //@formatter:on + + val propertyLazyWithNestedImmediate: F = { + o feature of({ f(it::nonNullValue) }) { + feature { f(it::length) } toBe 12 + } + } + val propertyLazyWithNestedLazy: F = { + o feature of({ f(it::nonNullValue) }) { + feature { f(it::length) } it { o toBe 12 } + } + } + + val propertyEmptyAssertionCreator: F = { o feature of({ f(it::nonNullValue) }) {} } + val f0EmptyAssertionCreator: F = { o feature of({ f(it::return0) }) {} } + val f1EmptyAssertionCreator: F = { o feature of({ f(it::return1, "a") }) {} } + val f2EmptyAssertionCreator: F = { o feature of({ f(it::return2, "a", 1) }) {} } + val f3EmptyAssertionCreator: F = { o feature of({ f(it::return3, "a", 1, true) }) {} } + val f4EmptyAssertionCreator: F = { o feature of({ f(it::return4, "a", 1, true, 1.2) }) {} } + val f5EmptyAssertionCreator: F = + { o feature of({ f(it::return5, "a", 1, true, 1.2, 'b') }) {} } + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect> = notImplemented() + val a1b: Expect> = notImplemented() + + val star: Expect> = notImplemented() + + a1 feature { f(it::size) } + a1 feature { f(it::size) } it {} + + a1b feature { f(it::size) } + a1b feature { f(it::size) } it {} + + star feature { f(it::size) } + star feature { f(it::size) } it {} + } +} + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt new file mode 100644 index 000000000..901cde901 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt @@ -0,0 +1,126 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.integration.TestData +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + +class FeatureAssertionsClassReferenceSpec : ch.tutteli.atrium.specs.integration.FeatureAssertionsSpec( + propertyImmediate, + propertyLazy, + return0ValueImmediate, + return1ValueImmediate, + return2ValueImmediate, + return3ValueImmediate, + return4ValueImmediate, + return5ValueImmediate, + return0ValueLazy, + return1ValueLazy, + return2ValueLazy, + return3ValueLazy, + return4ValueLazy, + return5ValueLazy, + + propertyNullableDoesNotHold, + return0ValueNullableDoesNotHold, + return1ValueNullableDoesNotHold, + return2ValueNullableDoesNotHold, + return3ValueNullableDoesNotHold, + return4ValueNullableDoesNotHold, + return5ValueNullableDoesNotHold, + + propertyNullableHolds, + return0ValueNullableHolds, + return1ValueNullableHolds, + return2ValueNullableHolds, + return3ValueNullableHolds, + return4ValueNullableHolds, + return5ValueNullableHolds, + + propertyLazyWithNestedImmediate, + propertyLazyWithNestedLazy, + + propertyEmptyAssertionCreator, + f0EmptyAssertionCreator, + f1EmptyAssertionCreator, + f2EmptyAssertionCreator, + f3EmptyAssertionCreator, + f4EmptyAssertionCreator, + f5EmptyAssertionCreator, + + isAbleToEvaluateDescription = true +) { + + //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again + companion object : WithAsciiReporter() { + //@formatter:off + val propertyImmediate: F = { o feature TestData::nonNullValue contains "hello" } + val propertyLazy: F = { o feature of(TestData::nonNullValue) { o contains "hello" } } + val return0ValueImmediate: F = { o feature TestData::return0 contains "hello" } + val return1ValueImmediate: F = { o feature of(TestData::return1, "a") contains "hello" } + val return2ValueImmediate: F = { o feature of(TestData::return2, "a", 1) contains "hello" } + val return3ValueImmediate: F = { o feature of(TestData::return3, "a", 1, true) contains "hello" } + val return4ValueImmediate: F = { o feature of(TestData::return4, "a", 1, true, 1.2) contains "hello" } + val return5ValueImmediate: F = { o feature of(TestData::return5, "a", 1, true, 1.2, 'b') contains "hello" } + val return0ValueLazy: F = { o feature of(TestData::return0) { contains("hello") } } + val return1ValueLazy: F = { o feature of(TestData::return1, "a") { contains("hello") } } + val return2ValueLazy: F = { o feature of(TestData::return2, "a", 1) { contains("hello") } } + val return3ValueLazy: F = { o feature of(TestData::return3, "a", 1, true) { contains("hello") } } + val return4ValueLazy: F = { o feature of(TestData::return4, "a", 1, true, 1.2) { contains("hello") } } + val return5ValueLazy: F = { o feature of(TestData::return5, "a", 1, true, 1.2, 'b') { contains("hello") } } + + val propertyNullableDoesNotHold: F = { o feature TestData::nullableValue toBe null } + val return0ValueNullableDoesNotHold: F = { o feature TestData::returnNullable0 toBe null } + val return1ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable1, "a") toBe null } + val return2ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable2, "a", 1) toBe null } + val return3ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable3, "a", 1, true) toBe null } + val return4ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable4, "a", 1, true, 1.2) toBe null } + val return5ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable5, "a", 1, true, 1.2, 'b') toBe null } + + val propertyNullableHolds: F = { o feature TestData::nullableValue notToBeNull { o toBe 1 } } + val return0ValueNullableHolds: F = { o feature TestData::returnNullable0 notToBeNull { o toBe 1 } } + val return1ValueNullableHolds: F = { o feature of(TestData::returnNullable1, "a") notToBeNull { o toBe 1 } } + val return2ValueNullableHolds: F = { o feature of(TestData::returnNullable2, "a", 1) notToBeNull { o toBe 1 } } + val return3ValueNullableHolds: F = { o feature of(TestData::returnNullable3, "a", 1, true) notToBeNull { o toBe 1 } } + val return4ValueNullableHolds: F = { o feature of(TestData::returnNullable4, "a", 1, true, 1.2) notToBeNull { o toBe 1 } } + val return5ValueNullableHolds: F = { o feature of(TestData::returnNullable5, "a", 1, true, 1.2, 'b') notToBeNull { o toBe 1 } } + //@formatter:on + + val propertyLazyWithNestedImmediate: F = { + o feature of(TestData::nonNullValue) { + o feature String::length toBe 12 + } + } + val propertyLazyWithNestedLazy: F = { + o feature of(TestData::nonNullValue) { + o feature of(String::length) { o toBe (12) } + } + } + + val propertyEmptyAssertionCreator: F = { o feature of(TestData::nonNullValue) {} } + val f0EmptyAssertionCreator: F = { o feature of(TestData::return0) {} } + val f1EmptyAssertionCreator: F = { o feature of(TestData::return1, "a") {} } + val f2EmptyAssertionCreator: F = { o feature of(TestData::return2, "a", 1) {} } + val f3EmptyAssertionCreator: F = { o feature of(TestData::return3, "a", 1, true) {} } + val f4EmptyAssertionCreator: F = { o feature of(TestData::return4, "a", 1, true, 1.2) {} } + val f5EmptyAssertionCreator: F = { o feature of(TestData::return5, "a", 1, true, 1.2, 'b') {} } + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val a1: Expect> = notImplemented() + val a1b: Expect> = notImplemented() + + val star: Expect> = notImplemented() + + a1 feature Collection<*>::size + a1 feature of(Collection<*>::size) {} + + a1b feature Collection<*>::size + a1b feature of(Collection<*>::size) {} + + star feature Collection<*>::size + star feature of(Collection<*>::size) {} + } +} + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt new file mode 100644 index 000000000..9a544d521 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt @@ -0,0 +1,118 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.workaround.it +import ch.tutteli.atrium.specs.integration.TestData +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + + +class FeatureAssertionsManualSpec : ch.tutteli.atrium.specs.integration.FeatureAssertionsSpec( + propertyImmediate, + propertyLazy, + f0Immediate, + f1Immediate, + f2Immediate, + f3Immediate, + f4Immediate, + f5Immediate, + f0Lazy, + f1Lazy, + f2Lazy, + f3Lazy, + f4Lazy, + f5Lazy, + + propertyNullableDoesNotHold, + f0NullableDoesNotHold, + f1NullableDoesNotHold, + f2NullableDoesNotHold, + f3NullableDoesNotHold, + f4NullableDoesNotHold, + f5NullableDoesNotHold, + + propertyNullableHolds, + f0NullableHolds, + f1NullableHolds, + f2NullableHolds, + f3NullableHolds, + f4NullableHolds, + f5NullableHolds, + + propertyLazyWithNestedImmediate, + propertyLazyWithNestedLazy, + + propertyEmptyAssertionCreator, + f0EmptyAssertionCreator, + f1EmptyAssertionCreator, + f2EmptyAssertionCreator, + f3EmptyAssertionCreator, + f4EmptyAssertionCreator, + f5EmptyAssertionCreator, + + isAbleToEvaluateDescription = false +) { + //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again + companion object : WithAsciiReporter() { + //@formatter:off + val propertyImmediate: F = { o feature { f("nonNullValue", it.nonNullValue) } contains "hello" } + + val propertyLazy: F = { o feature(of({ f("nonNullValue", it.nonNullValue) }) { o contains "hello" }) } + val f0Immediate: F = { o feature { f("return0()", it.return0()) } contains "hello" } + val f1Immediate: F = { o feature { f("return1(\"a\")", it.return1("a")) } contains "hello" } + val f2Immediate: F = { o feature { f("return2(\"a\", 1)", it.return2("a", 1)) } contains "hello" } + val f3Immediate: F = { o feature { f("return3(\"a\", 1, true)", it.return3("a", 1, true)) } contains "hello" } + val f4Immediate: F = { o feature { f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) } contains "hello" } + val f5Immediate: F = { o feature { f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) } contains "hello" } + val f0Lazy: F = { o feature of({ f("return0()", it.return0()) }) { o contains "hello" } } + val f1Lazy: F = { o feature of({ f("return1(\"a\")", it.return1("a")) }) { o contains "hello" } } + val f2Lazy: F = { o feature of({ f("return2(\"a\", 1)", it.return2("a", 1)) }) { o contains "hello" } } + val f3Lazy: F = { o feature of({ f("return3(\"a\", 1, true)", it.return3("a", 1, true)) }) { o contains "hello" } } + val f4Lazy: F = { o feature of({ f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) }) { o contains "hello" } } + val f5Lazy: F = { o feature of({ f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) }) { o contains "hello" } } + + val propertyNullableDoesNotHold: F = { o feature { f("nullableValue", it.nullableValue) } toBe null } + val f0NullableDoesNotHold: F = { o feature { f("returnNullable0()", it.returnNullable0()) } toBe null } + val f1NullableDoesNotHold: F = { o feature { f("returnNullable1(\"a\")", it.returnNullable1("a")) } toBe null } + val f2NullableDoesNotHold: F = { o feature { f("returnNullable2(\"a\", 1)", it.returnNullable2("a", 1)) } toBe null } + val f3NullableDoesNotHold: F = { o feature { f("returnNullable3(\"a\", 1, true)", it.returnNullable3("a", 1, true)) } toBe null } + val f4NullableDoesNotHold: F = { o feature { f("returnNullable4(\"a\", 1, true, 1.2)", it.returnNullable4("a", 1, true, 1.2)) } toBe null } + val f5NullableDoesNotHold: F = { o feature { f("returnNullable5(\"a\", 1, true, 1.2, 'b')", it.returnNullable5("a", 1, true, 1.2, 'b')) } toBe null } + + val propertyNullableHolds: F = { o feature { f("nullableValue", it.nullableValue) } notToBeNull { o toBe 1 } } + val f0NullableHolds: F = { o feature { f("returnNullable0()", it.returnNullable0()) } notToBeNull { o toBe 1 } } + val f1NullableHolds: F = { o feature { f("returnNullable1(\"a\")", it.returnNullable1("a")) } notToBeNull { o toBe 1 } } + val f2NullableHolds: F = { o feature { f("returnNullable2(\"a\", 1)", it.returnNullable2("a", 1)) } notToBeNull { o toBe 1 } } + val f3NullableHolds: F = { o feature { f("returnNullable3(\"a\", 1, true)", it.returnNullable3("a", 1, true)) } notToBeNull { o toBe 1 } } + val f4NullableHolds: F = { o feature { f("returnNullable4(\"a\", 1, true, 1.2)", it.returnNullable4("a", 1, true, 1.2)) } notToBeNull { o toBe 1 } } + val f5NullableHolds: F = { o feature { f("returnNullable5(\"a\", 1, true, 1.2, 'b')", it.returnNullable5("a", 1, true, 1.2, 'b')) } notToBeNull { o toBe 1 } } + //@formatter:on + + val propertyLazyWithNestedImmediate: F = { + o feature of({ f("nonNullValue", it.nonNullValue) }) { + feature { f("length", it.length) } toBe 12 + } + } + val propertyLazyWithNestedLazy: F = { + o feature of({ f("nonNullValue", it.nonNullValue) }) { + feature { f("length", it.length) } it { o toBe 12 } + } + } + + val propertyEmptyAssertionCreator: F = + { o feature of({ f("nonNullValue", it.nonNullValue) }) {} } + val f0EmptyAssertionCreator: F = { o feature of({ f("return0()", it.return0()) }) {} } + val f1EmptyAssertionCreator: F = { o feature of({ f("return1(\"a\")", it.return1("a")) }) {} } + val f2EmptyAssertionCreator: F = + { o feature of({ f("return2(\"a\", 1)", it.return2("a", 1)) }) {} } + val f3EmptyAssertionCreator: F = + { o feature of({ f("return3(\"a\", 1, true)", it.return3("a", 1, true)) }) {} } + val f4EmptyAssertionCreator: F = + { o feature of({ f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) }) {} } + val f5EmptyAssertionCreator: F = + { + o feature of({ + f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) + }) {} + } + } +} + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureWorstCaseTest.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureWorstCaseTest.kt new file mode 100644 index 000000000..7d69a4bd0 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureWorstCaseTest.kt @@ -0,0 +1,27 @@ +@file:Suppress("UNUSED_PARAMETER", "unused") + +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.verbs.internal.expect +import kotlin.js.JsName + +class WorstCase { + + val propAndFun: Int = 1 + @JsName("propFun") + fun propAndFun(): Int = 1 + + fun overloaded(): Int = 1 + fun overloaded(b: Boolean): Int = 1 +} + + +@Suppress(/* requires new type inference */ "RemoveExplicitTypeArguments") +fun testOverloadAmbiguity() { + expect(WorstCase()) { + feature { p(it::propAndFun) } + feature { f0(it::propAndFun) } + feature { f0(it::overloaded) } + feature { f1(it::overloaded, true) } + } +} From 73c642257f23de40378d60a5b0fa734f2f3c699d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 21:37:40 +0100 Subject: [PATCH 072/142] provide alternative for manual features in case of new inference --- .../api/infix/en_GB/featureAssertions.kt | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt index 3488d9004..4cad373dd 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt @@ -118,6 +118,7 @@ infix fun Expect.feature(provider: MetaFeatureOption.(T) -> MetaFea * * ``` * // use + * import ch.tutteli.atrium.api.infix.en_GB.workaround.it * expect(person) feature { f(it::age) } it { o toBe 20 } * * // instead of (which causes problems with Kotlin < 1.4) @@ -149,6 +150,10 @@ infix fun Expect.feature(of: MetaFeatureOptionWithCreator): Expe * expect(person) feature { f("first underage child", it.children.first { it < 18 }) } * ``` * + * Note that you can use `feature of("first underage child") { children.first { it < 18 } }` with the new type inference + * enabled (e.g. if you use Kotlin 1.4 or above). + * This method will most likely be removed once Kotlin 1.4 is out (probably with Atrium 1.0) + * * @return The newly created [MetaFeature]. */ @Suppress("unused" /* unused receiver, but that's fine */) @@ -158,72 +163,96 @@ fun MetaFeatureOption.f(description: String, provider: R): MetaFeature //@formatter:off /** * Helper function to create a [Feature] based on a [KFunction2] + arguments. + * + * @return The newly created [Feature]. */ fun of(f: KFunction2, a1: A1): Feature = Feature(formatMethodCall(f, a1)) { f.invoke(it, a1) } /** * Helper function to create a [Feature] based on a [KFunction3] + arguments. + * + * @return The newly created [Feature]. */ fun of(f: KFunction3, a1: A1, a2: A2): Feature = Feature(formatMethodCall(f, a1, a2)) { f.invoke(it, a1, a2) } /** * Helper function to create a [Feature] based on a [KFunction4] + arguments. + * + * @return The newly created [Feature]. */ fun of(f: KFunction4, a1: A1, a2: A2, a3: A3): Feature = Feature(formatMethodCall(f, a1, a2, a3)) { f.invoke(it, a1, a2, a3) } /** * Helper function to create a [Feature] based on a [KFunction5] + arguments. + * + * @return The newly created [Feature]. */ fun of(f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4): Feature = Feature(formatMethodCall(f, a1, a2, a3, a4)) { f.invoke(it, a1, a2, a3, a4) } /** * Helper function to create a [Feature] based on a [KFunction6] + arguments. + * + * @return The newly created [Feature]. */ fun of(f: KFunction6, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): Feature = Feature(formatMethodCall(f, a1, a2, a3, a4, a5)) { f.invoke(it, a1, a2, a3, a4, a5) } /** * Helper function to create a [FeatureWithCreator] based on a [KProperty1] + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(property: KProperty1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(property.name, { property.invoke(it) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction1] + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(f: KFunction1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(formatMethodCall(f), { f.invoke(it) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction2] + arguments + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(f: KFunction2, a1: A1, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(formatMethodCall(f, a1), { f.invoke(it, a1) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction3] + arguments + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(f: KFunction3, a1: A1, a2: A2, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(formatMethodCall(f, a1, a2), { f.invoke(it, a1, a2) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction4] + arguments + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(f: KFunction4, a1: A1, a2: A2, a3: A3, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(formatMethodCall(f, a1, a2, a3), { f.invoke(it, a1, a2, a3) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction5] + arguments + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(f: KFunction5, a1: A1, a2: A2, a3: A3, a4: A4, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(formatMethodCall(f, a1, a2, a3, a4), { f.invoke(it, a1, a2, a3, a4) }, assertionCreator) /** * Helper function to create a [FeatureWithCreator] based on a [KFunction6] + arguments + [assertionCreator]. + * + * @return The newly created [FeatureWithCreator]. */ fun of(f: KFunction6, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, assertionCreator: Expect.() -> Unit): FeatureWithCreator = FeatureWithCreator(formatMethodCall(f, a1, a2, a3, a4, a5), { f.invoke(it, a1, a2, a3, a4, a5) }, assertionCreator) @@ -244,3 +273,63 @@ fun of( provider, assertionCreator ) + +/** + * Creates a [Feature] using the given [extractor] and [description]. + * + * This can be used to create complex features with a custom description or as workaround where Kotlin is not able to + * infer the types properly. + * + * For instance: + * ``` + * expect(person) feature of("first underage child") { children.first { it < 18 } } + * ``` + * + * Note, you need to enable the new type inference of Kotlin (or use Kotlin 1.4 and above) in order that Kotlin + * is able to infer the types. + * As workaround you can use [feature] with the overload which expects `MetaFeatureOption.(T) -> MetaFeature`. + * For instance: + * ``` + * // use + * expect(person) feature { f("first underage child", { it.children.first { it < 18 }) } + * + * // instead of (which causes problems with Kotlin < 1.4) + * expect(person) feature of("first underage child") { children.first { it < 18 } + * ``` + * + * @return The newly created [Feature]. + */ +fun of(description: String, extractor: T.() -> R): Feature = + Feature(description, extractor) + +/** + * Creates a [Feature] using the given [extractor] and [description]. + * + * This can be used to create complex features with a custom description or as workaround where Kotlin is not able to + * infer the types properly. + * + * For instance: + * ``` + * expect(person) feature of("first underage child", { children.first { it < 18 }) { name.toBe("robert) } + * ``` + * + * Note, you need to enable the new type inference of Kotlin (or use Kotlin 1.4 and above) in order that Kotlin + * is able to infer the types. + * As workaround you can use [feature] with the overload which expects `MetaFeatureOption.(T) -> MetaFeature`. + * and use `it` after the call (import from the package workaround). For instance: + * ``` + * // use + * import ch.tutteli.atrium.api.infix.en_GB.workaround.it + * expect(person) feature { f(it::age) } it { o toBe 20 } + * + * // instead of (which causes problems with Kotlin < 1.4) + * expect(person) feature of({ f(it::age) }) { o toBe 20 } + * ``` + * + * @return The newly created [Feature]. + */ +fun of( + description: String, + extractor: T.() -> R, + assertionCreator: Expect.() -> Unit +): FeatureWithCreator = FeatureWithCreator(description, extractor, assertionCreator) From ff52df7ab543eb4570774f319d930ec8a4589935 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 22:11:45 +0100 Subject: [PATCH 073/142] change @since 0.10.0 for new infix api to 0.11.0 --- .../atrium/api/infix/en_GB/anyAssertions.kt | 2 +- .../api/infix/en_GB/charSequenceAssertions.kt | 12 +++--- .../en_GB/charSequenceContainsCreators.kt | 8 ++-- .../infix/en_GB/creating/feature/Feature.kt | 2 +- .../creating/feature/FeatureWithCreator.kt | 2 +- .../feature/MetaFeatureOptionWithCreator.kt | 2 +- .../en_GB/creating/list/IndexWithCreator.kt | 2 +- .../en_GB/creating/map/KeyWithCreator.kt | 2 +- .../api/infix/en_GB/featureAssertions.kt | 12 +++--- .../atrium/api/infix/en_GB/keywords.kt | 6 +-- .../api/infix/en_GB/throwableAssertions.kt | 4 +- .../en_GB/jdk8/chronoLocalDateAssertions.kt | 10 ++--- .../jdk8/chronoZonedDateTimeAssertions.kt | 10 ++--- .../api/infix/en_GB/jdk8/fileAssertions.kt | 4 +- .../infix/en_GB/jdk8/localDateAssertions.kt | 16 ++++---- .../en_GB/jdk8/localDateTimeAssertions.kt | 16 ++++---- .../api/infix/en_GB/jdk8/pathAssertions.kt | 38 +++++++++---------- .../en_GB/jdk8/zonedDateTimeAssertions.kt | 16 ++++---- 18 files changed, 82 insertions(+), 82 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt index 093148973..be575a646 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt @@ -156,7 +156,7 @@ inline infix fun Expect<*>.isA(noinline assertionCreator: E * * @return An [Expect] for the current subject of the assertion. * - * @since 0.10.0 + * @since 0.11.0 */ @Suppress("NOTHING_TO_INLINE") inline infix fun Expect.and(@Suppress("UNUSED_PARAMETER") o: o): Expect = this diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt index 46370d8fe..955aaac46 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -199,7 +199,7 @@ infix fun Expect.startsWith(expected: CharSequence) = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.startsWith(expected: Char) = o startsWith expected.toString() @@ -219,7 +219,7 @@ infix fun Expect.startsNotWith(expected: CharSequence) = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.startsNotWith(expected: Char) = o startsNotWith expected.toString() @@ -240,7 +240,7 @@ infix fun Expect.endsWith(expected: CharSequence) = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.endsWith(expected: Char) = o endsWith expected.toString() @@ -260,7 +260,7 @@ infix fun Expect.endsNotWith(expected: CharSequence) = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.endsNotWith(expected: Char) = o endsNotWith expected.toString() @@ -305,7 +305,7 @@ infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") Bla * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.matches(expected: Regex) = addAssertion(ExpectImpl.charSequence.matches(this, expected)) @@ -318,7 +318,7 @@ infix fun Expect.matches(expected: Regex) = * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.mismatches(expected: Regex) = addAssertion(ExpectImpl.charSequence.mismatches(this, expected)) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt index 06eea54f4..2922782f1 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -179,7 +179,7 @@ infix fun CheckerOption.regex(pattern * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun CheckerOption.matchFor( pattern: Regex @@ -230,7 +230,7 @@ infix fun CheckerOption.the(patterns: * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun CheckerOption.matchFor(patterns: All): Expect = addAssertion(ExpectImpl.charSequence.contains.regex(this, patterns.toList())) @@ -336,7 +336,7 @@ infix fun Builder.the(pattern * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given * [expectedIterable] does not have elements (is empty). * - * @since 0.10.0 + * @since 0.11.0 */ infix fun CheckerOption.elementsOf( expectedIterable: Iterable @@ -365,7 +365,7 @@ infix fun CheckerOption.elementsOf( * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given * [expectedIterable] does not have elements (is empty). * - * @since 0.10.0 + * @since 0.11.0 */ @JvmName("elementsOfIgnoringCase") infix fun CheckerOption.elementsOf( diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt index caa8a9d4f..fadaf71d8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt @@ -13,6 +13,6 @@ import kotlin.reflect.KProperty1 * @property description The description of the feature. * @property extractor The extractor which extracts the feature out of the subject of the assertion. - * @since 0.10.0 + * @since 0.11.0 */ data class Feature(val description: String, val extractor: (T) -> R) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt index 3aeddb1ce..be092d45d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt @@ -16,7 +16,7 @@ import kotlin.reflect.KProperty1 * @property extractor The extractor which extracts the feature out of the subject of the assertion. * @property assertionCreator The `assertionCreator`-lambda which defines assertions for the feature. * - * @since 0.10.0 + * @since 0.11.0 */ data class FeatureWithCreator( val description: String, diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt index 4b8097530..a62365c5e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt @@ -14,7 +14,7 @@ import ch.tutteli.atrium.domain.creating.MetaFeature * Usually you use [f][MetaFeatureOption.f] to create a [MetaFeature], * e.g. `feature of({ f(it::size) }) { o toBe 3 }` * - * @since 0.10.0 + * @since 0.11.0 */ data class MetaFeatureOptionWithCreator( val provider: MetaFeatureOption.(T) -> MetaFeature, diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt index efb18670a..cd674220f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt @@ -9,6 +9,6 @@ import ch.tutteli.atrium.creating.Expect * * Use the function `index(Int) { ... }` to create this representation. * - * @since 0.10.0 + * @since 0.11.0 */ data class IndexWithCreator(val index: Int, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt index 853472d2d..c4c2716cd 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt @@ -9,6 +9,6 @@ import ch.tutteli.atrium.creating.Expect * Use the function `key(...) { ... }` to create this representation where the first parameter corresponds * to the [key] and the second is the [assertionCreator] * - * @since 0.10.0 + * @since 0.11.0 */ data class KeyWithCreator(val key: K, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt index 4cad373dd..59c7669f6 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/featureAssertions.kt @@ -19,7 +19,7 @@ import kotlin.reflect.* * * @return The newly created [Expect] for the given [property]. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.feature(property: KProperty1): FeatureExpect = ExpectImpl.feature.property(this, property).getExpectOfFeature() @@ -35,7 +35,7 @@ infix fun Expect.feature(property: KProperty1): FeatureExpect * @return The newly created [Expect] for the return value of calling the method [f] * on the current subject of the assertion. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.feature(f: KFunction1): FeatureExpect = ExpectImpl.feature.f0(this, f).getExpectOfFeature() @@ -55,7 +55,7 @@ infix fun Expect.feature(f: KFunction1): FeatureExpect = * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ //TODO remove `in` with Kotlin 1.4 (most likely with Atrium 1.0.0) infix fun Expect.feature(of: Feature): FeatureExpect = @@ -80,7 +80,7 @@ infix fun Expect.feature(of: Feature): FeatureExpect = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] in case the created [AssertionGroup] does not hold. * - * @since 0.10.0 + * @since 0.11.0 */ //TODO remove `in` with Kotlin 1.4 (most likely with Atrium 1.0.0) infix fun Expect.feature(of: FeatureWithCreator): Expect = @@ -99,7 +99,7 @@ infix fun Expect.feature(of: FeatureWithCreator): Expect = * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.feature(provider: MetaFeatureOption.(T) -> MetaFeature): FeatureExpect = ExpectImpl.feature.genericSubjectBasedFeature(this) { MetaFeatureOption(this).provider(it) }.getExpectOfFeature() @@ -132,7 +132,7 @@ infix fun Expect.feature(provider: MetaFeatureOption.(T) -> MetaFea * e.g. `feature of({ f(it::size) }) { o toBe 3 }` * * @return An [Expect] for the current subject of the assertion. - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.feature(of: MetaFeatureOptionWithCreator): Expect = ExpectImpl.feature.genericSubjectBasedFeature(this) { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 16647ec91..225a2e150 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -56,7 +56,7 @@ object group : Keyword * Represents the pseudo keyword `not` as in [contains] `not`. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. * - * @since 0.10.0 + * @since 0.11.0 */ object not : Keyword @@ -67,7 +67,7 @@ object not : Keyword * * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. * - * @since 0.10.0 + * @since 0.11.0 */ object o : Keyword @@ -77,7 +77,7 @@ object o : Keyword * In case you want to refer to the pseudo-keyword `o` inside an [Expect] context, * then you can use this type alias instead to circumvent the bug. * - * @since 0.10.0 + * @since 0.11.0 */ typealias O = o diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt index e678900e8..35b904e22 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -57,7 +57,7 @@ infix fun Expect.messageContains(values: Values): Expect * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ @Suppress("RemoveExplicitTypeArguments") inline fun Expect.cause(): Expect = @@ -74,7 +74,7 @@ inline fun Expect.cause(): Expect * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ @Suppress("RemoveExplicitTypeArguments") inline infix fun Expect.cause( diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt index ab78421e0..0683b00b5 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateAssertions.kt @@ -14,7 +14,7 @@ import java.time.chrono.ChronoLocalDate * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.isBefore(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isBefore(this, expected)) @@ -26,7 +26,7 @@ infix fun Expect.isBefore(expected: ChronoLocalDate): E * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.isBeforeOrEqual(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isBeforeOrEquals(this, expected)) @@ -39,7 +39,7 @@ infix fun Expect.isBeforeOrEqual(expected: ChronoLocalD * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.isAfter(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isAfter(this, expected)) @@ -51,7 +51,7 @@ infix fun Expect.isAfter(expected: ChronoLocalDate): Ex * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.isAfterOrEqual(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isAfterOrEquals(this, expected)) @@ -63,7 +63,7 @@ infix fun Expect.isAfterOrEqual(expected: ChronoLocalDa * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.isEqual(expected: ChronoLocalDate): Expect = addAssertion(ExpectImpl.chronoLocalDate.isEqual(this, expected)) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt index 63871d9cd..79c990409 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoZonedDateTimeAssertions.kt @@ -15,7 +15,7 @@ import java.time.chrono.ChronoZonedDateTime * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun > Expect.isBefore( expected: ChronoZonedDateTime<*> @@ -28,7 +28,7 @@ infix fun > Expect.isBefore( * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun > Expect.isBeforeOrEqual( expected: ChronoZonedDateTime<*> @@ -41,7 +41,7 @@ infix fun > Expect.isBeforeOrEqu * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun > Expect.isAfter( expected: ChronoZonedDateTime<*> @@ -54,7 +54,7 @@ infix fun > Expect.isAfter( * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun > Expect.isAfterOrEqual( expected: ChronoZonedDateTime<*> @@ -67,7 +67,7 @@ infix fun > Expect.isAfterOrEqua * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun > Expect.isEqual( expected: ChronoZonedDateTime<*> diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt index 4c6e60129..5fcfa389f 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt @@ -15,7 +15,7 @@ import java.nio.file.Path * * @return The newly created [Expect] for the transformed subject. * - * @since 0.10.0 + * @since 0.11.0 */ fun Expect.asPath(): Expect = ExpectImpl.changeSubject(this).unreported { it.toPath() } @@ -29,7 +29,7 @@ fun Expect.asPath(): Expect = * * @return An [Expect] for the current subject of the assertion. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.asPath(assertionCreator: Expect.() -> Unit): Expect = apply { asPath().addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt index c343bfa2f..31d4efc4f 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateAssertions.kt @@ -17,7 +17,7 @@ import java.time.LocalDate * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.year: Expect get() = ExpectImpl.localDate.year(this).getExpectOfFeature() @@ -30,7 +30,7 @@ val Expect.year: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDate.year(this).addToInitial(assertionCreator) @@ -41,7 +41,7 @@ infix fun Expect.year(assertionCreator: Expect.() -> Uni * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.month: Expect get() = ExpectImpl.localDate.month(this).getExpectOfFeature() @@ -54,7 +54,7 @@ val Expect.month: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDate.month(this).addToInitial(assertionCreator) @@ -65,7 +65,7 @@ infix fun Expect.month(assertionCreator: Expect.() -> Un * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.dayOfWeek: Expect get() = ExpectImpl.localDate.dayOfWeek(this).getExpectOfFeature() @@ -78,7 +78,7 @@ val Expect.dayOfWeek: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDate.dayOfWeek(this).addToInitial(assertionCreator) @@ -90,7 +90,7 @@ infix fun Expect.dayOfWeek(assertionCreator: Expect Expect.day: Expect get() = ExpectImpl.localDate.day(this).getExpectOfFeature() @@ -103,7 +103,7 @@ val Expect.day: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDate.day(this).addToInitial(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt index 4cf14c207..dfc33a3ee 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/localDateTimeAssertions.kt @@ -17,7 +17,7 @@ import java.time.LocalDateTime * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.year: Expect get() = ExpectImpl.localDateTime.year(this).getExpectOfFeature() @@ -30,7 +30,7 @@ val Expect.year: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDateTime.year(this).addToInitial(assertionCreator) @@ -41,7 +41,7 @@ infix fun Expect.year(assertionCreator: Expect.() -> * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.month: Expect get() = ExpectImpl.localDateTime.month(this).getExpectOfFeature() @@ -54,7 +54,7 @@ val Expect.month: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDateTime.month(this).addToInitial(assertionCreator) @@ -65,7 +65,7 @@ infix fun Expect.month(assertionCreator: Expect.() - * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.dayOfWeek: Expect get() = ExpectImpl.localDateTime.dayOfWeek(this).getExpectOfFeature() @@ -78,7 +78,7 @@ val Expect.dayOfWeek: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDateTime.dayOfWeek(this).addToInitial(assertionCreator) @@ -89,7 +89,7 @@ infix fun Expect.dayOfWeek(assertionCreator: Expect Expect.day: Expect get() = ExpectImpl.localDateTime.day(this).getExpectOfFeature() @@ -102,7 +102,7 @@ val Expect.day: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.localDateTime.day(this).addToInitial(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 7dbb7645f..69296b108 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -13,7 +13,7 @@ import java.nio.file.Path * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.startsWith(expected: Path): Expect = addAssertion(ExpectImpl.path.startsWith(this, expected)) @@ -24,7 +24,7 @@ infix fun Expect.startsWith(expected: Path): Expect = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.startsNotWith(expected: Path): Expect = addAssertion(ExpectImpl.path.startsNotWith(this, expected)) @@ -35,7 +35,7 @@ infix fun Expect.startsNotWith(expected: Path): Expect = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.endsWith(expected: Path): Expect = addAssertion(ExpectImpl.path.endsWith(this, expected)) @@ -47,7 +47,7 @@ infix fun Expect.endsWith(expected: Path): Expect = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.endsNotWith(expected: Path): Expect = addAssertion(ExpectImpl.path.endsNotWith(this, expected)) @@ -62,7 +62,7 @@ infix fun Expect.endsNotWith(expected: Path): Expect = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.to(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.exists(this)) @@ -77,7 +77,7 @@ infix fun Expect.to(@Suppress("UNUSED_PARAMETER") exist: exist): E * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.notTo(@Suppress("UNUSED_PARAMETER") exist: exist): Expect = addAssertion(ExpectImpl.path.existsNot(this)) @@ -89,7 +89,7 @@ infix fun Expect.notTo(@Suppress("UNUSED_PARAMETER") exist: exist) * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.fileName: Expect get() = ExpectImpl.path.fileName(this).getExpectOfFeature() @@ -103,7 +103,7 @@ val Expect.fileName: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.fileName(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.fileName(this).addToInitial(assertionCreator) @@ -116,7 +116,7 @@ infix fun Expect.fileName(assertionCreator: Expect.() -> U * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.fileNameWithoutExtension: Expect get() = ExpectImpl.path.fileNameWithoutExtension(this).getExpectOfFeature() @@ -130,7 +130,7 @@ val Expect.fileNameWithoutExtension: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.fileNameWithoutExtension(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.fileNameWithoutExtension(this).addToInitial(assertionCreator) @@ -142,7 +142,7 @@ infix fun Expect.fileNameWithoutExtension(assertionCreator: Expect * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.parent: Expect get() = ExpectImpl.path.parent(this).getExpectOfFeature() @@ -154,7 +154,7 @@ val Expect.parent: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.parent(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.parent(this).addToInitial(assertionCreator) @@ -166,7 +166,7 @@ infix fun Expect.parent(assertionCreator: Expect.() -> Unit) * @return The newly created [Expect] for the extracted feature. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.resolve(other: String): Expect = ExpectImpl.path.resolve(this, other).getExpectOfFeature() @@ -187,7 +187,7 @@ infix fun Expect.resolve(other: String): Expect = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") readable: readable): Expect = addAssertion(ExpectImpl.path.isReadable(this)) @@ -204,7 +204,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") readable: read * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") writable: writable): Expect = addAssertion(ExpectImpl.path.isWritable(this)) @@ -224,7 +224,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") writable: writ * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aRegularFile: aRegularFile): Expect = addAssertion(ExpectImpl.path.isRegularFile(this)) @@ -244,7 +244,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aRegularFile: * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aDirectory: aDirectory): Expect = addAssertion(ExpectImpl.path.isDirectory(this)) @@ -256,7 +256,7 @@ infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") aDirectory: aD * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.extension: Expect get() = ExpectImpl.path.extension(this).getExpectOfFeature() @@ -270,7 +270,7 @@ val Expect.extension: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.extension(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.path.extension(this).addToInitial(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt index c89144591..df74e96e5 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/zonedDateTimeAssertions.kt @@ -17,7 +17,7 @@ import java.time.ZonedDateTime * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.year: Expect get() = ExpectImpl.zonedDateTime.year(this).getExpectOfFeature() @@ -30,7 +30,7 @@ val Expect.year: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.year(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.zonedDateTime.year(this).addToInitial(assertionCreator) @@ -41,7 +41,7 @@ infix fun Expect.year(assertionCreator: Expect.() -> * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.month: Expect get() = ExpectImpl.zonedDateTime.month(this).getExpectOfFeature() @@ -54,7 +54,7 @@ val Expect.month: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.month(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.zonedDateTime.month(this).addToInitial(assertionCreator) @@ -65,7 +65,7 @@ infix fun Expect.month(assertionCreator: Expect.() - * * @return The newly created [Expect] for the extracted feature. * - * @since 0.10.0 + * @since 0.11.0 */ val Expect.dayOfWeek: Expect get() = ExpectImpl.zonedDateTime.dayOfWeek(this).getExpectOfFeature() @@ -78,7 +78,7 @@ val Expect.dayOfWeek: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.dayOfWeek(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.zonedDateTime.dayOfWeek(this).addToInitial(assertionCreator) @@ -89,7 +89,7 @@ infix fun Expect.dayOfWeek(assertionCreator: Expect Expect.day: Expect get() = ExpectImpl.zonedDateTime.day(this).getExpectOfFeature() @@ -102,7 +102,7 @@ val Expect.day: Expect * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.10.0 + * @since 0.11.0 */ infix fun Expect.day(assertionCreator: Expect.() -> Unit): Expect = ExpectImpl.zonedDateTime.day(this).addToInitial(assertionCreator) From 7dddc9d5863f741730ba2327848c5db06bdc87a8 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 22:14:24 +0100 Subject: [PATCH 074/142] format KDoc of Throwable.cause --- .../ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt index e1b38a175..b24342608 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/throwableAssertions.kt @@ -46,7 +46,7 @@ fun Expect.messageContains(expected: Any, vararg otherExpecte * Expects that the property [Throwable.cause] of the subject *is a* [TExpected] (the same type or a sub-type), * creates an [Expect] of the [TExpected] type for it and returns it. * - * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion + * @return The newly created [Expect] for the property [Throwable.cause] of the subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 @@ -62,7 +62,7 @@ inline fun Expect.cause(): Expect * Notice, in contrast to other assertion functions which expect an [assertionCreator], this function returns not * [Expect] of the initial type, which was some type `T `, but an [Expect] of the specified type [TExpected]. * - * @return An [Expect] for the current subject of the assertion. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.10.0 From 284d0c32544ebe74a18d24dd59419807fe790675 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 21:53:27 +0100 Subject: [PATCH 075/142] v0.10.0 --- .github/CONTRIBUTING.md | 2 +- README.md | 233 +++++++++++++++++------------------ apis/differences.md | 8 +- build.gradle | 4 +- misc/maven/example-pom.xml | 2 +- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 7 files changed, 128 insertions(+), 129 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 89b3d0185..5dd44ff17 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/master/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/v0.10.0/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index 95047fd1d..013d9bebe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - + - # Atrium Atrium is an open-source multiplatform assertion library for Kotlin with support for JVM, JS and Android. @@ -30,12 +29,12 @@ Atrium currently provides two [API Styles](#api-styles): pure fluent and infix where both of them have their design focus on usability in conjunction with code completion functionality provided by your IDE. See [Examples](#examples) below to get a feel for how you could benefit from Atrium. ----- + **Table of Content** - [Installation](#installation) @@ -88,7 +87,7 @@ but can also be retrieved directly from [bintray](https://bintray.com/robstoll/t *gradle*: ``` buildscript { - ext { atrium_version='0.9.2' } + ext { atrium_version='0.10.0' } } repositories { mavenCentral() @@ -119,7 +118,7 @@ dependencies { click to see how the setup for the infix API looks like -The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.9.2. +The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.10.0. [Your help](https://github.com/robstoll/atrium/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22good+first+issue%22++new+infix) in bringing the new infix API forward is appreciated. @@ -144,9 +143,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/v0.10.0/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/v0.10.0/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -156,7 +155,7 @@ That is all, you are all set. Jump to [Examples](#examples) which shows how to u ``` buildscript { - ext { atrium_version='0.9.2' } + ext { atrium_version='0.10.0' } } repositories { mavenCentral() @@ -175,24 +174,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/master/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/master/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/v0.10.0/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/v0.10.0/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/master/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/v0.10.0/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -209,7 +208,7 @@ dependencies { click to see how the setup for the infix API looks like -The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.9.2. +The new infix API which is based on `Expect` and no longer on `Assert` is not yet available in v0.10.0. [Your help](https://github.com/robstoll/atrium/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22good+first+issue%22++new+infix) in bringing the new infix API forward is appreciated. @@ -250,11 +249,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.10.0/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -269,7 +268,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -282,7 +281,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -311,7 +310,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -343,7 +342,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -374,7 +373,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -409,7 +408,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -429,7 +428,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -452,7 +451,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -472,7 +471,7 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1 Notice that stacks are filtered so that you only see what is of interest. Filtering can be configured via [`ReporterBuilder`](#reporterbuilder) by choosing an appropriate -[AtriumErrorAdjuster](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). +[AtriumErrorAdjuster](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). Stack frames of Atrium and of test runners (Spek, Kotlintest and JUnit for JVM, mocha for JS) are excluded per default. [Create a Feature Request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]) in case you use a different runner, we can add yours to the list as well. @@ -505,7 +504,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -557,7 +556,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -607,7 +606,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -637,7 +636,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)
@@ -659,7 +658,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -705,7 +704,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -791,7 +790,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -812,7 +811,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -840,7 +839,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -853,7 +852,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -873,7 +872,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -889,7 +888,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -924,7 +923,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -943,7 +942,7 @@ This is reflected in the output, which tells us that we expected that the `numbe Exactly, what about the expected value `2`, why do we not see anything about it in the output? The output does not show anything about the expected value `2` because the predefined assertion verbs have configured [`ReporterBuilder`](#reporterbuilder) -to use an [Only Failure Reporter](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) +to use an [Only Failure Reporter](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) which shows us only assertions (or sub assertions) which failed. Back to the shortcut functions. @@ -964,7 +963,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1003,7 +1002,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1019,7 +1018,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1037,7 +1036,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1066,7 +1065,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1116,7 +1115,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1140,7 +1139,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1156,7 +1155,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1176,7 +1175,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1198,7 +1197,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1224,7 +1223,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1255,7 +1254,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1274,7 +1273,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1310,7 +1309,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1334,7 +1333,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) `isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry`. There are more assertion functions, a full list can be found in -[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). +[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). In case you should miss an assertion function, then please [open a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]). @@ -1351,7 +1350,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1366,7 +1365,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1388,7 +1387,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1425,7 +1424,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1459,7 +1458,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1499,7 +1498,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1517,11 +1516,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/v0.10.0/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/master/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/v0.10.0/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1555,7 +1554,7 @@ We try to provide a workaround whenever possible._ There is, but IntelliJ will not show it to you due to [this bug](https://youtrack.jetbrains.com/issue/KT-24836) (please upvote it). You should be able to see the KDoc of other functions without problems. -But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). +But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). @@ -1628,7 +1627,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1670,7 +1669,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1687,7 +1686,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1763,7 +1762,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1778,9 +1777,9 @@ Let us see how we actually defined `isMultipleOf`. the assertion to itself (creating alone is not enough, it needs to be added in order that it is evaluated). The method `createAndAddAssertion` returns itself (the same `Expect`) making it easy for you to provide a fluent API as well. - The method [createAndAddAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) + The method [createAndAddAssertion](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) expects: - - a either a `String` or a [Translatable](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) + - a either a `String` or a [Translatable](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) as description of your assertion. - the representation of the expected value. - and the actual check as lambda where you typically use `it` which refers to the subject of the assertion. @@ -1803,7 +1802,7 @@ fun Expect.isEven() = ``` -We are using a [RawString](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) +We are using a [RawString](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) here so that `"an even number"` is not treated as a `String` in reporting. Its usage looks then as follows: @@ -1812,7 +1811,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1911,7 +1910,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1943,7 +1942,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1984,7 +1983,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2045,7 +2044,7 @@ fun >> Expect.sameInitialsAs( There are a few additional methods which you can call after `mapArguments`. -See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). +See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). In case you want to provide your own implementation it suffices to create an extension function for `ArgumentMapperBuilder`. @@ -2055,21 +2054,21 @@ extension function for `ArgumentMapperBuilder`. Yet, sometimes we would like to create functions which have a better error reporting than the one we get when we compose assertion functions. -[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) is the entry point in this case. Its a builder and thus lets you find the functions you need via code completion. Following a quick overview what it provides: - all assertion functions on the domain level (what you have seen in [Compose-assertion-functions](#compose-assertion-functions) was the API level) so that you can reuse and compose them in other ways. -- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). +- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/master/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2081,7 +2080,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/master/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/v0.10.0/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2095,7 +2094,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/master/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/v0.10.0/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2136,7 +2135,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2168,8 +2167,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/v0.10.0/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2199,24 +2198,24 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
💬 Using a TranslationSupplier Next to providing translations via code you can also use a -[TranslationSupplier](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) -based [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) +[TranslationSupplier](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) +based [Translator](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) by configuring the [`ReporterBuilder`](#reporterbuilder) accordingly (e.g. use `withDefaultTranslationSupplier` instead of `withoutTranslations`). Atrium supports a properties files based `TranslationSupplier` for JVM (a supplier for JS will follow) which is more or less what [ResourceBundle](https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html) provides out of the box. Yet, a `Translator` uses a more enhanced fallback mechanism compared to a `ResourceBundle`. -For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). +For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). Notice though, that we plan to move away from the `ResourceBundle`-inspired approach due to enconding problems and missing implementations on other platforms than JVM. @@ -2275,15 +2274,15 @@ fun _isMultipleOf(container: Expect, base: Int): Assertion = Notice that the impl-function is not an extension function as before because we do not want to pollute the API of `Expect` with this function. -In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) +In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) (`createAndAddAssertion` does the same under the hood) with a test which defines whether the assertion holds as well as a description (`IS_MULTIPLE_OF`) and a representation (`base`). -[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) helps you in writing own assertion functions. We suggest you use it as entry point (rather than memorizing different class names), it guides you to existing assertion function implementations for different types -as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) +as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) which in turn helps you with creating assertions. In the API module we define the extension function and call the impl-function: @@ -2335,17 +2334,17 @@ Both have their design focus on interoperability with code completion functional -- so that you can let your IDE do some of the work. Atrium is -[built up by different modules](https://docs.atriumlib.org/latest#/doc/) +[built up by different modules](https://docs.atriumlib.org/0.10.0/doc/) and it is your choice which implementation you want to use. However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.10.0/apis/differences.md) for more information and to see how the API styles differ. @@ -2360,15 +2359,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2422,13 +2421,13 @@ expect(sequenceOf(1, 2, 3)).feature { f(it::asIterable) }.contains(2) ## Where do I find a list of all available functions? Atrium provides KDoc for all APIs - have a look at their KDoc: -- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) -- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) Deprecated APIs: -- [atrium-api-cc-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-api-cc-en_UK](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) -- [atrium-api-cc-de_CH](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) +- [atrium-api-cc-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-api-cc-en_UK](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) +- [atrium-api-cc-de_CH](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) ## Problems in conjunction with `feature` @@ -2464,7 +2463,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/master/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/v0.10.0/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 1663e47f6..139c1f207 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,14 +14,14 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/0.10.0/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) +- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/0.10.0/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/v0.10.0/README.md#installation) for the rest): ``` dependencies { diff --git a/build.gradle b/build.gradle index 38ced6607..565411937 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - rootProject.version = '0.10.0-SNAPSHOT' + rootProject.version = '0.10.0' rootProject.group = 'ch.tutteli.atrium' def sampleProjectsFun = subprojects.findAll { @@ -530,7 +530,7 @@ Release & deploy a commit d) search for `latest#/doc` in all .md files and replace with `X.Y.Z/doc` e) use the release badges in README (comment out the ones for master and uncomment the ones for the release) f) comment out the warning in README.md about taking a sneak peak - g) commit & push (modified build.gradle, README.md, differences.md and example-pom.xml) + g) commit & push (modified CONTRIBUTING.md, differences.md, example-pom.xml, build.gradle and README.md) 2. update github pages: assumes you have a atrium-gh-pages folder on the same level as atrium where the gh-pages branch is checked out diff --git a/misc/maven/example-pom.xml b/misc/maven/example-pom.xml index b1abbf6fc..80d1f8658 100644 --- a/misc/maven/example-pom.xml +++ b/misc/maven/example-pom.xml @@ -5,7 +5,7 @@ com.example.artifactId - 0.9.2 + 0.10.0 diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 888ac9bb2..13be5942c 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index 35fcd84a6..8721d8ad7 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From 12115dca838472696b27c16372da90b34a4953f4 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 22:59:27 +0100 Subject: [PATCH 076/142] update samples, use new version 0.10.0 --- samples/js/jasmine/build.gradle | 2 +- samples/js/mocha/build.gradle | 2 +- samples/jvm/junit5/build.gradle | 2 +- samples/jvm/spek/build.gradle | 2 +- samples/multiplatform/build.gradle | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/js/jasmine/build.gradle b/samples/js/jasmine/build.gradle index 376ab9b1c..713b18b03 100644 --- a/samples/js/jasmine/build.gradle +++ b/samples/js/jasmine/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { atrium_api = 'atrium-fluent-en_GB-js' - atrium_version = '0.9.2' + atrium_version = '0.10.0' } repositories { maven { url "https://plugins.gradle.org/m2/" } diff --git a/samples/js/mocha/build.gradle b/samples/js/mocha/build.gradle index ff8e2c105..5ec788e75 100644 --- a/samples/js/mocha/build.gradle +++ b/samples/js/mocha/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { atrium_api = 'atrium-fluent-en_GB-js' - atrium_version = '0.9.2' + atrium_version = '0.10.0' } repositories { maven { url "https://plugins.gradle.org/m2/" } diff --git a/samples/jvm/junit5/build.gradle b/samples/jvm/junit5/build.gradle index ed0fdcc3f..089d07c83 100644 --- a/samples/jvm/junit5/build.gradle +++ b/samples/jvm/junit5/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { kotlin_version= '1.3.41' atrium_api= 'atrium-fluent-en_GB' - atrium_version='0.9.2' + atrium_version='0.10.0' junit_version= '5.3.1' } diff --git a/samples/jvm/spek/build.gradle b/samples/jvm/spek/build.gradle index 1b6b5d369..df347e9f4 100644 --- a/samples/jvm/spek/build.gradle +++ b/samples/jvm/spek/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { kotlin_version = '1.3.41' spek_version = '2.0.0' - atrium_version='0.9.2' + atrium_version='0.10.0' } repositories { diff --git a/samples/multiplatform/build.gradle b/samples/multiplatform/build.gradle index 42f888f8d..b5ac5b028 100644 --- a/samples/multiplatform/build.gradle +++ b/samples/multiplatform/build.gradle @@ -10,7 +10,7 @@ version '0.0.1' apply plugin: 'maven-publish' kotlin { - def atrium_version = '0.9.2' + def atrium_version = '0.10.0' jvm() js { nodejs {} From 17f20b4ce34edf3fc99107f9e661d87c2faf4351 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 23:04:03 +0100 Subject: [PATCH 077/142] prepare v0.11.0 dev cycle --- .github/CONTRIBUTING.md | 2 +- README.md | 221 ++++++++++++++++++----------------- apis/differences.md | 8 +- build.gradle | 9 +- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 6 files changed, 124 insertions(+), 124 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5dd44ff17..06c974647 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/v0.10.0/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/naster/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index 013d9bebe..ccf11a5f8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - - + + # Atrium Atrium is an open-source multiplatform assertion library for Kotlin with support for JVM, JS and Android. @@ -29,12 +30,12 @@ Atrium currently provides two [API Styles](#api-styles): pure fluent and infix where both of them have their design focus on usability in conjunction with code completion functionality provided by your IDE. See [Examples](#examples) below to get a feel for how you could benefit from Atrium. - +---- **Table of Content** - [Installation](#installation) @@ -143,9 +144,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/v0.10.0/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/naster/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/v0.10.0/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/naster/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -174,24 +175,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/v0.10.0/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/naster/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/v0.10.0/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/naster/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/v0.10.0/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/naster/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -249,11 +250,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.10.0/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/naster/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -268,7 +269,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -281,7 +282,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -310,7 +311,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -342,7 +343,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -373,7 +374,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -408,7 +409,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -428,7 +429,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -451,7 +452,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -471,7 +472,7 @@ expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1 Notice that stacks are filtered so that you only see what is of interest. Filtering can be configured via [`ReporterBuilder`](#reporterbuilder) by choosing an appropriate -[AtriumErrorAdjuster](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). +[AtriumErrorAdjuster](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-atrium-error-adjuster/index.html). Stack frames of Atrium and of test runners (Spek, Kotlintest and JUnit for JVM, mocha for JS) are excluded per default. [Create a Feature Request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]) in case you use a different runner, we can add yours to the list as well. @@ -504,7 +505,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -556,7 +557,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -606,7 +607,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -636,7 +637,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)
@@ -658,7 +659,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -704,7 +705,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -790,7 +791,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -811,7 +812,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -839,7 +840,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -852,7 +853,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -872,7 +873,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -888,7 +889,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -923,7 +924,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -942,7 +943,7 @@ This is reflected in the output, which tells us that we expected that the `numbe Exactly, what about the expected value `2`, why do we not see anything about it in the output? The output does not show anything about the expected value `2` because the predefined assertion verbs have configured [`ReporterBuilder`](#reporterbuilder) -to use an [Only Failure Reporter](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) +to use an [Only Failure Reporter](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.core/-core-factory/new-only-failure-reporter.html) which shows us only assertions (or sub assertions) which failed. Back to the shortcut functions. @@ -963,7 +964,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1002,7 +1003,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1018,7 +1019,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1036,7 +1037,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1065,7 +1066,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1115,7 +1116,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1139,7 +1140,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1155,7 +1156,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1175,7 +1176,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1197,7 +1198,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1223,7 +1224,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1254,7 +1255,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1273,7 +1274,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1309,7 +1310,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1333,7 +1334,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) `isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry`. There are more assertion functions, a full list can be found in -[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). +[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html). In case you should miss an assertion function, then please [open a feature request](https://github.com/robstoll/atrium/issues/new?template=feature_request.md&title=[Feature]). @@ -1350,7 +1351,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1365,7 +1366,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1387,7 +1388,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1424,7 +1425,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1458,7 +1459,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1498,7 +1499,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1516,11 +1517,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/v0.10.0/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/naster/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/v0.10.0/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/naster/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1554,7 +1555,7 @@ We try to provide a workaround whenever possible._ There is, but IntelliJ will not show it to you due to [this bug](https://youtrack.jetbrains.com/issue/KT-24836) (please upvote it). You should be able to see the KDoc of other functions without problems. -But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). +But in case, you can also browse the online documentation, e.g. [KDoc of toBe](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/to-be.html). @@ -1627,7 +1628,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1669,7 +1670,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1686,7 +1687,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1762,7 +1763,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1777,9 +1778,9 @@ Let us see how we actually defined `isMultipleOf`. the assertion to itself (creating alone is not enough, it needs to be added in order that it is evaluated). The method `createAndAddAssertion` returns itself (the same `Expect`) making it easy for you to provide a fluent API as well. - The method [createAndAddAssertion](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) + The method [createAndAddAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.creating/-assertion-plant/create-and-add-assertion.html) expects: - - a either a `String` or a [Translatable](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) + - a either a `String` or a [Translatable](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translatable/index.html) as description of your assertion. - the representation of the expected value. - and the actual check as lambda where you typically use `it` which refers to the subject of the assertion. @@ -1802,7 +1803,7 @@ fun Expect.isEven() = ``` -We are using a [RawString](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) +We are using a [RawString](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting/-raw-string/index.html) here so that `"an even number"` is not treated as a `String` in reporting. Its usage looks then as follows: @@ -1811,7 +1812,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1910,7 +1911,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1942,7 +1943,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1983,7 +1984,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/v0.10.0/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2044,7 +2045,7 @@ fun >> Expect.sameInitialsAs( There are a few additional methods which you can call after `mapArguments`. -See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). +See [KDoc of ArgumentMapperBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders.utils/-argument-mapper-builder/index.html). In case you want to provide your own implementation it suffices to create an extension function for `ArgumentMapperBuilder`. @@ -2054,21 +2055,21 @@ extension function for `ArgumentMapperBuilder`. Yet, sometimes we would like to create functions which have a better error reporting than the one we get when we compose assertion functions. -[`ExpectImpl`](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) is the entry point in this case. Its a builder and thus lets you find the functions you need via code completion. Following a quick overview what it provides: - all assertion functions on the domain level (what you have seen in [Compose-assertion-functions](#compose-assertion-functions) was the API level) so that you can reuse and compose them in other ways. -- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). +- `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/naster/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/v0.10.0/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2080,7 +2081,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/v0.10.0/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/naster/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2094,7 +2095,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/v0.10.0/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/naster/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2135,7 +2136,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/naster/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2167,8 +2168,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/v0.10.0/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/naster/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/naster/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2198,24 +2199,24 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/naster/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
💬 Using a TranslationSupplier Next to providing translations via code you can also use a -[TranslationSupplier](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) -based [Translator](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) +[TranslationSupplier](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translation-supplier/index.html) +based [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html) by configuring the [`ReporterBuilder`](#reporterbuilder) accordingly (e.g. use `withDefaultTranslationSupplier` instead of `withoutTranslations`). Atrium supports a properties files based `TranslationSupplier` for JVM (a supplier for JS will follow) which is more or less what [ResourceBundle](https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html) provides out of the box. Yet, a `Translator` uses a more enhanced fallback mechanism compared to a `ResourceBundle`. -For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). +For further technical information have a look at the KDoc of [Translator](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.reporting.translating/-translator/index.html). Notice though, that we plan to move away from the `ResourceBundle`-inspired approach due to enconding problems and missing implementations on other platforms than JVM. @@ -2274,15 +2275,15 @@ fun _isMultipleOf(container: Expect, base: Int): Assertion = Notice that the impl-function is not an extension function as before because we do not want to pollute the API of `Expect` with this function. -In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) +In the above example we created a simple [DescriptiveAssertion](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions/-descriptive-assertion/index.html) (`createAndAddAssertion` does the same under the hood) with a test which defines whether the assertion holds as well as a description (`IS_MULTIPLE_OF`) and a representation (`base`). -[`ExpectImpl`](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) +[`ExpectImpl`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.domain.builders/-expect-impl/index.html) helps you in writing own assertion functions. We suggest you use it as entry point (rather than memorizing different class names), it guides you to existing assertion function implementations for different types -as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) +as well as to other builders such as the [`AssertionBuilder`](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) which in turn helps you with creating assertions. In the API module we define the extension function and call the impl-function: @@ -2334,17 +2335,17 @@ Both have their design focus on interoperability with code completion functional -- so that you can let your IDE do some of the work. Atrium is -[built up by different modules](https://docs.atriumlib.org/0.10.0/doc/) +[built up by different modules](https://docs.atriumlib.org/latest#/doc/) and it is your choice which implementation you want to use. However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/v0.10.0/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/v0.10.0/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/naster/apis/differences.md) for more information and to see how the API styles differ. @@ -2359,15 +2360,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/v0.10.0/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2421,13 +2422,13 @@ expect(sequenceOf(1, 2, 3)).feature { f(it::asIterable) }.contains(2) ## Where do I find a list of all available functions? Atrium provides KDoc for all APIs - have a look at their KDoc: -- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) -- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-api-cc-infix-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) Deprecated APIs: -- [atrium-api-cc-en_GB](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-api-cc-en_UK](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) -- [atrium-api-cc-de_CH](https://docs.atriumlib.org/0.10.0/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) +- [atrium-api-cc-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-api-cc-en_UK](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.en_-u-k/index.html) +- [atrium-api-cc-de_CH](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.cc.de_-d-e/index.html) ## Problems in conjunction with `feature` @@ -2463,7 +2464,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/v0.10.0/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/naster/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 139c1f207..0f57f69b4 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,14 +14,14 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/0.10.0/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/0.10.0/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/0.10.0/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) +- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) +- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/v0.10.0/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/naster/README.md#installation) for the rest): ``` dependencies { diff --git a/build.gradle b/build.gradle index 565411937..ea24299fe 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - rootProject.version = '0.10.0' + rootProject.version = '0.11.0-SNAPSHOT' rootProject.group = 'ch.tutteli.atrium' def sampleProjectsFun = subprojects.findAll { @@ -560,10 +560,9 @@ Prepare next dev cycle a) search for `tree/vX.Y.Z` in all .md files and replace it with `tree/master` b) search for `X.Y.Z/doc` in all .md files and replace with `latest#/doc` c) use the master badges in README (uncomment them in README and comment out release badges) - d) uncomment the warning about taking a sneak peek in README - e) update version in the warning to X.Y.Z and update the link as well (if not already correct) - f) change rootProject.version in build.gradle to X.Y.Z-SNAPSHOT - g) commit & push changes + d) uncomment the warning about taking a sneak peek in README and revert `tree/master` still point to the tag + e) change rootProject.version in build.gradle to X.Y.Z-SNAPSHOT + f) commit & push changes 3. establish backward compatibility tests for the previous version a) add new version at the end of atrium-bc-test/build.gradle diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 13be5942c..3124fc51c 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index 8721d8ad7..70bc160be 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/v0.10.0/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From 1535807a3bde4ed6987b3870e2c442039b405b96 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 23:18:56 +0100 Subject: [PATCH 078/142] establish bc/bbc tests for 0.10.0 --- misc/tools/atrium-bc-test/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/misc/tools/atrium-bc-test/build.gradle b/misc/tools/atrium-bc-test/build.gradle index df1da500a..5a6c86c5d 100644 --- a/misc/tools/atrium-bc-test/build.gradle +++ b/misc/tools/atrium-bc-test/build.gradle @@ -6,6 +6,7 @@ description = 'Checks that specs from older versions of Atrium can still be run with the components of the current version.' repositories { + mavenLocal() maven { url "https://dl.bintray.com/jetbrains/spek" } } @@ -373,6 +374,10 @@ createBcAndBbcTasksForApis('0.9.2', 'forgive=^$', 'fluent-en_GB' ) +createBcAndBbcTasksForApis('0.10.0', + 'forgive=^$', + 'fluent-en_GB' +) //@formatter:on def apis = ['cc-de_CH', 'cc-en_GB', 'cc-infix-en_GB'] From 097d53d783a9fbaae0cfdeceee9aa49cf4d28bc5 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 23:22:56 +0100 Subject: [PATCH 079/142] remove mavenLocal repositories from build.gradle files --- misc/tools/atrium-bc-test/build.gradle | 1 - samples/js/jasmine/build.gradle | 1 - samples/js/mocha/build.gradle | 1 - samples/jvm/spek/build.gradle | 3 --- 4 files changed, 6 deletions(-) diff --git a/misc/tools/atrium-bc-test/build.gradle b/misc/tools/atrium-bc-test/build.gradle index 5a6c86c5d..8ebbf4427 100644 --- a/misc/tools/atrium-bc-test/build.gradle +++ b/misc/tools/atrium-bc-test/build.gradle @@ -6,7 +6,6 @@ description = 'Checks that specs from older versions of Atrium can still be run with the components of the current version.' repositories { - mavenLocal() maven { url "https://dl.bintray.com/jetbrains/spek" } } diff --git a/samples/js/jasmine/build.gradle b/samples/js/jasmine/build.gradle index 713b18b03..8f71a0561 100644 --- a/samples/js/jasmine/build.gradle +++ b/samples/js/jasmine/build.gradle @@ -18,7 +18,6 @@ apply plugin: 'com.moowork.node' repositories { jcenter() - mavenLocal() // either use jcenter or the repository on the next line // maven { url "https://dl.bintray.com/robstoll/tutteli-jars" } } diff --git a/samples/js/mocha/build.gradle b/samples/js/mocha/build.gradle index 5ec788e75..9e5221e05 100644 --- a/samples/js/mocha/build.gradle +++ b/samples/js/mocha/build.gradle @@ -18,7 +18,6 @@ apply plugin: 'com.moowork.node' repositories { jcenter() - mavenLocal() // either use jcenter or the repository on the next line // maven { url "https://dl.bintray.com/robstoll/tutteli-jars" } } diff --git a/samples/jvm/spek/build.gradle b/samples/jvm/spek/build.gradle index df347e9f4..5efb4a008 100644 --- a/samples/jvm/spek/build.gradle +++ b/samples/jvm/spek/build.gradle @@ -26,9 +26,6 @@ apply plugin: 'kotlin' repositories { // atrium jvm installation: more info here -> https://github.com/robstoll/atrium#jvm jcenter() - - // dependencies for spek - mavenLocal() } // setup the test task From c6dc9dba608aed03729bab798ede52db09317306 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 12 Mar 2020 23:34:43 +0100 Subject: [PATCH 080/142] add jcenter to mpp sample because it takes to long until a new version of Atrium is published to maven central --- samples/multiplatform/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/multiplatform/build.gradle b/samples/multiplatform/build.gradle index b5ac5b028..ba0777a94 100644 --- a/samples/multiplatform/build.gradle +++ b/samples/multiplatform/build.gradle @@ -3,6 +3,7 @@ plugins { } repositories { mavenCentral() + jcenter() } group 'com.atrium' version '0.0.1' From 8db7c9e5a3fa4b38f5c5b6736344268ce093358a Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 13 Mar 2020 15:02:41 +0100 Subject: [PATCH 081/142] exclude smokeTest of extensions from publishing and add spek2 dep we also need to add the spek2 dep to the smokeTests of bundles --- build.gradle | 58 +++++++++++++------ .../build.gradle | 1 - .../build.gradle | 1 - 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index ea24299fe..43d5fab3d 100644 --- a/build.gradle +++ b/build.gradle @@ -260,7 +260,7 @@ configure(apiProjects) { apiProject -> createTestSourcesJarTask(apiProject) } -def bundleSmokeTests = subprojects.findAll { it.name.endsWith('smoke-test') } +def bundleSmokeTests = subprojects.findAll { it.name.contains('-smoke-test') } //TODO new infix API: remove once we are ready to publish the new API def newInfixApiModules = subprojects.findAll { it.name.contains('-api-infix') } @@ -328,25 +328,49 @@ apply from: 'gradle/scripts/gh-pages.gradle' apply from: 'gradle/scripts/jacoco-multi-project.gradle' configure(bundleSmokeTests) { - def bundleUnderTest = it.name.substring(0, it.name.indexOf('-smoke-test')) - Project bundle = project(":$bundleUnderTest-jvm") - description = "Represents a JDK >= 9 smoke test for $bundleUnderTest" - - sourceCompatibility = JavaVersion.current() - targetCompatibility = JavaVersion.current() - - ext.jacoco_additional = [bundle] - - sourceSets { - // we are reusing the source from the bundle, so that we do not have to re-invent the spec - test { kotlin { srcDirs += ["${bundle.projectDir}/src/test/kotlin"] } } + //TODO dependencies no longer required once all specs are with spek2 where they are set via spek plugin + def spekDep = { closure -> + delegate = closure + testRuntimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek2_version", excludeKotlin + testRuntimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek2_version", excludeKotlin } - dependencies { - //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead - testImplementation bundle - testImplementation prefixedProject('verbs-jvm') + def suffix = "-smoke-test" + def isABundleAndNotExtensionSmokeTest = it.name.endsWith(suffix) + if (isABundleAndNotExtensionSmokeTest) { + def bundleUnderTest = it.name.substring(0, it.name.indexOf(suffix)) + Project bundle = project(":$bundleUnderTest-jvm") + + description = "Represents a JDK >= 9 smoke test for $bundleUnderTest" + + sourceCompatibility = JavaVersion.current() + targetCompatibility = JavaVersion.current() + + ext.jacoco_additional = [bundle] + + sourceSets { + // we are reusing the source from the bundle, so that we do not have to re-invent the spec + test { kotlin { srcDirs += ["${bundle.projectDir}/src/test/kotlin"] } } + } + + dependencies { + //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead + testImplementation bundle + //TODO remove once all specs are with spek2 where they are set via spek plugin + spekDep(delegate) + } + //TODO remove once all specs are with spek2 where they are set via spek plugin + bundle.dependencies { + spekDep(delegate) + } + } else { + //TODO remove once all specs are with spek2 where they are set via spek plugin + dependencies { + spekDep(delegate) + } } } diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/build.gradle b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/build.gradle index c35f7feb8..6e6d2fa96 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/build.gradle +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/build.gradle @@ -7,5 +7,4 @@ dependencies { //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead testImplementation prefixedProject('fluent-en_GB-jvm') testImplementation prefixedProject('api-fluent-en_GB-jdk8-jvm') - testImplementation prefixedProject('verbs-jvm') } diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle index ef0e94c2e..cf6eddc31 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle @@ -7,5 +7,4 @@ dependencies { //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead testImplementation prefixedProject('fluent-en_GB-jvm') testImplementation prefixedProject('api-fluent-en_GB-kotlin_1_3-jvm') - testImplementation prefixedProject('verbs-jvm') } From e79fc65b4685adedfac74bde51ee6f8cc56618e4 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 13 Mar 2020 17:32:48 +0100 Subject: [PATCH 082/142] fix dependencies for api-fluent..-android, addd spek2 --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index 43d5fab3d..2ea6bd718 100644 --- a/build.gradle +++ b/build.gradle @@ -366,6 +366,10 @@ configure(bundleSmokeTests) { bundle.dependencies { spekDep(delegate) } + //TODO remove once all specs are with spek2 where they are set via spek plugin + project(":$bundleUnderTest-android").dependencies { + spekDep(delegate) + } } else { //TODO remove once all specs are with spek2 where they are set via spek plugin dependencies { From 5892456d32f61082f94e396af840186f132e4727 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 13 Mar 2020 17:46:08 +0100 Subject: [PATCH 083/142] fix of the fix, not all bundles are MPP projects --- build.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2ea6bd718..8cadf761a 100644 --- a/build.gradle +++ b/build.gradle @@ -367,8 +367,10 @@ configure(bundleSmokeTests) { spekDep(delegate) } //TODO remove once all specs are with spek2 where they are set via spek plugin - project(":$bundleUnderTest-android").dependencies { - spekDep(delegate) + if(!it.name.contains("-cc-")) { + project(":$bundleUnderTest-android").dependencies { + spekDep(delegate) + } } } else { //TODO remove once all specs are with spek2 where they are set via spek plugin From f36378721bd9e1b312ced0688a5e7b46b564c3d8 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 13 Mar 2020 18:20:09 +0100 Subject: [PATCH 084/142] also build android project in GitHub actions --- .github/workflows/java-windows.yml | 2 ++ build.gradle | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/java-windows.yml b/.github/workflows/java-windows.yml index 775eb07e3..71372da19 100644 --- a/.github/workflows/java-windows.yml +++ b/.github/workflows/java-windows.yml @@ -18,6 +18,8 @@ jobs: java-version: ${{ matrix.java_version }} - name: Build buildNonDeprecatedJvm run: ./gr buildNonDeprecatedJvm + env: + CI: true - name: build sample atrium+spek project run: samples\jvm\spek\gradlew -p samples\jvm\spek build diff --git a/build.gradle b/build.gradle index 8cadf761a..d451af823 100644 --- a/build.gradle +++ b/build.gradle @@ -367,7 +367,7 @@ configure(bundleSmokeTests) { spekDep(delegate) } //TODO remove once all specs are with spek2 where they are set via spek plugin - if(!it.name.contains("-cc-")) { + if (!it.name.contains("-cc-") && System.getenv('CI')) { project(":$bundleUnderTest-android").dependencies { spekDep(delegate) } From 91e7332f51f4b8d6153ec6d2b62721ed6814bd43 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 14 Mar 2020 21:32:04 +0100 Subject: [PATCH 085/142] add spek2 dependency directly to bundle configuring via smoke-test was a bad idea as they are only activated with jdk >= 9 (so not for jdk8) --- build.gradle | 29 +++++++------------ .../atrium-fluent-en_GB-android/build.gradle | 3 ++ .../atrium-fluent-en_GB-jvm/build.gradle | 3 ++ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index d451af823..ee3fdcf71 100644 --- a/build.gradle +++ b/build.gradle @@ -99,6 +99,16 @@ buildscript { } } } + + //TODO dependencies no longer required once all specs are with spek2 where they are set via spek plugin + spekDep = { closure -> + delegate = closure + testRuntimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek2_version", excludeKotlin + testRuntimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek2_version", excludeKotlin + } + } repositories { @@ -329,15 +339,6 @@ apply from: 'gradle/scripts/jacoco-multi-project.gradle' configure(bundleSmokeTests) { - //TODO dependencies no longer required once all specs are with spek2 where they are set via spek plugin - def spekDep = { closure -> - delegate = closure - testRuntimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek2_version", excludeKotlin - testRuntimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek2_version", excludeKotlin - } - def suffix = "-smoke-test" def isABundleAndNotExtensionSmokeTest = it.name.endsWith(suffix) if (isABundleAndNotExtensionSmokeTest) { @@ -362,16 +363,6 @@ configure(bundleSmokeTests) { //TODO remove once all specs are with spek2 where they are set via spek plugin spekDep(delegate) } - //TODO remove once all specs are with spek2 where they are set via spek plugin - bundle.dependencies { - spekDep(delegate) - } - //TODO remove once all specs are with spek2 where they are set via spek plugin - if (!it.name.contains("-cc-") && System.getenv('CI')) { - project(":$bundleUnderTest-android").dependencies { - spekDep(delegate) - } - } } else { //TODO remove once all specs are with spek2 where they are set via spek plugin dependencies { diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-android/build.gradle b/bundles/fluent-en_GB/atrium-fluent-en_GB-android/build.gradle index e1802eff2..1896f706c 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-android/build.gradle +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-android/build.gradle @@ -10,6 +10,9 @@ dependencies { runtimeOnly prefixedProject('domain-robstoll-android') runtimeOnly prefixedProject('core-robstoll-android') + + //TODO remove once all specs are with spek2 where they are set via spek plugin + spekDep(delegate) } srcAndResourcesFromJvmProject(project) diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle index d56d7f4c5..7b58b830f 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle @@ -10,4 +10,7 @@ dependencies { runtimeOnly prefixedProject('domain-robstoll-jvm') runtimeOnly prefixedProject('core-robstoll-jvm') + + //TODO remove once all specs are with spek2 where they are set via spek plugin + spekDep(delegate) } From 769401320ea0ede17234369d81227ab39c4e4ad1 Mon Sep 17 00:00:00 2001 From: assaflei Date: Fri, 13 Mar 2020 12:46:46 +0200 Subject: [PATCH 086/142] Migrate smoke tests to spek2 at fluent-en_GB --- .../src/test/kotlin/custom/SmokeSpec.kt | 3 ++- .../src/test/kotlin/custom/SmokeSpec.kt | 3 ++- .../src/test/kotlin/custom/SmokeSpec.kt | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt index 560c07ec6..c373c5b01 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt @@ -8,7 +8,8 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic -import org.jetbrains.spek.api.Spek +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe object SmokeSpec : Spek({ test("see if `toBe` can be used") { diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt index 70b242cd2..98766434b 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt @@ -9,7 +9,8 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic -import org.jetbrains.spek.api.Spek +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe import java.nio.file.Paths object SmokeSpec : Spek({ diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt index 2e7254ee7..9cb91619c 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt @@ -8,7 +8,8 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic -import org.jetbrains.spek.api.Spek +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe object SmokeSpec : Spek({ test("see if `toBe` can be used") { From 58a818f1a77e44a628eb4115b35b2fa6a25860c1 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 14 Mar 2020 21:51:12 +0100 Subject: [PATCH 087/142] adjust module-info in SmokeTests (due to kotlin bug not detected) --- .../src/test/kotlin/module-info.java | 2 +- .../src/test/kotlin/module-info.java | 2 +- .../src/test/kotlin/module-info.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-smoke-test/src/test/kotlin/module-info.java b/bundles/fluent-en_GB/atrium-fluent-en_GB-smoke-test/src/test/kotlin/module-info.java index f78ea6879..a3a67b621 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-smoke-test/src/test/kotlin/module-info.java +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-smoke-test/src/test/kotlin/module-info.java @@ -5,5 +5,5 @@ module ch.tutteli.atrium.fluent.en_GB.smoke { requires ch.tutteli.atrium.fluent.en_GB; requires kotlin.stdlib; - requires spek.api; + requires spek.dsl.jvm; } diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java index 98e210c6a..9b7496264 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java @@ -6,5 +6,5 @@ module ch.tutteli.atrium.fluent.en_GB.jdk8.smoke { requires ch.tutteli.atrium.fluent.en_GB; requires ch.tutteli.atrium.api.fluent.en_GB.jdk8; requires kotlin.stdlib; - requires spek.api; + requires spek.dsl.jvm; } diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java index ca6d9915e..d18cc3696 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java @@ -6,5 +6,5 @@ module ch.tutteli.atrium.fluent.en_GB.kotlin_1_3.smoke { requires ch.tutteli.atrium.fluent.en_GB; requires ch.tutteli.atrium.api.fluent.en_GB.kotlin_1_3; requires kotlin.stdlib; - requires spek.api; + requires spek.dsl.jvm; } From a46d9012b5e4a64f801d9729c11a7d8686db38d2 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 14 Mar 2020 21:57:23 +0100 Subject: [PATCH 088/142] document kotlin 1.3 extension requires dep on domain-robstoll-kotlin_1_3 And use isSuccess in SmokeSpec (revealed that the current documentation is not good enough). --- README.md | 2 ++ .../atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle | 1 + .../src/test/kotlin/custom/SmokeSpec.kt | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ccf11a5f8..9e8b02ea6 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ You can enable them as follows: dependencies { testImplementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-jdk8:$atrium_version" testImplementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-kotlin_1_3:$atrium_version" + testRuntimeOnly "ch.tutteli.atrium:atrium-domain-robstoll-kotlin_1_3:$atrium_version" } ``` @@ -202,6 +203,7 @@ You can enable them as follows: ``` dependencies { testImplementation "ch.tutteli.atrium:atrium-api-fluent-en_GB-kotlin_1_3-js:$atrium_version" + testRuntimeOnly "ch.tutteli.atrium:atrium-domain-robstoll-kotlin_1_3-js:$atrium_version" } ``` diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle index cf6eddc31..f0f65dfa3 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/build.gradle @@ -7,4 +7,5 @@ dependencies { //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead testImplementation prefixedProject('fluent-en_GB-jvm') testImplementation prefixedProject('api-fluent-en_GB-kotlin_1_3-jvm') + testRuntimeOnly prefixedProject('domain-robstoll-kotlin_1_3-jvm') } diff --git a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt index 9cb91619c..75f7f41c6 100644 --- a/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt +++ b/bundles/fluent-en_GB/extensions/atrium-fluent-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt @@ -1,5 +1,8 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + package custom +import ch.tutteli.atrium.api.fluent.en_GB.kotlin_1_3.isSuccess import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.expect import ch.tutteli.atrium.assertions.Assertion @@ -9,7 +12,6 @@ import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.translations.DescriptionBasic import org.spekframework.spek2.Spek -import org.spekframework.spek2.style.specification.describe object SmokeSpec : Spek({ test("see if `toBe` can be used") { @@ -17,8 +19,7 @@ object SmokeSpec : Spek({ } test("see if `Result.isSuccess` can be used") { - //TODO activate after isSuccess is implemented - //expect(Result.success(1)).isSuccess { toBe(1) } + expect(Result.success(1)).isSuccess { toBe(1) } } test("see if own assertion function without i18n can be used") { From b5556940794c2a6ecfc3d715b31ab07980721294 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 14 Mar 2020 21:59:34 +0100 Subject: [PATCH 089/142] fix typo in URLs, tree/master instead of tree/naster --- .github/CONTRIBUTING.md | 2 +- README.md | 166 +++++++++++++++++------------------ apis/differences.md | 2 +- gradle/package-lock.json | 6 +- samples/js/jasmine/README.md | 4 +- samples/js/mocha/README.md | 4 +- 6 files changed, 92 insertions(+), 92 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 06c974647..89b3d0185 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu ## Code of Conduct This project and everyone participating in it is governed by Atrium's -[Code of Conduct](https://github.com/robstoll/atrium/tree/naster/.github/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/robstoll/atrium/tree/master/.github/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@tutteli.ch ## How to Contribute diff --git a/README.md b/README.md index 9e8b02ea6..45d513af0 100644 --- a/README.md +++ b/README.md @@ -145,9 +145,9 @@ dependencies { *maven*: Because maven is a bit more verbose than gradle, the example is not listed here but -a [settings.xml](https://github.com/robstoll/atrium/tree/naster/misc/maven/settings.xml) +a [settings.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/settings.xml) is provided to set up the repository as well as an -[example-pom.xml](https://github.com/robstoll/atrium/tree/naster/misc/maven/example-pom.xml) +[example-pom.xml](https://github.com/robstoll/atrium/tree/master/misc/maven/example-pom.xml) which includes the necessary dependencies. That is all, you are all set. Jump to [Examples](#examples) which shows how to use Atrium. @@ -176,24 +176,24 @@ which provides a pure fluent API (in en_GB) for the JS platform. You need to setup an explicit dependency on `atrium-fluent-en_GB-js` in your test code in order that you can use Atrium. This is due to the loosely coupled design of Atrium and dead code elimination performed by the Kotlin compiler for JS. An example of how to setup Atrium in combination with the testing framework mocha is given in -[samples/js/mocha](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha). +[samples/js/mocha](https://github.com/robstoll/atrium/tree/master/samples/js/mocha). It also includes an automated way of establishing the dependency to Atrium. Atrium itself is using mocha as well -(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/naster/build.gradle#L290)) +(see [build.gradle -> createJsTestTask](https://github.com/robstoll/atrium/tree/master/build.gradle#L290)) and has tests written in JS modules -(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/naster/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) -as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) +(see [AdjustStackTest](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AdjustStackTest.kt)) +as well as tests written in common modules (e.g. [SmokeTest](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt)) which are executed on the JS platform as well (actually on all platforms -> JVM uses JUnit for this purpose, see -[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/naster/build.gradle#L342)). +[build.gradle -> useJupiter](https://github.com/robstoll/atrium/tree/master/build.gradle#L342)). Further examples for other test frameworks can be found in the [kotlin-examples repo](https://github.com/JetBrains/kotlin-examples/blob/master/gradle/js-tests). Notice though, that they do not include the automated setup of a dependency to a bundle of Atrium. Or in other words, you should at least create a gradle task similar to -[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L85) -or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L80)) +[establishDependencyToAtrium](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L85) +or include a [testSetup.kt]((https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L80)) file in your test sources. We currently provide the following extensions for the JS platform: @@ -252,11 +252,11 @@ Have a look at [JVM](#jvm), [JS](#js) or [Android](#android) to see how the setu # Examples We are using the API provided by the bundle module -[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +[atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) in the following examples. It provides a pure fluent API for the JVM platform. Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/naster/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) to see how the infix API looks like, how they differ respectively. ## Your First Assertion @@ -271,7 +271,7 @@ import ch.tutteli.atrium.api.verbs.expect val x = 10 expect(x).toBe(9) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L47)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ equals: 9 (kotlin.Int <1234789>) @@ -284,7 +284,7 @@ where `◆ ...` represents a single assertion for the subject (`10` in the above In this sense the report can be read as `I expected that the subject of the assertion, which is 10, equals 9` -- and needless to say, this assertion is wrong and thus the thrown error. -We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) +We are using the bundle [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle) and the predefined assertion verb `expect` in the examples. Thus the corresponding `import`s at the beginning of the file in the above example. We will omit the `import` statements in the remaining examples for brevity. @@ -313,7 +313,7 @@ The next section shows how you can define multiple assertions for the same subje // two single assertions, only first evaluated expect(4 + 6).isLessThan(5).isGreaterThan(10) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L54)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -345,7 +345,7 @@ expect(4 + 6) { isGreaterThan(10) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L59)Output ```text expected that subject: 10 (kotlin.Int <1234789>) ◆ is less than: 5 (kotlin.Int <1234789>) @@ -376,7 +376,7 @@ expect { throw IllegalArgumentException("name is empty") }.toThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L67)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$4$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -411,7 +411,7 @@ expect { throw IllegalArgumentException() }.toThrow().message.startsWith("firstName") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L74)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$5$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -431,7 +431,7 @@ expect { message { startsWith("firstName") } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L80)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$6$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -454,7 +454,7 @@ expect { throw IllegalArgumentException("name is empty", RuntimeException("a cause")) }.notToThrow() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L88)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec$1$7$1 <1234789>) ◆ does not: throw when called @@ -507,7 +507,7 @@ expect(myPerson) .feature { f(it::fullName) } // not evaluated anymore, subject String afterwards .startsWith("rob") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L107)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ isStudent: false @@ -559,7 +559,7 @@ Feature assertions follow the common pattern of having two overloads: feature { f(it::lastName) }.toBe("Dummy") } ``` - ↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output + ↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L116)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ firstName: "Robert" <1234789> @@ -609,7 +609,7 @@ expect(myPerson) .toBe("Robert aka. Stoll") // fails .startsWith("llotS") // not evaluated anymore ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L130)Output ```text expected that subject: Person(firstName=Robert, lastName=Stoll, isStudent=false) (readme.examples.ReadmeSpec$1$Person <1234789>) ◆ ▶ nickname(false): "Mr. Robert" <1234789> @@ -639,7 +639,7 @@ in case you miss a shortcut. 💬 Write own feature assertion functions with additional checks. Atrium provides a feature extractor which allows to make feature assertions in a safe way in case they are only valid for certain input. -See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt) +See `ExpectImpl.feature.extractor`. It is for instance used for [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)
@@ -661,7 +661,7 @@ expect(myFamily) .feature("first member's name") { members.first().name } // subject narrowed to String .toBe("Peter") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L147)Output ```text expected that subject: Family(members=[FamilyMember(name=Robert)]) (readme.examples.ReadmeSpec$1$Family <1234789>) ◆ ▶ first member's name: "Robert" <1234789> @@ -707,7 +707,7 @@ expect(listOf(1 to "a", 2 to "b")).get(10) { firstToBe(1) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L163)Output ```text expected that subject: [(1, a), (2, b)] (java.util.Arrays.ArrayList <1234789>) ◆ ▶ get(10): ❗❗ index out of bounds @@ -793,7 +793,7 @@ expect(x).isA() .feature { f(it::number) } .toBe(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L196)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ is instance of type: SubType1 (readme.examples.SubType1) @@ -814,7 +814,7 @@ expect(x).isA { feature { f(it::flag) }.toBe(false) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L202)Output ```text expected that subject: SubType2(word=hello, flag=true) (readme.examples.SubType2 <1234789>) ◆ ▶ word: "hello" <1234789> @@ -842,7 +842,7 @@ Let us look at the case where the subject of the assertion has a [nullable type] val slogan1: String? = "postulating assertions made easy" expect(slogan1).toBe(null) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L228)Output ```text expected that subject: "postulating assertions made easy" <1234789> ◆ equals: null @@ -855,7 +855,7 @@ expected that subject: "postulating assertions made easy" <1234789> val slogan2: String? = null expect(slogan2).toBe("postulating assertions made easy") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L232)Output ```text expected that subject: null ◆ equals: "postulating assertions made easy" <1234789> @@ -875,7 +875,7 @@ expect(slogan2) // subject has type String? .notToBeNull() // subject narrowed to String .startsWith("atrium") ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L237)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -891,7 +891,7 @@ one without (example above) and one with `assertionCreator`-lambda (example belo ```kotlin expect(slogan2).notToBeNull { startsWith("atrium") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L242)Output ```text expected that subject: null ◆ is instance of type: String (kotlin.String) -- Class: java.lang.String @@ -926,7 +926,7 @@ The following sub sections show both use cases by examples. ```kotlin expect(listOf(1, 2, 2, 4)).contains(2, 3) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L246)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -966,7 +966,7 @@ expect(listOf(1, 2, 2, 4)).contains( { isGreaterThan(2).isLessThan(4) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L250)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1005,7 +1005,7 @@ Following each in action: ```kotlin expect(listOf(1, 2, 3, 4)).any { isLessThan(0) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L257)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1021,7 +1021,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).none { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L260)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ does not contain: @@ -1039,7 +1039,7 @@ expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 3, 4)).all { isGreaterThan(2) } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L263)Output ```text expected that subject: [1, 2, 3, 4] (java.util.Arrays.ArrayList <1234789>) ◆ all entries: @@ -1068,7 +1068,7 @@ Following on the last section we will start with an `inOrder` example: ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.entries({ isLessThan(3) }, { isLessThan(2) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L267)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1118,7 +1118,7 @@ and we happily answer your question there. ```kotlin expect(listOf(1, 2, 2, 4)).contains.inOrder.only.values(1, 2, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L270)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in order: @@ -1142,7 +1142,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.atLeast(1).butAtMost(2).entries({ isLessThan(3) }) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L273)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains, in any order: @@ -1158,7 +1158,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(1, 2, 3, 4) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L276)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1178,7 +1178,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(listOf(1, 2, 2, 4)).contains.inAnyOrder.only.values(4, 3, 2, 2, 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L279)Output ```text expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789>) ◆ contains only, in any order: @@ -1200,7 +1200,7 @@ expected that subject: [1, 2, 2, 4] (java.util.Arrays.ArrayList <1234789> ```kotlin expect(mapOf("a" to 1, "b" to 2)).contains("c" to 2, "a" to 1, "b" to 1) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L283)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1226,7 +1226,7 @@ expect(mapOf("a" to 1, "b" to 2)).contains( KeyValue("b") { isLessThan(2) } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L286)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains, in any order: @@ -1257,7 +1257,7 @@ expect(mapOf("bernstein" to bernstein)) feature { f(it::firstName) }.toBe("Albert") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L298)Output ```text expected that subject: {bernstein=Person(firstName=Leonard, lastName=Bernstein, age=50)} (java.util.Collections.SingletonMap <1234789>) ◆ ▶ get("bernstein"): Person(firstName=Leonard, lastName=Bernstein, age=50) (readme.examples.ReadmeSpec2$1$Person <1234789>) @@ -1276,7 +1276,7 @@ expect(mapOf("a" to 1, "b" to 2)) { values { none { isGreaterThan(1) } } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L310)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ ▶ keys: [a, b] (java.util.LinkedHashMap.LinkedKeySet <1234789>) @@ -1312,7 +1312,7 @@ expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().contains.inOrder.only.entrie } ) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L316)Output ```text expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>) ◆ contains only, in order: @@ -1353,7 +1353,7 @@ For example, `exists` will explain which entry was the first one missing: ```kotlin expect(Paths.get("/usr/bin/noprogram")).exists() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L326)Output ```text expected that subject: /usr/bin/noprogram (sun.nio.fs.UnixPath <1234789>) ◆ to: exist @@ -1368,7 +1368,7 @@ Atrium will give details about why something cannot be accessed, for example whe ```kotlin expect(Paths.get("/root/.ssh/config")).isWritable() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L330)Output ```text expected that subject: /root/.ssh/config (sun.nio.fs.UnixPath <1234789>) ◆ equals: writable @@ -1390,7 +1390,7 @@ val filePointer = Files.createSymbolicLink(directory.resolve("directory"), file) expect(filePointer.resolve("subfolder/file")).isRegularFile() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L335)Output ```text expected that subject: /tmp/atrium-path/directory/subfolder/file (sun.nio.fs.UnixPath <1234789>) ◆ equals: a file @@ -1427,7 +1427,7 @@ expect("calling myFun with...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L348)Output ```text expected that subject: "calling myFun with..." <1234789> ◆ ▶ myFun(1): 'b' @@ -1461,7 +1461,7 @@ expect("calling myFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L362)Output ```text expected that subject: "calling myFun with ..." <1234789> ◆ ▶ myFun(3): 'd' @@ -1501,7 +1501,7 @@ expect("calling myNullableFun with ...") { } } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L380)Output ```text expected that subject: "calling myNullableFun with ..." <1234789> ◆ ▶ myNullableFun(-2147483648): null @@ -1519,11 +1519,11 @@ expected that subject: "calling myNullableFun with ..." <1234789> Atrium supports further assertion builders (e.g, for `CharSequence`) as well as assertion functions which have not been shown in the examples. -Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/naster/apis/differences.md) for a few more examples. +Have a look at [apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for a few more examples. This site contains also a list of all APIs with links to their assertion function catalogs. You can also have a look at the -[specifications](https://github.com/robstoll/atrium/tree/naster/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) +[specifications](https://github.com/robstoll/atrium/tree/master/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs) for more examples. # How is Atrium different from other Assertion Libraries @@ -1630,7 +1630,7 @@ expect { } }.toThrow { messageContains("no no no") } ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L404)Output ```text expected that subject: () -> kotlin.Nothing (readme.examples.ReadmeSpec2$1$31$1 <1234789>) ◆ ▶ thrown exception when called: java.lang.IllegalArgumentException @@ -1672,7 +1672,7 @@ then Atrium reminds us of the possible pitfall. For instance: ```kotlin expect(BigDecimal.TEN).isEqualIncludingScale(BigDecimal("10.0")) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L414)Output ```text expected that subject: 10 (java.math.BigDecimal <1234789>) ◆ is equal (including scale): 10.0 (java.math.BigDecimal <1234789>) @@ -1689,7 +1689,7 @@ For instance: ```kotlin expect(listOf(1)).get(0) {} ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L417)Output ```text expected that subject: [1] (java.util.Collections.SingletonList <1234789>) ◆ ▶ get(0): 1 (kotlin.Int <1234789>) @@ -1765,7 +1765,7 @@ and its usage: ```kotlin expect(12).isMultipleOf(5) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L429)Output ```text expected that subject: 12 (kotlin.Int <1234789>) ◆ is multiple of: 5 (kotlin.Int <1234789>) @@ -1814,7 +1814,7 @@ Its usage looks then as follows: ```kotlin expect(13).isEven() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L440)Output ```text expected that subject: 13 (kotlin.Int <1234789>) ◆ is: an even number @@ -1913,7 +1913,7 @@ Its usage is then as follows: expect(Person("Susanne", "Whitley", 43, listOf())) .hasNumberOfChildren(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L479)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1945,7 +1945,7 @@ but we do not have to, as `all` already checks that there is at least one elemen expect(Person("Susanne", "Whitley", 43, listOf())) .hasAdultChildren() ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L494)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[]) (readme.examples.Person <1234789>) ◆ ▶ children: [] (kotlin.collections.EmptyList <1234789>) @@ -1986,7 +1986,7 @@ expect(Person("Susanne", "Whitley", 43, listOf(Person("Petra", "Whitley", 12, li .children // using the val -> subsequent assertions are about children and fail fast .hasSize(2) ``` -↑ [Example](https://github.com/robstoll/atrium/tree/naster/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output +↑ [Example](https://github.com/robstoll/atrium/tree/master/samples/readme-examples/src/main/kotlin/readme/examples/ReadmeSpec.kt#L504)Output ```text expected that subject: Person(firstName=Susanne, lastName=Whitley, age=43, children=[Person(firstName=Petra, lastName=Whitley, age=12, children=[])]) (readme.examples.Person <1234789>) ◆ ▶ children: [Person(firstName=Petra, lastName=Whitley, age=12, children=[])] (java.util.Collections.SingletonList <1234789>) @@ -2066,12 +2066,12 @@ Following a quick overview what it provides: was the API level) so that you can reuse and compose them in other ways. - `ExpectImpl.builder` to create different kinds of assertions (see [AssertionBuilder](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.assertions.builders/-assertion-builder/index.html) for more information). - `ExpectImpl.changeSubject` which allows to change the subject either: - - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/naster/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) - - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) -- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) -- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) + - `unreported`; meaning it does not show up in reporting (e.g. `Expect>.asIterable()` uses it, see [arrayAssertions](https://github.com/robstoll/atrium/tree/master/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt#L17)) + - reported, using `reportBuilder`; meaning a subject transformation which is shown in reporting as it incorporates a transformation (e.g. `isA` uses it, see [anyAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/anyAssertions.kt#L62)) +- `ExpectImpl.collector` which allows to collect assertions - especially helpful in creating explanatory assertions (see [mapAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/mapAssertions.kt#L41)) +- `ExpectImpl.feature.extractor` for feature assertions which are not always save to extract (see [`List.get`](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/listAssertions.kt)) -You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/naster/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) +You can find an example in [floatingPointAssertions](https://github.com/robstoll/atrium/tree/master/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/floatingPointAssertions.kt#L33) which makes use of explanatory assertions as well as providing a failure hint. Unfortunately we do not have the time to cover all cases, so let us know if you want to know more @@ -2083,7 +2083,7 @@ Unfortunately we do not have the time to cover all cases, so let us know if you Do you want to write an own sophisticated assertion builder (or extend a current with more options) instead of an assertion function? Great, we do not provide hands on documentation yet (had only one question about it so far). Therefore, please have a look at the implementation, for instance how the sophisticated assertion builders for `Iterable` are defined: -[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/naster/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). +[ch.tutteli.atrium.creating.iterable.contains](https://github.com/robstoll/atrium/tree/master/domain/api/atrium-domain-api-common/src/main/kotlin/ch/tutteli/atrium/domain/creating/iterable/contains). Notice that the implementation supports [Internationalization](#internationalization-1). We are willing to provide more documentation if you need it (please open an issue). @@ -2097,7 +2097,7 @@ Atrium offers three assertion verbs out of the box: `expect`, `assert` and `asse But you can also define your own set of assertion verbs if they do not suite you or if you do not want that all of them are available in your classpath. In order to create an own assertion verb it is sufficient to: - 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/naster/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) + 1. Copy the file content of [atriumVerbs.kt](https://github.com/robstoll/atrium/tree/master/misc/verbs-internal/atrium-verbs-internal-common/src/main/kotlin/ch.tutteli.atrium.api.verbs.internal/atriumVerbs.kt) 2. Create your own atriumVerbs.kt and paste the previously copied content -- notice that you can also use a `String` for the assertion verb in case you do not care about [Internationalization](#internationalization-1) 3. Adjust package name and `import`s and rename `expect` as desired (you can also leave it that way of course). @@ -2138,7 +2138,7 @@ What are the drawbacks: The `ReporterBuilder` lets you choose among different options to configure the style of the reporting. For instance, in case you are not happy with the predefined bullet points, then you can change them via the `ReporterBuilder`. -Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/naster/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) +Have a look at [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt) where you can find an example. Or if you prefer multi-line reporting over single-line reporting, @@ -2170,8 +2170,8 @@ It does not matter if you use your [own assertion verb](#use-own-assertion-verbs You can provide your custom configured `Reporter` by providing a `ReporterFactory`. This is done via [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -mechanism on JVM and by calling `registerService` on JS where the call has to be before your tests run. -An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/naster/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). -An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/naster/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). +An example for JVM is given in [atriumVerbs.kt of atrium-api-infix-en_GB](https://github.com/robstoll/atrium/tree/master/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/testutils/AsciiBulletPointReporterFactory.kt). +An example of how you can make sure your code is called earlier than the tests run is given in [testSetup.kt of atrium-core-robstoll-lib](https://github.com/robstoll/atrium/tree/master/core/robstoll-lib/atrium-core-robstoll-lib-js/src/test/kotlin/testSetup.kt). # Internationalization @@ -2201,10 +2201,10 @@ enum class DescriptionIntAssertion(override val value: String) : StringBasedTran Typically you would put `DescriptionIntAssertion` into an own module (jar) so that it could be replaced (with zero performance cost) by another language representation. For instance, -[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +[atrium-fluent-en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) uses `atrium-translations-en_GB-common` whereas tests of -[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/naster/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) +[atrium-infix_en_GB-common](https://github.com/robstoll/atrium/tree/master/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle) uses `atrium-translations-de_CH-common`.
@@ -2343,11 +2343,11 @@ However, this is more intended for advanced user with special requirements. Atrium provides bundle modules which bundle API, translation, domain and core as well as predefined assertion verbs, so that you just have to have a dependency on one of those bundles (kind a bit like a BOM pom in the maven world): -- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) -- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/naster/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) +- [atrium-fluent-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/fluent-en_GB/atrium-fluent-en_GB-common/build.gradle) +- [atrium-cc-infix-en_GB](https://github.com/robstoll/atrium/tree/master/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle) Have a look at -[apis/differences.md](https://github.com/robstoll/atrium/tree/naster/apis/differences.md) +[apis/differences.md](https://github.com/robstoll/atrium/tree/master/apis/differences.md) for more information and to see how the API styles differ. @@ -2362,15 +2362,15 @@ Therefore you want to turn the platform type into the nullable version. You need to use a cast to do this. But depending on your return type this might be cumbersome especially if you deal with type parameters. Thus, Atrium provides the following functions to ease dealing with Java Code at least for some standard cases: -- [`nullable`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) +- [`nullable`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L19) turns a type into a nullable type. -- [`nullableContainer`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) +- [`nullableContainer`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#40) turns an `Iterable` into an iterable with nullable element type, likewise it does the same for `Array`. -- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) +- [`nullableKeyMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L66) turns a `Map` into a map with a nullable key type. -- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) +- [`nullableValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L79) turns a `Map` into a map with a nullable value type. -- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/naster/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) +- [`nullableKeyValueMap`](https://github.com/robstoll/atrium/tree/master/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/nullable.kt#L92) turns a `Map` into a map with a nullable key and nullable value type. @@ -2466,7 +2466,7 @@ You are more than welcome to contribute as well: if you would like to code (ping us on [Slack](https://kotlinlang.slack.com/messages/C887ZKGCQ) if there are not any). Please have a look at -[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/naster/.github/CONTRIBUTING.md) +[CONTRIBUTING.md](https://github.com/robstoll/atrium/tree/master/.github/CONTRIBUTING.md) for further suggestions and guidelines. # Sponsors diff --git a/apis/differences.md b/apis/differences.md index 0f57f69b4..1663e47f6 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -21,7 +21,7 @@ The links point to the KDoc of their included API where you find an overview of ---- Following an excerpt of a build.gradle file which uses two APIs (see -[README#Installation](https://github.com/robstoll/atrium/tree/naster/README.md#installation) +[README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) for the rest): ``` dependencies { diff --git a/gradle/package-lock.json b/gradle/package-lock.json index d50014913..92f9cd1db 100644 --- a/gradle/package-lock.json +++ b/gradle/package-lock.json @@ -122,9 +122,9 @@ }, "dependencies": { "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", diff --git a/samples/js/jasmine/README.md b/samples/js/jasmine/README.md index 3124fc51c..888ac9bb2 100644 --- a/samples/js/jasmine/README.md +++ b/samples/js/jasmine/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. diff --git a/samples/js/mocha/README.md b/samples/js/mocha/README.md index 70bc160be..35fcd84a6 100644 --- a/samples/js/mocha/README.md +++ b/samples/js/mocha/README.md @@ -14,8 +14,8 @@ Yet with a few optimizations and adaptations: This sample project defines a dependency on the bundle module `atrium-fluent-en_GB-robstoll-js`. It does so by using a project dependency (this way CI builds it as well and we can be sure that we provide you a working example). -Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L28) +Therefore you need to delete line 28,29 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L28) and uncomment line 30. -Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/naster/samples/js/mocha/build.gradle#L4) +Change line 4 in [build.gradle](https://github.com/robstoll/atrium/tree/master/samples/js/mocha/build.gradle#L4) to `infix-en_GB-robstoll` in case you want to use the infix API. From 8fe7f380a0c3311fd26358dd3eedc9fa7bc93ac2 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 14 Mar 2020 22:09:18 +0100 Subject: [PATCH 090/142] update mocha to 7.1.0 --- gradle/package-lock.json | 740 +++++++++++++++++++++++++++++++++++++-- gradle/package.json | 2 +- 2 files changed, 713 insertions(+), 29 deletions(-) diff --git a/gradle/package-lock.json b/gradle/package-lock.json index 92f9cd1db..352e8c545 100644 --- a/gradle/package-lock.json +++ b/gradle/package-lock.json @@ -2,12 +2,58 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "binary-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "dev": true + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -18,16 +64,117 @@ "concat-map": "0.0.1" } }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "chokidar": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.2.0" + } + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "concat-map": { @@ -37,12 +184,27 @@ "dev": true }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" } }, "diff": { @@ -51,22 +213,105 @@ "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -77,22 +322,46 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, "inflight": { @@ -111,6 +380,84 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, "jasmine": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.5.0.tgz", @@ -143,6 +490,41 @@ "integrity": "sha512-nCeAiw37MIMA9w9IXso7bRaLl+c/ef3wnxsoSAlYrzS+Ot0zTG6nU8G/cIfGkqpkjX2wNaIW9RFG0TwIFnG6bA==", "dev": true }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "log-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", + "dev": true, + "requires": { + "chalk": "^2.4.2" + } + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -168,30 +550,87 @@ } }, "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.0.tgz", + "integrity": "sha512-MymHK8UkU0K15Q/zX7uflZgVoRWiTjy0fXE/QjKts6mowUvGxOdPhZ2qj3b0iZdUrNZlW9LAIMFHB4IW+2b3EQ==", "dev": true, "requires": { + "ansi-colors": "3.2.3", "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", + "chokidar": "3.3.0", + "debug": "3.2.6", "diff": "3.5.0", "escape-string-regexp": "1.0.5", - "glob": "7.1.2", + "find-up": "3.0.0", + "glob": "7.1.3", "growl": "1.10.5", - "he": "1.1.1", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "3.0.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "5.4.0" + "ms": "2.1.1", + "node-environment-flags": "1.0.6", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.3.0", + "yargs-parser": "13.1.1", + "yargs-unparser": "1.6.0" } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true }, + "node-environment-flags": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", + "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -201,26 +640,271 @@ "wrappy": "1" } }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "picomatch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", + "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", + "dev": true + }, + "readdirp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "dev": true, + "requires": { + "picomatch": "^2.0.4" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", "dev": true, "requires": { "has-flag": "^3.0.0" } }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", + "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.15", + "yargs": "^13.3.0" + } } } } diff --git a/gradle/package.json b/gradle/package.json index 9eebdbe35..8b649334e 100644 --- a/gradle/package.json +++ b/gradle/package.json @@ -4,6 +4,6 @@ "repository": "https://github.com/robstoll/atrium", "devDependencies": { "jasmine": "^3.5.0", - "mocha": "^5.2.0" + "mocha": "^7.1.0" } } From 53cc7fc104e0d8206de69570f971009d03f19b02 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2020 04:35:09 +0000 Subject: [PATCH 091/142] Bump kotlin-gradle-plugin from 1.3.61 to 1.3.70 Bumps kotlin-gradle-plugin from 1.3.61 to 1.3.70. Signed-off-by: dependabot-preview[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ee3fdcf71..388ffa359 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { kbox = { "ch.tutteli.kbox:kbox:$kbox_version" } niok_version = '1.3.4' niok = { "ch.tutteli.niok:niok:$niok_version" } - kotlin_version = '1.3.61' + kotlin_version = '1.3.70' // test jacoco_tool_version = '0.8.5' From 971839ab169aa14cd6953ba078cfc82364107e10 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 15 Mar 2020 21:42:31 +0100 Subject: [PATCH 092/142] suppress deprecation warnings about (Use)Experimental We cannot use (Requires)DropIn as it was introduced in 1.3.70 and we want to support Kotlin 1.2 --- .../ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt | 3 +++ .../ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt | 3 +++ .../src/main/kotlin/ch/tutteli/atrium/core/CoreFactory.kt | 1 + .../main/kotlin/ch/tutteli/atrium/creating/ExpectConfig.kt | 2 +- .../tutteli/atrium/creating/ReportingAssertionContainer.kt | 2 ++ .../atrium/core/robstoll/lib/creating/FeatureExpectImpl.kt | 5 +++-- .../robstoll/lib/creating/ReportingAssertionContainerImpl.kt | 2 +- .../ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt | 1 + .../domain/robstoll/lib/creating/changers/extractFeature.kt | 1 + .../atrium/domain/robstoll/lib/creating/fun0Assertions.kt | 1 + .../domain/robstoll/lib/creating/throwableAssertions.kt | 3 ++- .../creating/resultAssertions.kt | 1 + 12 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt index 422e620ea..a7349f600 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/expectExtensions.kt @@ -10,6 +10,7 @@ import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.reporter +@Suppress("DEPRECATION" /* RequiresOptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @Experimental @Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.FUNCTION) @@ -63,6 +64,7 @@ fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChooser * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) fun RootExpect.withOptions(options: ExpectOptions): Expect = coreFactory.newReportingAssertionContainer( ReportingAssertionContainer.AssertionCheckerDecorator.create( @@ -122,6 +124,7 @@ fun FeatureExpect.withOptions(configuration: FeatureExtractorBuilde * @return An [Expect] for the current subject of the assertion. */ @ExperimentalWithOptions +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) fun FeatureExpect.withOptions(options: FeatureOptions): Expect = coreFactory.newFeatureExpect( diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt index d2a53ae34..2ff205b44 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/expectExtensions.kt @@ -10,6 +10,7 @@ import ch.tutteli.atrium.domain.builders.reporting.ExpectOptions import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.reporter +@Suppress("DEPRECATION" /* RequiresOptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @Experimental @Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.FUNCTION) @@ -55,6 +56,7 @@ infix fun RootExpect.withOptions(configuration: ExpectBuilder.OptionsChoo * Uses the given [options] to override (parts) of the existing configuration. */ @ExperimentalWithOptions +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) infix fun RootExpect.withOptions(options: ExpectOptions): Expect = coreFactory.newReportingAssertionContainer( @@ -107,6 +109,7 @@ infix fun FeatureExpect.withOptions(configuration: FeatureExtractor * Uses the given [options] to override (parts) of the existing configuration. */ @ExperimentalWithOptions +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) infix fun FeatureExpect.withOptions(options: FeatureOptions): Expect = coreFactory.newFeatureExpect( diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/CoreFactory.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/CoreFactory.kt index d57c0803d..c42419e61 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/CoreFactory.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/core/CoreFactory.kt @@ -207,6 +207,7 @@ interface CoreFactoryCommon { //TODO #280 add KDoc + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) fun newFeatureExpect( previousExpect: Expect, diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ExpectConfig.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ExpectConfig.kt index d3b876cd8..72fcaf01b 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ExpectConfig.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ExpectConfig.kt @@ -2,7 +2,7 @@ package ch.tutteli.atrium.creating import ch.tutteli.atrium.reporting.translating.Translatable - +@Suppress("DEPRECATION" /* RequiresOptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @Experimental @Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.CLASS) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ReportingAssertionContainer.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ReportingAssertionContainer.kt index 7e8ce1214..c3cb9e6c0 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ReportingAssertionContainer.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/ReportingAssertionContainer.kt @@ -17,6 +17,7 @@ interface RootExpect : Expect { /** * The chosen [RootExpectConfig]. */ + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) val config: RootExpectConfig } @@ -39,6 +40,7 @@ interface FeatureExpect : Expect { /** * The chosen [FeatureExpectConfig]. */ + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) val config: FeatureExpectConfig diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/FeatureExpectImpl.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/FeatureExpectImpl.kt index 9b7b76651..1ba232cc9 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/FeatureExpectImpl.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/FeatureExpectImpl.kt @@ -14,6 +14,7 @@ import ch.tutteli.atrium.creating.FeatureExpectConfig class FeatureExpectImpl( override val previousExpect: Expect, override val maybeSubject: Option, + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) override val config: FeatureExpectConfig, private val assertionChecker: AssertionChecker, @@ -45,6 +46,7 @@ class FeatureExpectImpl( return this } + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) private fun checkAndClearAssertions(): Expect { try { @@ -54,8 +56,7 @@ class FeatureExpectImpl( } finally { clearAssertions() } - return this - } + return this } override fun getAssertions(): List = getCopyOfAssertions() } diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/ReportingAssertionContainerImpl.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/ReportingAssertionContainerImpl.kt index 7ecea3efb..baa9d635f 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/ReportingAssertionContainerImpl.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/creating/ReportingAssertionContainerImpl.kt @@ -11,7 +11,7 @@ class ReportingAssertionContainerImpl( private val assertionCheckerDecorator: ReportingAssertionContainer.AssertionCheckerDecorator ) : MutableListBasedAssertionContainer(assertionCheckerDecorator.maybeSubject), ReportingAssertionContainer { - + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) override val config: RootExpectConfig = RootExpectConfig.create( diff --git a/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt b/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt index e34a5ab31..f80de21b0 100644 --- a/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt +++ b/core/robstoll/atrium-core-robstoll-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/CoreFactoryCommonImpl.kt @@ -34,6 +34,7 @@ abstract class CoreFactoryCommonImpl : CoreFactoryCommon { final override fun newFeatureExpect( previousExpect: Expect, maybeSubject: Option, + @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) featureConfig: FeatureExpectConfig, assertions: List diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/changers/extractFeature.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/changers/extractFeature.kt index 2f02637c5..6e4a2569e 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/changers/extractFeature.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/changers/extractFeature.kt @@ -14,6 +14,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.collectors.collectAssertions import ch.tutteli.atrium.reporting.translating.Translatable +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalExpectConfig::class) fun _extractFeature( originalAssertionContainer: Expect, diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt index f77add4da..e2d5e9113 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/fun0Assertions.kt @@ -14,6 +14,7 @@ import ch.tutteli.atrium.reporting.reporter import ch.tutteli.atrium.translations.DescriptionFunLikeAssertion.* import kotlin.reflect.KClass +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalWithOptions::class) fun _isThrowing( expect: Expect Any?>, diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt index 2a32fa23e..731c4e842 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/domain/robstoll/lib/creating/throwableAssertions.kt @@ -10,8 +10,9 @@ import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.translations.DescriptionThrowableAssertion import kotlin.reflect.KClass +@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */) @UseExperimental(ExperimentalWithOptions::class) -fun _cause( +fun _cause( expect: Expect, expectedType: KClass ): ChangedSubjectPostStep = diff --git a/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt b/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt index f86e534b0..21c72c5fb 100644 --- a/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt +++ b/domain/robstoll-lib/extensions/kotlin_1_3/atrium-domain-robstoll-lib-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/domain.robstoll.lib.kotlin_1_3/creating/resultAssertions.kt @@ -24,6 +24,7 @@ fun > _isSuccess(expect: Expect): ExtractedFeaturePostStep _isFailure( expect: Expect>, From 13e6cd71cc93acced3840ee9645dafa0ebddb9b2 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2020 04:31:30 +0000 Subject: [PATCH 093/142] Bump spek2_version from 2.0.8 to 2.0.10 Bumps `spek2_version` from 2.0.8 to 2.0.10. Updates `spek-dsl-jvm` from 2.0.8 to 2.0.10 - [Release notes](https://github.com/spekframework/spek/releases) - [Changelog](https://github.com/spekframework/spek/blob/2.x/docs/breaking-changes.md) - [Commits](https://github.com/spekframework/spek/compare/2.0.8...2.0.10) Updates `spek-runner-junit5` from 2.0.8 to 2.0.10 - [Release notes](https://github.com/spekframework/spek/releases) - [Changelog](https://github.com/spekframework/spek/blob/2.x/docs/breaking-changes.md) - [Commits](https://github.com/spekframework/spek/compare/2.0.8...2.0.10) Signed-off-by: dependabot-preview[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 388ffa359..f0d9d4a32 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { junit_platform_version = '1.6.0' jupiter_version = '5.6.0' spek_version = '1.1.5' - spek2_version = '2.0.8' + spek2_version = '2.0.10' spekExtensions_version = '1.1.0' spekExtensions = { "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensions_version" } mockk_version = '1.9.3' From e5bf96a72864d82ce7db250391fec486b7c75414 Mon Sep 17 00:00:00 2001 From: Assaf L Date: Wed, 18 Mar 2020 12:21:41 +0200 Subject: [PATCH 094/142] migrate DetailedObjectFormatterSpec to spek2 --- .../reporting/DetailedObjectFormatterSpec.kt | 41 ++++++++----------- .../specs/reporting/ObjectFormatterSpec.kt | 21 ++++------ 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/DetailedObjectFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/DetailedObjectFormatterSpec.kt index 5fbadb0b7..139d9dc58 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/DetailedObjectFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/DetailedObjectFormatterSpec.kt @@ -10,17 +10,11 @@ import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.reporting.ObjectFormatterSpec import ch.tutteli.atrium.api.verbs.internal.AssertionVerb -import com.nhaarman.mockitokotlin2.doReturn -import com.nhaarman.mockitokotlin2.mock -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.dsl.on -import org.jetbrains.spek.api.include +import io.mockk.* +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to common module object DetailedObjectFormatterSpec : Spek({ include(AtriumsObjectFormatterSpec) @@ -28,21 +22,21 @@ object DetailedObjectFormatterSpec : Spek({ describe("format") { - on("a ${Char::class.simpleName}") { + context("a ${Char::class.simpleName}") { val result = testee.format('a') it("returns the ${Char::class.simpleName} in apostrophes") { expect(result).toBe("'a'") } } - on("a ${Boolean::class.simpleName}") { + context("a ${Boolean::class.simpleName}") { it("returns the toString representation of the ${Boolean::class.simpleName}") { expect(testee.format(true)).toBe("true") expect(testee.format(false)).toBe("false") } } - on("a ${String::class.simpleName}") { + context("a ${String::class.simpleName}") { it("returns two quotes including identity hash if empty ${String::class.simpleName}") { val string = "" val result = testee.format(string) @@ -62,7 +56,7 @@ object DetailedObjectFormatterSpec : Spek({ val typeNameAndHash = "including type name and identity hash" - on("a ${CharSequence::class.simpleName} besides ${String::class.simpleName}") { + context("a ${CharSequence::class.simpleName} besides ${String::class.simpleName}") { it("returns two quotes $typeNameAndHash if empty ${CharSequence::class.simpleName}") { val value = StringBuilder("") val result = testee.format(value) @@ -81,18 +75,17 @@ object DetailedObjectFormatterSpec : Spek({ } } - - on("a ${StringBasedRawString::class.simpleName}") { + context("a ${StringBasedRawString::class.simpleName}") { val result = testee.format(RawString.create("hello")) it("returns the containing string") { expect(result).toBe("hello") } } - on("a ${TranslatableBasedRawString::class.simpleName}") { + context("a ${TranslatableBasedRawString::class.simpleName}") { val translation = "es gilt" - val translator = mock { - on { translate(AssertionVerb.EXPECT) } doReturn translation + val translator = mockk { + every { translate(AssertionVerb.EXPECT) } returns translation } val testeeWithMockedTranslation = DetailedObjectFormatter(translator) val result = testeeWithMockedTranslation.format(RawString.create(AssertionVerb.EXPECT)) @@ -101,7 +94,7 @@ object DetailedObjectFormatterSpec : Spek({ } } - on("an enum") { + context("an enum") { val enum = AssertionVerb.EXPECT val result = testee.format(enum) it("returns its toString representation together with its Class.name but without System.identityHash") { @@ -109,14 +102,14 @@ object DetailedObjectFormatterSpec : Spek({ } } - on("a Throwable") { + context("a Throwable") { val result = testee.format(AssertionError("blablabla")) it("returns only its Class.name") { expect(result).toBe(AssertionError::class.java.name) } } - on("a ${Class::class.simpleName}") { + context("a ${Class::class.simpleName}") { val result = testee.format(DetailedObjectFormatterSpec::class.java) it("returns its simpleName and name in parenthesis") { val clazz = DetailedObjectFormatterSpec::class.java @@ -124,7 +117,7 @@ object DetailedObjectFormatterSpec : Spek({ } } - group("on a ${KClass::class.simpleName}") { + context("on a ${KClass::class.simpleName}") { context("java Class is the same (no special Kotlin class)") { val result = testee.format(DetailedObjectFormatterSpec::class) @@ -160,7 +153,7 @@ object DetailedObjectFormatterSpec : Spek({ java.lang.Float::class.java.simpleName to 1.0f, java.lang.Double::class.java.simpleName to 1.0 ).forEach { (typeName, value) -> - on(typeName) { + context(typeName) { val result = testee.format(value) it("returns subject's toString() $typeNameAndHash") { expect(result).toBe( @@ -171,7 +164,7 @@ object DetailedObjectFormatterSpec : Spek({ } } - on("an anonymous class") { + context("an anonymous class") { val anonymous = object : Any() { override fun toString(): String = "anonymous type" } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt index 3ab506e15..f633786c7 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt @@ -9,28 +9,23 @@ import ch.tutteli.atrium.reporting.StringBasedRawString import ch.tutteli.atrium.reporting.translating.TranslatableBasedRawString import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun -import com.nhaarman.mockitokotlin2.any -import com.nhaarman.mockitokotlin2.doReturn -import com.nhaarman.mockitokotlin2.mock -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import io.mockk.* +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class ObjectFormatterSpec( testeeFactory: (Translator) -> ObjectFormatter, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val translatable = AssertionVerb.ASSERT val translatedText = "es gilt" - val translator = mock { - on { translate(any()) } doReturn (translatedText) + val translator = mockk { + every { translate(any()) } returns (translatedText) } val testee = testeeFactory(translator) From 6505663a4201e695faad85d17c24ec0698113519 Mon Sep 17 00:00:00 2001 From: Assaf L Date: Thu, 19 Mar 2020 18:53:52 +0200 Subject: [PATCH 095/142] migrate OnlyFailureReporterSpec to spek 2 --- .../reporting/OnlyFailureReporterSpec.kt | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt index 8c38244f8..f8b4024dc 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt @@ -15,24 +15,19 @@ import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.AssertionVerb import ch.tutteli.atrium.specs.describeFun +import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE -import com.nhaarman.mockitokotlin2.any -import com.nhaarman.mockitokotlin2.eq -import com.nhaarman.mockitokotlin2.mock -import com.nhaarman.mockitokotlin2.verify -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import io.mockk.* +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class OnlyFailureReporterSpec( testeeFactory: (AssertionFormatterFacade, AtriumErrorAdjuster) -> Reporter, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val translator = UsingDefaultTranslator() val facade = coreFactory.newAssertionFormatterFacade(coreFactory.newAssertionFormatterController()) @@ -82,14 +77,16 @@ abstract class OnlyFailureReporterSpec( } context("dependencies") { - val assertionFormatterFacade = mock() + val assertionFormatterFacade = mockk() + every { assertionFormatterFacade.format(any(), any(), any()) } just Runs + val testeeWithMockedFacade = testeeFactory( assertionFormatterFacade, coreFactory.newNoOpAtriumErrorAdjuster() ) it("delegates to ${assertionFormatterFacade::class.java.simpleName}") { testeeWithMockedFacade.format(basicAssertion, sb) - verify(assertionFormatterFacade).format(eq(basicAssertion), eq(sb), any()) + verify { assertionFormatterFacade.format(eq(basicAssertion), eq(sb), any()) } } } } From 3401ce7af59a95c72bde7a50eb4b445d18125690 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 13 Mar 2020 17:30:27 +0100 Subject: [PATCH 096/142] introduce uncheckedToNonNullable similar to unifySignatures in Specs This way we can test non-nullable and nullable at the same time and only have to test real null-cases for the nullable version. --- .../fluent/en_GB/MapEntryAssertionsSpec.kt | 3 +- .../integration/MapEntryAssertionsSpec.kt | 91 +++++++------------ .../ch/tutteli/atrium/specs/testUtils.kt | 3 + 3 files changed, 37 insertions(+), 60 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryAssertionsSpec.kt index 70b8f6ea6..fed5f4967 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapEntryAssertionsSpec.kt @@ -3,10 +3,11 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix object MapEntryAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryAssertionsSpec( fun2(Expect>::isKeyValue), - fun2(Expect>::isKeyValue) + fun2(Expect>::isKeyValue).withNullableSuffix() ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt index 7e69d23ec..b24b2891a 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt @@ -1,9 +1,6 @@ package ch.tutteli.atrium.specs.integration -import ch.tutteli.atrium.api.fluent.en_GB.contains -import ch.tutteli.atrium.api.fluent.en_GB.containsNot -import ch.tutteli.atrium.api.fluent.en_GB.message -import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.specs.* import org.spekframework.spek2.Spek @@ -24,83 +21,59 @@ abstract class MapEntryAssertionsSpec( isKeyValueNullable.forSubjectLess("key", 1) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val mapEntry = mapEntry("a", 1) val fluent = expect(mapEntry) - val mapEntryNullable = mapEntry("a" as String?, 1 as Int?) - val fluentNullable = expect(mapEntryNullable) - describeFun(isKeyValue.name) { - val isKeyValueFun = isKeyValue.lambda + describeFun(isKeyValue, isKeyValueNullable) { + + val isKeyValueFunctions = uncheckedToNonNullable(isKeyValue, isKeyValueNullable) + context("map $mapEntry") { - it("a to 1 does not throw") { - fluent.isKeyValueFun("a", 1) - } + isKeyValueFunctions.forEach { (name, isKeyValueFun) -> + it("$name - a to 1 does not throw") { + fluent.isKeyValueFun("a", 1) + } - it("a to 2 throws AssertionError") { - expect { - fluent.isKeyValueFun("a", 2) - }.toThrow { - message { - contains("value: 1", "$toBeDescr: 2") - containsNot("key") + it("$name - a to 2 throws AssertionError") { + expect { + fluent.isKeyValueFun("a", 2) + }.toThrow { + message { + contains("value: 1", "$toBeDescr: 2") + containsNot("key") + } } } - } - it("b to 1 throws AssertionError") { - expect { - fluent.isKeyValueFun("b", 1) - }.toThrow { - message { - contains("key: \"a\"", "$toBeDescr: \"b\"") - containsNot("value") + it("$name - b to 1 throws AssertionError") { + expect { + fluent.isKeyValueFun("b", 1) + }.toThrow { + message { + contains("key: \"a\"", "$toBeDescr: \"b\"") + containsNot("value") + } } } } } } - describeFun("${isKeyValueNullable.name} nullable") { + describeFun(isKeyValueNullable) { val isKeyValueFun = isKeyValueNullable.lambda - context("map $mapEntryNullable") { - it("a to 1 does not throw") { - fluentNullable.isKeyValueFun("a", 1) - } - - it("a to 2 throws AssertionError") { - expect { - fluentNullable.isKeyValueFun("a", 2) - }.toThrow { - message { - contains("value: 1", "$toBeDescr: 2") - containsNot("key") - } - } - } - it("b to 1 throws AssertionError") { - expect { - fluentNullable.isKeyValueFun("b", 1) - }.toThrow { - message { - contains("key: \"a\"", "$toBeDescr: \"b\"") - containsNot("value") - } - } - } - } val mapEntryNullable2 = mapEntry(null as String?, null as Int?) - val fluentNullable2 = expect(mapEntryNullable2) + val fluentNullable = expect(mapEntryNullable2) context("map $mapEntryNullable2") { it("null to null does not throw") { - fluentNullable2.isKeyValueFun(null, null) + fluentNullable.isKeyValueFun(null, null) } it("null to 2 throws AssertionError") { expect { - fluentNullable2.isKeyValueFun(null, 2) + fluentNullable.isKeyValueFun(null, 2) }.toThrow { message { contains("value: null", "$toBeDescr: 2") @@ -110,7 +83,7 @@ abstract class MapEntryAssertionsSpec( } it("b to null throws AssertionError") { expect { - fluentNullable2.isKeyValueFun("b", null) + fluentNullable.isKeyValueFun("b", null) }.toThrow { message { contains("key: null", "$toBeDescr: \"b\"") diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index ae34113cc..c9110dd9e 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -163,6 +163,9 @@ fun unifySignatures( ) } +@Suppress("UNCHECKED_CAST") +fun uncheckedToNonNullable(f: F, fNullable: Any): List = listOf(f, fNullable as F) + internal inline fun Feature0.withSubAssertion(): Expect.(Expect.() -> Unit) -> Expect = { f: Expect.() -> Unit -> apply { (lambda)().f() } } From 28c99dac209aac36bf6d41c41ab7119dd4aecdbf Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 13 Mar 2020 18:35:20 +0100 Subject: [PATCH 097/142] use uncheckedToNonNullable from Throwable to KeyValueLike...Spec --- .../KeyValueLikeFeatureAssertionsSpec.kt | 34 +- .../integration/ListFeatureAssertionsSpec.kt | 50 +-- .../specs/integration/MapAssertionsSpec.kt | 299 +++++++++--------- .../integration/MapEntryAssertionsSpec.kt | 1 - .../ResultFeatureAssertionsSpec.kt | 33 +- .../integration/ThrowableAssertionsSpec.kt | 2 +- .../ch/tutteli/atrium/specs/testUtils.kt | 4 + 7 files changed, 197 insertions(+), 226 deletions(-) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt index 3f4f94dae..13be4d739 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/KeyValueLikeFeatureAssertionsSpec.kt @@ -18,10 +18,10 @@ abstract class KeyValueLikeFeatureAssertionsSpec( key: Fun1.() -> Unit>, valueFeature: Feature0, value: Fun1.() -> Unit>, - nullableKeyFeature: Feature0, - nullableKey: Fun1.() -> Unit>, - nullableValueFeature: Feature0, - nullableValue: Fun1.() -> Unit>, + keyFeatureNullable: Feature0, + keyNullable: Fun1.() -> Unit>, + valueFeatureNullable: Feature0, + valueNullable: Fun1.() -> Unit>, describePrefix: String = "[Atrium] " ) : Spek({ @@ -36,10 +36,10 @@ abstract class KeyValueLikeFeatureAssertionsSpec( ) {}) include(object : SubjectLessSpec( "$describePrefix[nullable] ", - nullableKeyFeature.forSubjectLess(), - nullableKey.forSubjectLess { toBe(null) }, - nullableValueFeature.forSubjectLess(), - nullableValue.forSubjectLess { toBe(null) } + keyFeatureNullable.forSubjectLess(), + keyNullable.forSubjectLess { toBe(null) }, + valueFeatureNullable.forSubjectLess(), + valueNullable.forSubjectLess { toBe(null) } ) {}) include(object : AssertionCreatorSpec( @@ -49,8 +49,8 @@ abstract class KeyValueLikeFeatureAssertionsSpec( ) {}) include(object : AssertionCreatorSpec( "$describePrefix[nullable]", nullMapEntry, - nullableKey.forAssertionCreatorSpec("$toBeDescr: null") { toBe(null) }, - nullableValue.forAssertionCreatorSpec("$toBeDescr: null") { toBe(null) } + keyNullable.forAssertionCreatorSpec("$toBeDescr: null") { toBe(null) }, + valueNullable.forAssertionCreatorSpec("$toBeDescr: null") { toBe(null) } ) {}) fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = @@ -62,8 +62,12 @@ abstract class KeyValueLikeFeatureAssertionsSpec( val nullableFluent = expect(nullableMapEntry) val nullFluent = expect(nullMapEntry) - describeFun(keyFeature, key, valueFeature, value) { - val keyFunctions = unifySignatures(keyFeature, key) + describeFun(keyFeature, key, keyFeatureNullable, keyNullable, valueFeature, value, valueFeature, valueNullable) { + val keyFunctions = uncheckedToNonNullable( + unifySignatures(keyFeature, key), + unifySignatures(keyFeatureNullable, keyNullable) + ) + val valueFunctions = unifySignatures(valueFeature, value) context("$mapEntry") { keyFunctions.forEach { (name, keyFun, _) -> @@ -101,9 +105,9 @@ abstract class KeyValueLikeFeatureAssertionsSpec( } - describeFun(nullableKeyFeature, nullableKey, nullableValueFeature, nullableValue) { - val keyFunctions = unifySignatures(nullableKeyFeature, nullableKey) - val valueFunctions = unifySignatures(nullableValueFeature, nullableValue) + describeFun(keyFeatureNullable, keyNullable, valueFeatureNullable, valueNullable) { + val keyFunctions = unifySignatures(keyFeatureNullable, keyNullable) + val valueFunctions = unifySignatures(valueFeatureNullable, valueNullable) context("$nullableMapEntry") { keyFunctions.forEach { (name, nullableKeyFun, _) -> diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt index ef398bef9..feecd6b04 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt @@ -13,7 +13,7 @@ import org.spekframework.spek2.style.specification.Suite abstract class ListFeatureAssertionsSpec( getFeature: Feature1, Int, Int>, get: Fun2, Int, Expect.() -> Unit>, - getNullableFeature: Feature1, Int, Int?>, + getFeatureNullable: Feature1, Int, Int?>, getNullable: Fun2, Int, Expect.() -> Unit>, describePrefix: String = "[Atrium] " ) : Spek({ @@ -25,7 +25,7 @@ abstract class ListFeatureAssertionsSpec( get.forSubjectLess(1) { toBe(1) } ) {}) include(object : SubjectLessSpec>("$describePrefix[nullable Element] ", - getNullableFeature.forSubjectLess(1), + getFeatureNullable.forSubjectLess(1), getNullable.forSubjectLess(1) { toBe(null) } ) {}) @@ -47,8 +47,12 @@ abstract class ListFeatureAssertionsSpec( val indexOutOfBounds = DescriptionListAssertion.INDEX_OUT_OF_BOUNDS.getDefault() - describeFun(getFeature, get) { - val getFunctions = unifySignatures(getFeature, get) + describeFun(getFeature, get, getFeatureNullable, getNullable) { + val getFunctions = uncheckedToNonNullable( + unifySignatures(getFeature, get), + unifySignatures(getFeatureNullable, getNullable) + ) + context("list $list") { getFunctions.forEach { (name, getFun, hasExtraHint) -> it("$name - can perform sub-assertion on existing index") { @@ -68,45 +72,13 @@ abstract class ListFeatureAssertionsSpec( } } - describeFun(getNullableFeature) { - val getFun = getNullableFeature.lambda - context("list $listNullable") { - it("can perform sub-assertion on existing key") { - fluentNullable.getFun(0).toBe(1) - } - it("can perform sub-assertion on existing key with value null") { - fluentNullable.getFun(1).toBe(null) - } - - it("non-existing key throws") { - expect { - fluentNullable.getFun(4).toBe(null) - }.toThrow { - messageContains("get(4): $indexOutOfBounds") - } - } - } - } - - describeFun(getNullableFeature, getNullable) { - val getFunctions = unifySignatures(getNullableFeature, getNullable) + describeFun(getFeatureNullable, getNullable) { + val getFunctions = unifySignatures(getFeatureNullable, getNullable) context("list $listNullable") { getFunctions.forEach { (name, getFun, hasExtraHint) -> - it("$name - can perform sub-assertion on existing key") { - fluentNullable.getFun(0) { toBe(1) } - } - it("$name - can perform sub-assertion on existing key with value null") { + it("$name - can perform sub-assertion on existing index with value null") { fluentNullable.getFun(1) { toBe(null) } } - - it("$name - non-existing key throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { - expect { - fluentNullable.getFun(4) { toBe(null) } - }.toThrow { - messageContains("get(4): $indexOutOfBounds") - if (hasExtraHint) messageContains("$toBeDescr: null") - } - } } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt index 774df8141..b4fbf52ba 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt @@ -16,9 +16,9 @@ abstract class MapAssertionsSpec( containsKeyWithValueAssertions: Fun2, Pair.() -> Unit>, Array.() -> Unit>>>, containsKeyWithNullableValueAssertions: Fun2, Pair.() -> Unit)?>, Array.() -> Unit)?>>>, containsKey: Fun1, String>, - containsNullableKey: Fun1, String?>, + containsKeyNullable: Fun1, String?>, containsNotKey: Fun1, String>, - containsNotNullableKey: Fun1, String?>, + containsNotKeyNullable: Fun1, String?>, isEmpty: Fun0>, isNotEmpty: Fun0>, describePrefix: String = "[Atrium] " @@ -55,8 +55,8 @@ abstract class MapAssertionsSpec( keyNullableValue(null) { toBe(1) }, arrayOf(keyNullableValue("a", null)) ), - containsNullableKey.forSubjectLess(null).unchecked1(), - containsNotNullableKey.forSubjectLess(null).unchecked1() + containsKeyNullable.forSubjectLess(null).unchecked1(), + containsNotKeyNullable.forSubjectLess(null).unchecked1() ) {}) include(object : AssertionCreatorSpec>( @@ -75,8 +75,9 @@ abstract class MapAssertionsSpec( ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) + val map: Map = mapOf("a" to 1, "b" to 2) val fluent = expect(map) @@ -93,43 +94,46 @@ abstract class MapAssertionsSpec( fun entry(key: String, value: Any): String = entry(key) + ": " + value - describeFun(contains.name) { - val containsFun = contains.lambda + describeFun(contains, containsNullable) { + val containsFunctions = uncheckedToNonNullable(contains, containsNullable) + context("map $map") { - listOf( - listOf("a" to 1), - listOf("b" to 2), - listOf("a" to 1, "b" to 2), - listOf("b" to 2, "a" to 1) - ).forEach { - it("$it does not throw") { - fluent.containsFun(it.first(), it.drop(1).toTypedArray()) + containsFunctions.forEach { (name, containsFun) -> + listOf( + listOf("a" to 1), + listOf("b" to 2), + listOf("a" to 1, "b" to 2), + listOf("b" to 2, "a" to 1) + ).forEach { + it("$name - $it does not throw") { + fluent.containsFun(it.first(), it.drop(1).toTypedArray()) + } } - } - it("a to 1 and a to 1 does not throw (no unique match)") { - fluent.containsFun("a" to 1, arrayOf("a" to 1)) - } + it("$name - a to 1 and a to 1 does not throw (no unique match)") { + fluent.containsFun("a" to 1, arrayOf("a" to 1)) + } - it("{a to 1, b to 3, c to 4} throws AssertionError, reports b and c") { - expect { - fluent.containsFun("a" to 1, arrayOf("b" to 3, "c" to 4)) - }.toThrow { - message { - contains( - entry("b", 2), - "$toBeDescr: 3", - entry("c", keyDoesNotExist), - "$toBeDescr: 4" - ) - containsNot(entry("a")) + it("$name - {a to 1, b to 3, c to 4} throws AssertionError, reports b and c") { + expect { + fluent.containsFun("a" to 1, arrayOf("b" to 3, "c" to 4)) + }.toThrow { + message { + contains( + entry("b", 2), + "$toBeDescr: 3", + entry("c", keyDoesNotExist), + "$toBeDescr: 4" + ) + containsNot(entry("a")) + } } } } } } - describeFun("${containsNullable.name} for nullable") { + describeFun(containsNullable) { val containsNullableFun = containsNullable.lambda context("map $nullableMap") { listOf( @@ -169,49 +173,55 @@ abstract class MapAssertionsSpec( } } - describeFun(containsKeyWithValueAssertions.name) { - val containsKeyWithValueAssertionsFun = containsKeyWithValueAssertions.lambda + describeFun(containsKeyWithValueAssertions, containsKeyWithNullableValueAssertions) { + val containsKeyWithValueAssertionsFunctions = uncheckedToNonNullable( + containsKeyWithValueAssertions, + containsKeyWithNullableValueAssertions + ) + context("map $map") { - listOf( - "a { toBe(1) }" to listOf(keyValue("a") { toBe(1) }), - "b { toBe(2) }" to listOf(keyValue("b") { toBe(2) }), - "a { toBe(1) }, b { toBe(2) }" to listOf(keyValue("a") { toBe(1) }, keyValue("b") { toBe(2) }), - "b { toBe(2) }, a { toBe(1) }" to listOf(keyValue("b") { toBe(2) }, keyValue("a") { toBe(1) }) - ).forEach { (description, keyValues) -> - it("$description does not throw") { - fluent.containsKeyWithValueAssertionsFun(keyValues.first(), keyValues.drop(1).toTypedArray()) + containsKeyWithValueAssertionsFunctions.forEach { (name, containsKeyWithValueAssertionsFun) -> + listOf( + "a { toBe(1) }" to listOf(keyValue("a") { toBe(1) }), + "b { toBe(2) }" to listOf(keyValue("b") { toBe(2) }), + "a { toBe(1) }, b { toBe(2) }" to listOf(keyValue("a") { toBe(1) }, keyValue("b") { toBe(2) }), + "b { toBe(2) }, a { toBe(1) }" to listOf(keyValue("b") { toBe(2) }, keyValue("a") { toBe(1) }) + ).forEach { (description, keyValues) -> + it("$name - $description does not throw") { + fluent.containsKeyWithValueAssertionsFun(keyValues.first(), keyValues.drop(1).toTypedArray()) + } } - } - it("a { isLessThan(2) } and a { isGreaterThan(0) } does not throw (no unique match)") { - fluent.containsKeyWithValueAssertionsFun( - keyValue("a") { isLessThan(2) }, - arrayOf(keyValue("a") { isGreaterThan(0) }) - ) - } - - it("a { isLessThan(3) }, b { isLessThan(2) }, c { isLessThan(1) }} throws AssertionError, reports b and c") { - expect { + it("$name - a { isLessThan(2) } and a { isGreaterThan(0) } does not throw (no unique match)") { fluent.containsKeyWithValueAssertionsFun( - keyValue("a") { isLessThan(3) }, - arrayOf(keyValue("b") { isLessThan(2) }, keyValue("c") { isLessThan(1) }) + keyValue("a") { isLessThan(2) }, + arrayOf(keyValue("a") { isGreaterThan(0) }) ) - }.toThrow { - message { - contains( - entry("b", 2), - "$lessThanDescr: 2", - entry("c", keyDoesNotExist), - "$lessThanDescr: 1" + } + + it("$name - a { isLessThan(3) }, b { isLessThan(2) }, c { isLessThan(1) }} throws AssertionError, reports b and c") { + expect { + fluent.containsKeyWithValueAssertionsFun( + keyValue("a") { isLessThan(3) }, + arrayOf(keyValue("b") { isLessThan(2) }, keyValue("c") { isLessThan(1) }) ) - containsNot(entry("a")) + }.toThrow { + message { + contains( + entry("b", 2), + "$lessThanDescr: 2", + entry("c", keyDoesNotExist), + "$lessThanDescr: 1" + ) + containsNot(entry("a")) + } } } } } } - describeFun("${containsKeyWithNullableValueAssertions.name} for nullable") { + describeFun(containsKeyWithNullableValueAssertions) { val containsKeyWithNullableValueAssertionsFun = containsKeyWithNullableValueAssertions.lambda context("map $nullableMap") { listOf( @@ -247,13 +257,6 @@ abstract class MapAssertionsSpec( } } - it("b { isLessThan(3) } and b { isGreaterThan(0) } does not throw (no unique match)") { - nullableFluent.containsKeyWithNullableValueAssertionsFun( - keyNullableValue("b") { isLessThan(3) }, - arrayOf(keyNullableValue("b") { isGreaterThan(0) }) - ) - } - it("(a, null), b { isLessThan(2) }, c { isLessThan(1) }} throws AssertionError, reports b and c") { expect { nullableFluent.containsKeyWithNullableValueAssertionsFun( @@ -277,99 +280,99 @@ abstract class MapAssertionsSpec( } } - describeFun(containsKey.name) { - val containsKeyFun = containsKey.lambda + describeFun(containsKey, containsKeyNullable, containsNotKey, containsNotKeyNullable) { + val containsKeyFunctions = uncheckedToNonNullable(containsKey, containsKeyNullable) + val containsNotKeyFunctions = uncheckedToNonNullable(containsNotKey, containsNotKeyNullable) + val fluent2 = expect(map as Map) - it("does not throw if the map contains the key") { - fluent2.containsKeyFun("a") - } + context("$map") { + containsKeyFunctions.forEach { (name, containsKeyFun) -> + it("$name - does not throw if the map contains the key") { + fluent2.containsKeyFun("a") + } - it("throws an AssertionError if the map does not contain the key") { - expect { - fluent2.containsKeyFun("c") - }.toThrow { messageContains("$containsKeyDescr: \"c\"") } - } + it("$name - throws an AssertionError if the map does not contain the key") { + expect { + fluent2.containsKeyFun("c") + }.toThrow { messageContains("$containsKeyDescr: \"c\"") } + } - it("does not throw if null is passed and the map contains null as key") { - fluent2.containsKeyFun("a") + it("$name - does not throw if null is passed and the map contains null as key") { + fluent2.containsKeyFun("a") + } + } + + containsNotKeyFunctions.forEach { (name, containsNotKeyFun) -> + it("$name - does not throw if the map does not contain the key") { + fluent2.containsNotKeyFun("c") + } + + it("$name - throws an AssertionError if the map contains the key") { + expect { + fluent2.containsNotKeyFun("a") + }.toThrow { messageContains("$containsNotKeyDescr: \"a\"") } + } + } } } - describeFun("$containsNullableKey for nullable key type") { - val containsNullableKeyFun = containsNullableKey.lambda - it("does not throw if the map contains the key") { - val map2: Map = mapOf("a" to 1, null to 2) - expect(map2).containsNullableKeyFun(null) - } + describeFun(containsKeyNullable, containsNotKeyNullable) { + val containsNullableKeyFun = containsKeyNullable.lambda + val containsNotNullableKeyFun = containsNotKeyNullable.lambda - it("throws an AssertionError if the map does not contain the key") { - expect { - val map2: Map = mapOf("a" to 1, "b" to 2) + val map2: Map = mapOf("a" to 1, null to 2) + context("$map2") { + it("${containsKeyNullable.name} - does not throw if the map contains the key") { expect(map2).containsNullableKeyFun(null) - }.toThrow { messageContains("$containsKeyDescr: null") } + } + + it("${containsNotKeyNullable.name} - throws an AssertionError if the map contains the key") { + expect { + expect(map2).containsNotNullableKeyFun(null) + }.toThrow { messageContains("$containsNotKeyDescr: null") } + } + } + + val map3: Map = mapOf("a" to 1, "b" to 2) + context("$map3") { + it("${containsKeyNullable.name} - throws an AssertionError if the map does not contain the key") { + expect { + expect(map3).containsNullableKeyFun(null) + }.toThrow { messageContains("$containsKeyDescr: null") } + } + + it("${containsNotKeyNullable.name} - does not throw if the map does not contain the key") { + expect(map3).containsNotNullableKeyFun(null) + } } } - describeFun(containsNotKey.name) { - val containsNotKeyFun = containsNotKey.lambda - val fluent2 = expect(map as Map) - - it("does not throw if the map does not contain the key") { - fluent2.containsNotKeyFun("c") - } - - it("throws an AssertionError if the map contains the key") { - expect { - fluent2.containsNotKeyFun("a") - }.toThrow { messageContains("$containsNotKeyDescr: \"a\"") } - } - } - - describeFun("${containsNotNullableKey.name} for nullable key type") { - val containsNotNullableKeyFun = containsNotNullableKey.lambda - - it("does not throw if the map does not contain the key") { - val map2: Map = mapOf("a" to 1, "b" to 2) - expect(map2).containsNotNullableKeyFun(null) - } - - it("throws an AssertionError if the map contains the key") { - expect { - val map2: Map = mapOf("a" to 1, null to 2) - expect(map2).containsNotNullableKeyFun(null) - }.toThrow { messageContains("$containsNotKeyDescr: null") } - } - } - - - describeFun(isEmpty.name) { + describeFun(isEmpty, isNotEmpty) { val isEmptyFun = isEmpty.lambda - - it("does not throw if a map is empty") { - val map2: Map<*, *> = mapOf() - expect(map2).isEmptyFun() - } - - it("throws an AssertionError if a map is not empty") { - expect { - expect(map as Map<*, *>).isEmptyFun() - }.toThrow { messageContains("$isDescr: $empty") } - } - } - - describeFun(isNotEmpty.name) { val isNotEmptyFun = isNotEmpty.lambda - it("does not throw if a map is not empty") { - expect(map as Map<*, *>).isNotEmptyFun() - } + val map2: Map<*, *> = mapOf() + context("empty Map") { + it("${isEmpty.name} - does not throw") { + expect(map2).isEmptyFun() + } - it("throws an AssertionError if a map is empty") { - expect { - val map2: Map<*, *> = mapOf() - expect(map2).isNotEmptyFun() - }.toThrow { messageContains("$isNotDescr: $empty") } + it("${isNotEmpty.name} - throws an AssertionError") { + expect { + expect(map2).isNotEmptyFun() + }.toThrow { messageContains("$isNotDescr: $empty") } + } + } + context("$map") { + it("${isEmpty.name} - throws an AssertionError") { + expect { + expect(map as Map<*, *>).isEmptyFun() + }.toThrow { messageContains("$isDescr: $empty") } + } + it("${isNotEmpty.name} - does not throw") { + expect(map as Map<*, *>).isNotEmptyFun() + } } } }) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt index b24b2891a..a56e88029 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapEntryAssertionsSpec.kt @@ -28,7 +28,6 @@ abstract class MapEntryAssertionsSpec( val fluent = expect(mapEntry) describeFun(isKeyValue, isKeyValueNullable) { - val isKeyValueFunctions = uncheckedToNonNullable(isKeyValue, isKeyValueNullable) context("map $mapEntry") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt index ae3f8eef0..3b8d69497 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt @@ -17,7 +17,7 @@ import org.spekframework.spek2.style.specification.Suite abstract class ResultFeatureAssertionsSpec( isSuccessFeature: Feature0, Int>, isSuccess: Fun1, Expect.() -> Unit>, - isSuccessNullableFeature: Feature0, Int?>, + isSuccessFeatureNullable: Feature0, Int?>, isSuccessNullable: Fun1, Expect.() -> Unit>, isFailureFeature: Feature0, IllegalArgumentException>, isFailure: Feature1, Expect.() -> Unit, IllegalArgumentException>, @@ -33,7 +33,7 @@ abstract class ResultFeatureAssertionsSpec( ) {}) include(object : SubjectLessSpec>( "$describePrefix[nullable] ", - isSuccessNullableFeature.forSubjectLess(), + isSuccessFeatureNullable.forSubjectLess(), isSuccessNullable.forSubjectLess { toBe(1) } ) {}) @@ -61,7 +61,6 @@ abstract class ResultFeatureAssertionsSpec( val resultSuccess = Result.success(1) val resultFailure = Result.failure(IllegalArgumentException("oh no...")) - val resultNullableSuccess = Result.success(1 as Int?) val resultNullSuccess = Result.success(null as Int?) val resultNullableFailure = Result.failure(IllegalArgumentException("oh no...")) @@ -70,8 +69,11 @@ abstract class ResultFeatureAssertionsSpec( val exceptionDescr = DescriptionResultAssertion.EXCEPTION.getDefault() val isADescr = DescriptionAnyAssertion.IS_A.getDefault() - describeFun(isSuccessFeature, isSuccess, isFailureFeature, isFailure) { - val successFunctions = unifySignatures(isSuccessFeature, isSuccess) + describeFun(isSuccessFeature, isSuccess, isSuccessFeatureNullable, isSuccessNullable, isFailureFeature, isFailure) { + val successFunctions = uncheckedToNonNullable( + unifySignatures(isSuccessFeature, isSuccess), + unifySignatures(isSuccessFeatureNullable, isSuccessNullable) + ) val failureFunctions = unifySignatures(isFailureFeature, isFailure) context("subject is $resultSuccess") { @@ -138,24 +140,11 @@ abstract class ResultFeatureAssertionsSpec( } } - - describeFun(isSuccessNullableFeature, isSuccessNullable) { - val successFunctions = unifySignatures(isSuccessNullableFeature, isSuccessNullable) + describeFun(isSuccessFeatureNullable, isSuccessNullable) { + val successFunctions = unifySignatures(isSuccessFeatureNullable, isSuccessNullable) successFunctions.forEach { (name, isSuccessFun, hasExtraHint) -> - context("$resultNullableSuccess") { - it("$name - can perform sub-assertion which holds") { - expect(resultNullableSuccess).isSuccessFun { toBe(1) } - } - it("$name - can perform sub-assertion which fails, throws AssertionError") { - expect { - expect(resultNullableSuccess).isSuccessFun { toBe(2) } - }.toThrow { - messageContains("value: 1", "$toBeDescr: 2") - } - } - } - context("$resultNullSuccess") { + context("subject is $resultNullSuccess") { it("$name - can perform sub-assertion which holds") { expect(resultNullSuccess).isSuccessFun { toBe(null) } } @@ -168,7 +157,7 @@ abstract class ResultFeatureAssertionsSpec( } } - context("$resultNullableFailure") { + context("subject is $resultNullableFailure") { it("${isSuccessFeature.name} throws AssertionError" + if (hasExtraHint) " but shows intended sub-assertion" else "") { expect { expect(resultNullableFailure).isSuccessFun { toBe(1) } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt index 8b9ca19dd..031e7d06c 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt @@ -160,7 +160,7 @@ abstract class ThrowableAssertionsSpec( } describeFun(causeFeature, cause) { - val causeFunctions = unifySignatures(causeFeature, cause) + val causeFunctions = unifySignatures(causeFeature, cause) context("Throwable.cause is not null") { val exceptionCause = IllegalArgumentException("Hello from the Clause") diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index c9110dd9e..c692059f9 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.core.polyfills.format import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.subExpect import ch.tutteli.atrium.translations.DescriptionBasic +import ch.tutteli.kbox.glue import kotlin.jvm.JvmName import kotlin.reflect.KFunction1 import kotlin.reflect.KFunction2 @@ -163,6 +164,9 @@ fun unifySignatures( ) } +@Suppress("UNCHECKED_CAST") +fun uncheckedToNonNullable(f: List, fNullable: List): List = f + (fNullable as List) + @Suppress("UNCHECKED_CAST") fun uncheckedToNonNullable(f: F, fNullable: Any): List = listOf(f, fNullable as F) From 914c48d6016551e2b671b79e84bed99e8c1ffc94 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 19 Mar 2020 23:20:47 +0100 Subject: [PATCH 098/142] simplify/revise iterable specs - don't use expect in BaseSpecs as it instantiates the reporter too early - check for hasElement in reporting for Iterable.none - simplify nonNullableCases with the help of uncheckedToNonNullable - remove IterablePredicateSpecBase, no longer required afterwards - move mfun2 to specs (no need to duplicate in APIs) --- .../fluent/en_GB/IterableAnyAssertionsSpec.kt | 9 +- .../en_GB/IterableNoneAssertionsSpec.kt | 5 +- .../api/fluent/en_GB/MapAssertionsSpec.kt | 6 +- .../api/infix/en_GB/MapAssertionsSpec.kt | 6 +- .../integration/IterableAllAssertionsSpec.kt | 8 +- .../integration/IterableAnyAssertionsSpec.kt | 12 +- .../integration/IterableAssertionsSpec.kt | 16 +- .../IterableContainsEntriesSpecBase.kt | 32 +- ...InAnyOrderAtLeast1EntriesAssertionsSpec.kt | 8 +- ...sInAnyOrderAtLeast1ValuesAssertionsSpec.kt | 4 +- ...insInAnyOrderAtLeastValuesAssertionSpec.kt | 6 +- ...ainsInAnyOrderAtMostValuesAssertionSpec.kt | 6 +- ...nsInAnyOrderExactlyValuesAssertionsSpec.kt | 6 +- ...AnyOrderNotOrAtMostValuesAssertionsSpec.kt | 6 +- ...ainsInAnyOrderOnlyEntriesAssertionsSpec.kt | 8 +- ...tainsInAnyOrderOnlyValuesAssertionsSpec.kt | 22 +- ...ontainsInOrderOnlyEntriesAssertionsSpec.kt | 11 +- ...sInOrderOnlyGroupedValuesAssertionsSpec.kt | 318 ++++++++---------- ...ContainsInOrderOnlyValuesAssertionsSpec.kt | 6 +- ...terableContainsNotEntriesAssertionsSpec.kt | 6 +- ...IterableContainsNotValuesAssertionsSpec.kt | 8 +- .../integration/IterableContainsSpecBase.kt | 34 +- .../integration/IterableNoneAssertionsSpec.kt | 20 +- .../integration/IterablePredicateSpecBase.kt | 33 -- .../integration/ListFeatureAssertionsSpec.kt | 2 +- .../specs/integration/MapAssertionsSpec.kt | 16 +- .../ch/tutteli/atrium/specs/testUtils.kt | 1 - 27 files changed, 256 insertions(+), 359 deletions(-) delete mode 100644 misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterablePredicateSpecBase.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt index 7f6534a7a..c37352480 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix import org.spekframework.spek2.Spek import kotlin.reflect.KFunction2 import kotlin.reflect.KFunction3 @@ -16,28 +17,28 @@ class IterableAnyAssertionsSpec : Spek({ }) { object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( fun1(Expect>::any), - fun1(Expect>::any), + fun1(Expect>::any).withNullableSuffix(), "◆ ", "[Atrium][Predicate] " ) object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( getContainsPair(), - getContainsNullablePair(), + getContainsNullablePair().withNullableSuffix(), "◆ ", "[Atrium][Builder] " ) object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( getContainsShortcutPair(), - getContainsNullableShortcutPair(), + getContainsNullableShortcutPair().withNullableSuffix(), "◆ ", "[Atrium][Shortcut] " ) object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( getContainsSequencePair(), - getContainsNullableSequencePair(), + getContainsNullableSequencePair().withNullableSuffix(), "◆ ", "[Atrium][Sequence] " ) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt index 63d7be6df..7c664032f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix import org.spekframework.spek2.Spek class IterableNoneAssertionsSpec : Spek({ @@ -13,14 +14,14 @@ class IterableNoneAssertionsSpec : Spek({ }) { object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableNoneAssertionsSpec( fun1(Expect>::none), - fun1(Expect>::none), + fun1(Expect>::none).withNullableSuffix(), "◆ ", "✔ ", "✘ ", "⚬ ", "» ", "▶ ", "◾ ", "[Atrium][Predicate] " ) object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableNoneAssertionsSpec( getContainsNotPair(), - getContainsNotNullablePair(), + getContainsNotNullablePair().withNullableSuffix(), "◆ ", "✔ ", "✘ ", "⚬ ", "» ", "▶ ", "◾ ", "[Atrium][Builder] " ) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt index 702158296..bc0320c7f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt @@ -3,12 +3,8 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.integration.mfun2 import kotlin.jvm.JvmName -import kotlin.reflect.KFunction3 - -private fun mfun2( - f: KFunction3>, Pair, Array>, Expect>> -) = fun2(f) class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( mfun2(Expect>::contains), diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index b048a2057..cfdd9f2aa 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -3,13 +3,9 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.integration.mfun2 import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import kotlin.jvm.JvmName -import kotlin.reflect.KFunction3 - -private fun mfun2( - f: KFunction3>, Pair, Array>, Expect>> -) = fun2(f) class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( mfun2(::contains), diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt index 823295acf..24b17101d 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllAssertionsSpec.kt @@ -16,7 +16,7 @@ abstract class IterableAllAssertionsSpec( featureArrow: String, featureBulletPoint: String, describePrefix: String = "[Atrium] " -) : IterablePredicateSpecBase({ +) : IterableContainsEntriesSpecBase({ include(object : SubjectLessSpec>(describePrefix, all.first to expectLambda { all.second(this) { toBe(2.5) } } @@ -52,9 +52,9 @@ abstract class IterableAllAssertionsSpec( ) { allFun -> context("empty collection") { - it("$isLessThanFun(1.0) throws AssertionError") { + it("throws AssertionError as there needs to be at least one element") { expect { - fluentEmpty.allFun { isLessThan(1.0) } + expect(fluentEmpty()).allFun { isLessThan(1.0) } }.toThrow { messageContains( "$rootBulletPoint$featureArrow$hasElement: false$separator" + @@ -95,7 +95,7 @@ abstract class IterableAllAssertionsSpec( nullableCases(describePrefix) { - describeFun("${allNullable.name} for nullable") { + describeFun(allNullable) { val allNullableFun = allNullable.lambda val iterableOfNulls = { sequenceOf(null, null).constrainOnce().asIterable() } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyAssertionsSpec.kt index cb16dfdb3..eb07fbcb2 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyAssertionsSpec.kt @@ -8,6 +8,7 @@ import ch.tutteli.atrium.domain.builders.migration.asAssert import ch.tutteli.atrium.domain.builders.migration.asExpect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionComparableAssertion +import ch.tutteli.atrium.translations.DescriptionIterableAssertion import ch.tutteli.atrium.translations.ErrorMessages abstract class IterableAnyAssertionsSpec( @@ -15,7 +16,7 @@ abstract class IterableAnyAssertionsSpec( anyNullable: Fun1, (Expect.() -> Unit)?>, rootBulletPoint: String, describePrefix: String = "[Atrium] " -) : IterablePredicateSpecBase({ +) : IterableContainsEntriesSpecBase({ val isGreaterThanDescr = DescriptionComparableAssertion.IS_GREATER_THAN.getDefault() @@ -43,9 +44,9 @@ abstract class IterableAnyAssertionsSpec( ) { anyFun -> context("empty collection") { - it("$isLessThanFun(1.0) throws AssertionError") { + it("throws AssertionError as there needs to be at least one element") { expect { - fluentEmpty.anyFun { isLessThan(1.0) } + expect(fluentEmpty()).anyFun { isLessThan(1.0) } }.toThrow { messageContains( "$rootBulletPoint$containsInAnyOrder: $separator", @@ -54,12 +55,13 @@ abstract class IterableAnyAssertionsSpec( "$numberOfOccurrences: 0", "$atLeast: 1" ) + } } //TODO remove with 1.0.0 it("$returnValueOfFun(...) states warning that subject is not set") { expect { - fluentEmpty.anyFun { + expect(fluentEmpty()).anyFun { @Suppress("DEPRECATION") asAssert().returnValueOf(subject::dec).asExpect().toBe(1.0) } @@ -98,7 +100,7 @@ abstract class IterableAnyAssertionsSpec( nullableCases(describePrefix) { - describeFun("${anyNullable.name} for nullable") { + describeFun(anyNullable) { val anyNullableFun = anyNullable.lambda context("iterable ${oneToSevenNullable().toList()}") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAssertionsSpec.kt index 716e51eee..f86a8912c 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAssertionsSpec.kt @@ -3,12 +3,7 @@ package ch.tutteli.atrium.specs.integration import ch.tutteli.atrium.api.fluent.en_GB.messageContains import ch.tutteli.atrium.api.fluent.en_GB.toThrow import ch.tutteli.atrium.api.verbs.internal.expect -import ch.tutteli.atrium.specs.Fun0 -import ch.tutteli.atrium.specs.SubjectLessSpec -import ch.tutteli.atrium.specs.describeFunTemplate -import ch.tutteli.atrium.specs.forSubjectLess -import ch.tutteli.atrium.specs.lambda -import ch.tutteli.atrium.specs.name +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionBasic import ch.tutteli.atrium.translations.DescriptionIterableAssertion import org.spekframework.spek2.Spek @@ -25,15 +20,14 @@ abstract class IterableAssertionsSpec( hasNext.forSubjectLess() ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val hasDescriptionBasic = DescriptionBasic.HAS.getDefault() val hasNotDescriptionBasic = DescriptionBasic.HAS_NOT.getDefault() val nextElement = DescriptionIterableAssertion.NEXT_ELEMENT.getDefault() - describeFun(hasNext.name) { + describeFun(hasNext) { val hasNextFun = hasNext.lambda it("does not throw if an iterable has next") { @@ -47,7 +41,7 @@ abstract class IterableAssertionsSpec( } } - describeFun(hasNotNext.name) { + describeFun(hasNotNext) { val hasNotNextFun = hasNotNext.lambda it("does not throw if an iterable has not next") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsEntriesSpecBase.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsEntriesSpecBase.kt index 2f9d17731..0f71210f5 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsEntriesSpecBase.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsEntriesSpecBase.kt @@ -1,22 +1,14 @@ package ch.tutteli.atrium.specs.integration -import ch.tutteli.atrium.api.cc.en_GB.returnValueOf import ch.tutteli.atrium.api.fluent.en_GB.isGreaterThan import ch.tutteli.atrium.api.fluent.en_GB.isLessThan import ch.tutteli.atrium.api.fluent.en_GB.toBe -import ch.tutteli.atrium.api.verbs.internal.expect -import ch.tutteli.atrium.creating.Assert import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.builders.migration.asAssert import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.translations.DescriptionComparableAssertion import ch.tutteli.atrium.translations.DescriptionIterableAssertion import org.spekframework.spek2.dsl.Root -import org.spekframework.spek2.style.specification.Suite -import org.spekframework.spek2.style.specification.describe -import kotlin.reflect.KFunction -import kotlin.reflect.KFunction0 abstract class IterableContainsEntriesSpecBase( spec: Root.() -> Unit @@ -26,8 +18,7 @@ abstract class IterableContainsEntriesSpecBase( isGreaterThanFun = Expect::isGreaterThan.name toBeFun = fun1(Expect::toBe).name //TODO remove with 1.0.0 - @Suppress("DEPRECATION") val f: (KFunction0) -> Assert = expect(1).asAssert()::returnValueOf - returnValueOfFun = (f as KFunction<*>).name + returnValueOfFun = "returnValueOf" } companion object { @@ -38,26 +29,5 @@ abstract class IterableContainsEntriesSpecBase( val anEntryWhich = DescriptionIterableAssertion.AN_ENTRY_WHICH.getDefault() val isLessThanDescr = DescriptionComparableAssertion.IS_LESS_THAN.getDefault() val isGreaterThanDescr = DescriptionComparableAssertion.IS_GREATER_THAN.getDefault() - - fun Root.nonNullableCases( - describePrefix: String, - containsPair: Pair>.(Expect.() -> Unit, Array.() -> Unit>) -> Expect>>, - containsNullablePair: Pair>.((Expect.() -> Unit)?, Array.() -> Unit)?>) -> Expect>>, - action: Suite.(Expect>.(Expect.() -> Unit, Array.() -> Unit>) -> Any) -> Unit - ) { - describe("$describePrefix describe non-nullable cases") { - mapOf>.(Expect.() -> Unit, Array.() -> Unit>) -> Any>( - containsPair.first to { a, aX -> containsPair.second(this, a, aX) }, - containsNullablePair.first to { a, aX -> - @Suppress("UNCHECKED_CAST") - containsNullablePair.second(this as Expect>, a, aX) - } - ).forEach { (describe, containsEntriesFunArr) -> - describeFun(describe) { - action(containsEntriesFunArr) - } - } - } - } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt index 0e319c462..92c181ce8 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt @@ -60,7 +60,7 @@ abstract class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec( context("empty collection") { it("$isLessThanFun(1.0) throws AssertionError") { expect { - fluentEmpty.containsEntriesFun({ isLessThan(1.0) }) + expect(fluentEmpty()).containsEntriesFun({ isLessThan(1.0) }) }.toThrow { message { contains.exactly(1).values( @@ -75,7 +75,7 @@ abstract class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec( } it("$isLessThanFun(1.0) and $isGreaterThanFun(2.0) throws AssertionError") { expect { - fluentEmpty.containsEntriesFun({ isLessThan(1.0) }, { isGreaterThan(2.0) }) + expect(fluentEmpty()).containsEntriesFun({ isLessThan(1.0) }, { isGreaterThan(2.0) }) }.toThrow { message { contains.exactly(2).values( @@ -94,7 +94,7 @@ abstract class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec( //TODO remove with 1.0.0 it("$returnValueOfFun(...) states warning that subject is not set") { expect { - fluentEmpty.containsEntriesFun({ + expect(fluentEmpty()).containsEntriesFun({ @Suppress("DEPRECATION") asAssert().returnValueOf(subject::dec).asExpect().toBe(1.0) }) @@ -143,7 +143,7 @@ abstract class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec( nullableCases(describePrefix) { - describeFun("${containsInAnyOrderNullableEntries.name} for nullable") { + describeFun(containsInAnyOrderNullableEntries) { context("iterable ${oneToSevenNullable().toList()}") { context("happy cases (do not throw)") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt index 7c7321eca..e422d08f3 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt @@ -37,7 +37,7 @@ abstract class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec( context("empty collection") { it("1.0 throws AssertionError") { expect { - fluentEmpty.containsFun(1.0) + expect(fluentEmpty()).containsFun(1.0) }.toThrow { messageContains( "$rootBulletPoint$containsInAnyOrder: $separator", @@ -113,7 +113,7 @@ abstract class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec( nullableCases(describePrefix) { - describeFun("${containsInAnyOrderNullableValues.name} for nullable") { + describeFun(containsInAnyOrderNullableValues) { context("iterable ${oneToSevenNullable().toList()}") { listOf( diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeastValuesAssertionSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeastValuesAssertionSpec.kt index edc5566eb..f4363eb0e 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeastValuesAssertionSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtLeastValuesAssertionSpec.kt @@ -25,8 +25,8 @@ abstract class IterableContainsInAnyOrderAtLeastValuesAssertionSpec( containsAtLeastButAtMost.forSubjectLess(1, 2, 2.3, arrayOf()) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) fun Expect>.containsAtLeastFun(atLeast: Int, a: Double, vararg aX: Double) = containsAtLeast(this, atLeast, a, aX.toTypedArray()) @@ -37,7 +37,7 @@ abstract class IterableContainsInAnyOrderAtLeastValuesAssertionSpec( val (containsNot, errorMsgContainsNot) = containsNotPair val (exactly, errorMsgExactly) = exactlyPair - describeFun(containsAtLeast.name, containsAtLeastButAtMost.name) { + describeFun(containsAtLeast, containsAtLeastButAtMost) { context("throws an $illegalArgumentException") { it("for at least -1 -- only positive numbers") { expect { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtMostValuesAssertionSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtMostValuesAssertionSpec.kt index ed3c654fd..3a6310df2 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtMostValuesAssertionSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderAtMostValuesAssertionSpec.kt @@ -21,8 +21,8 @@ abstract class IterableContainsInAnyOrderAtMostValuesAssertionSpec( containsAtMost.forSubjectLess(2, 2.3, arrayOf()) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) fun Expect>.containsAtMostFun(atLeast: Int, a: Double, vararg aX: Double) = containsAtMost(this, atLeast, a, aX.toTypedArray()) @@ -30,7 +30,7 @@ abstract class IterableContainsInAnyOrderAtMostValuesAssertionSpec( val (containsNot, errorMsgContainsNot) = containsNotPair val (exactly, errorMsgExactly) = exactlyPair - describeFun(containsAtMost.name) { + describeFun(containsAtMost) { context("throws an $illegalArgumentException") { it("for at most -1 -- only positive numbers") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt index 0fcecfffd..dd63b67c3 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt @@ -21,8 +21,8 @@ abstract class IterableContainsInAnyOrderExactlyValuesAssertionsSpec( containsExactly.forSubjectLess(2, 2.3, arrayOf()) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) fun Expect>.containsExactlyFun(atLeast: Int, a: Double, vararg aX: Double) = containsExactly.invoke(this, atLeast, a, aX.toTypedArray()) @@ -31,7 +31,7 @@ abstract class IterableContainsInAnyOrderExactlyValuesAssertionsSpec( val exactly = EXACTLY.getDefault() - describeFun(containsExactly.name) { + describeFun(containsExactly) { context("throws an $illegalArgumentException") { it("for exactly -1 -- only positive numbers") { expect { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt index 85f21e798..79ba56907 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt @@ -20,15 +20,15 @@ abstract class IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec( containsNotOrAtMost.forSubjectLess(2, 2.3, arrayOf()) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) fun Expect>.containsNotOrAtMostFun(atLeast: Int, a: Double, vararg aX: Double) = containsNotOrAtMost(this, atLeast, a, aX.toTypedArray()) val (containsNot, errorMsgContainsNot) = containsNotPair - describeFun(containsNotOrAtMost.name) { + describeFun(containsNotOrAtMost) { context("throws an $illegalArgumentException") { it("for not at all or at most -1 -- only positive numbers") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt index b488eecf0..61ca4afc6 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt @@ -73,7 +73,7 @@ abstract class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec( context("empty collection") { it("$isLessThanFun(1.0) throws AssertionError") { expect { - fluentEmpty.containsEntriesFun({ isLessThan(1.0) }) + expect(fluentEmpty()).containsEntriesFun({ isLessThan(1.0) }) }.toThrow { message { contains( @@ -87,7 +87,7 @@ abstract class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec( } it("$isLessThanFun(1.0) and $isGreaterThanFun(4.0) throws AssertionError") { expect { - fluentEmpty.containsEntriesFun({ isLessThan(1.0) }, { isGreaterThan(4.0) }) + expect(fluentEmpty()).containsEntriesFun({ isLessThan(1.0) }, { isGreaterThan(4.0) }) }.toThrow { message { contains.exactly(1).values( @@ -104,7 +104,7 @@ abstract class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec( //TODO remove with 1.0.0 it("$returnValueOfFun(...) states warning that subject is not set") { expect { - fluentEmpty.containsEntriesFun({ + expect(fluentEmpty()).containsEntriesFun({ @Suppress("DEPRECATION") asAssert().returnValueOf(subject::dec).asExpect().toBe(1.0) }) @@ -292,7 +292,7 @@ abstract class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec( nullableCases(describePrefix) { - describeFun("${containsInAnyOrderOnlyNullableEntries.name} for nullable") { + describeFun(containsInAnyOrderOnlyNullableEntries) { val null1null3 = { sequenceOf(null, 1.0, null, 3.0).constrainOnce().asIterable() } context("iterable ${null1null3().toList()}") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt index e195957db..68bcbf64e 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.Fun2 import ch.tutteli.atrium.specs.SubjectLessSpec import ch.tutteli.atrium.specs.forSubjectLess +import ch.tutteli.atrium.specs.invoke abstract class IterableContainsInAnyOrderOnlyValuesAssertionsSpec( containsInAnyOrderOnlyValues: Fun2, Double, Array>, @@ -28,9 +29,8 @@ abstract class IterableContainsInAnyOrderOnlyValuesAssertionsSpec( containsInAnyOrderOnlyNullableValues.forSubjectLess(2.5, arrayOf()) ) {}) - val (containsInOrderNullableValues, containsInOrderNullableValuesFunArr) = containsInAnyOrderOnlyNullableValues - fun Expect>.containsInOrderNullableValuesFun(t: Double?, vararg tX: Double?) = - containsInOrderNullableValuesFunArr(t, tX) + fun Expect>.containsInAnyOrderNullableValuesFun(t: Double?, vararg tX: Double?) = + containsInAnyOrderOnlyNullableValues(this, t, tX) nonNullableCases( describePrefix, @@ -44,7 +44,7 @@ abstract class IterableContainsInAnyOrderOnlyValuesAssertionsSpec( context("empty collection") { it("1.0 throws AssertionError") { expect { - fluentEmpty.containsFun(1.0) + expect(fluentEmpty()).containsFun(1.0) }.toThrow { message { contains( @@ -58,7 +58,7 @@ abstract class IterableContainsInAnyOrderOnlyValuesAssertionsSpec( } it("1.0 and 4.0 throws AssertionError") { expect { - fluentEmpty.containsFun(1.0, 4.0) + expect(fluentEmpty()).containsFun(1.0, 4.0) }.toThrow { message { contains.exactly(1).values( @@ -200,30 +200,30 @@ abstract class IterableContainsInAnyOrderOnlyValuesAssertionsSpec( nullableCases(describePrefix) { - describeFun("$containsInOrderNullableValues for nullable") { + describeFun(containsInAnyOrderOnlyValues) { val null1null3 = { sequenceOf(null, 1.0, null, 3.0).constrainOnce().asIterable() } context("iterable ${null1null3().toList()}") { context("happy cases (do not throw)") { it("null, 1.0, null, 3.0") { - expect(null1null3()).containsInOrderNullableValuesFun(null, 1.0, null, 3.0) + expect(null1null3()).containsInAnyOrderNullableValuesFun(null, 1.0, null, 3.0) } it("1.0, null, null, 3.0") { - expect(null1null3()).containsInOrderNullableValuesFun(1.0, null, null, 3.0) + expect(null1null3()).containsInAnyOrderNullableValuesFun(1.0, null, null, 3.0) } it("1.0, null, 3.0, null") { - expect(null1null3()).containsInOrderNullableValuesFun(1.0, null, 3.0, null) + expect(null1null3()).containsInAnyOrderNullableValuesFun(1.0, null, 3.0, null) } it("1.0, 3.0, null, null") { - expect(null1null3()).containsInOrderNullableValuesFun(1.0, 3.0, null, null) + expect(null1null3()).containsInAnyOrderNullableValuesFun(1.0, 3.0, null, null) } } context("failing cases") { it("null, 1.0, 3.0 -- null was missing") { expect { - expect(null1null3()).containsInOrderNullableValuesFun(null, 1.0, 3.0) + expect(null1null3()).containsInAnyOrderNullableValuesFun(null, 1.0, 3.0) }.toThrow { message { contains.exactly(1).values( diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt index 1129bc145..d1805e1fb 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt @@ -49,9 +49,6 @@ abstract class IterableContainsInOrderOnlyEntriesAssertionsSpec( ) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - fun Expect>.containsInOrderOnlyNullableEntriesFun( t: (Expect.() -> Unit)?, vararg tX: (Expect.() -> Unit)? @@ -103,7 +100,7 @@ abstract class IterableContainsInOrderOnlyEntriesAssertionsSpec( context("empty collection") { it("$isLessThanFun(1.0) throws AssertionError") { expect { - fluentEmpty.containsEntriesFun({ isLessThan(1.0) }) + expect(fluentEmpty()).containsEntriesFun({ isLessThan(1.0) }) }.toThrow { message { contains("$rootBulletPoint$containsInOrderOnly:") @@ -115,7 +112,7 @@ abstract class IterableContainsInOrderOnlyEntriesAssertionsSpec( } it("$isLessThanFun(1.0) and $isGreaterThanFun(4.0) throws AssertionError") { expect { - fluentEmpty.containsEntriesFun({ isLessThan(1.0) }, { isGreaterThan(4.0) }) + expect(fluentEmpty()).containsEntriesFun({ isLessThan(1.0) }, { isGreaterThan(4.0) }) }.toThrow { message { contains.exactly(1).value("$rootBulletPoint$containsInOrderOnly:") @@ -129,7 +126,7 @@ abstract class IterableContainsInOrderOnlyEntriesAssertionsSpec( //TODO remove with 1.0.0 it("$returnValueOfFun(...) states warning that subject is not set") { expect { - fluentEmpty.containsEntriesFun({ + expect(fluentEmpty()).containsEntriesFun({ @Suppress("DEPRECATION") asAssert().returnValueOf(subject::dec).asExpect().toBe(1.0) }) @@ -271,7 +268,7 @@ abstract class IterableContainsInOrderOnlyEntriesAssertionsSpec( nullableCases(describePrefix) { - describeFun("${containsInOrderOnlyNullableEntries.name} for nullable") { + describeFun(containsInOrderOnlyNullableEntries) { val null1null3 = { sequenceOf(null, 1.0, null, 3.0).constrainOnce().asIterable() } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt index 4a403e17e..cbea341d2 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt @@ -8,7 +8,6 @@ import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE import ch.tutteli.atrium.translations.DescriptionIterableAssertion import org.spekframework.spek2.style.specification.Suite -import org.spekframework.spek2.style.specification.describe abstract class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec( containsInOrderOnlyGroupedValues: Fun3, Group, Group, Array>>, @@ -37,9 +36,6 @@ abstract class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec( containsInOrderOnlyGroupedNullableValues.forSubjectLess(nullableGroup(2.5), nullableGroup(4.1), arrayOf()) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - fun Expect>.containsInOrderOnlyGroupedNullableValuesFun( t1: Group, t2: Group, @@ -137,187 +133,167 @@ abstract class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec( ) } - fun groupToNullableGroup(group: Group) = nullableGroup(*group.toList().toTypedArray()) + nonNullableCases( + describePrefix, + containsInOrderOnlyGroupedValues, + containsInOrderOnlyGroupedNullableValues + ) { containsFunArr -> - describe("$describePrefix describe non-nullable cases") { - mapOf>.(Group, Group, Array>) -> Any>( - containsInOrderOnlyGroupedValues.name to { g1, g2, gX -> - containsInOrderOnlyGroupedValues( - this, - g1, - g2, - gX - ) - }, - "$containsInOrderOnlyGroupedNullableValues for nullable" to { g1, g2, gX -> - @Suppress("UNCHECKED_CAST") - containsInOrderOnlyGroupedNullableValues( - this as Expect>, - groupToNullableGroup(g1), - groupToNullableGroup(g2), - gX.map { groupToNullableGroup(it) }.toTypedArray() - ) + fun Expect>.containsFun(t1: Group, t2: Group, vararg tX: Group) = + containsFunArr(t1, t2, tX) + + context("throws an $illegalArgumentException") { + it("if an empty group is given as first parameter") { + expect { + expect(oneToFour()).containsFun(context(), context(-1.2)) + }.toThrow { messageContains("a group of values cannot be empty") } } - ).forEach { (describe, containsFunArr) -> + it("if an empty group is given as second parameter") { + expect { + expect(oneToFour()).containsFun(context(1.2), context()) + }.toThrow { messageContains("a group of values cannot be empty") } + } + it("if an empty group is given as third parameter") { + expect { + expect(oneToFour()).containsFun(context(1.2), context(4.3), context()) + }.toThrow { messageContains("a group of values cannot be empty") } + } + it("if an empty group is given as fourth parameter") { + expect { + expect(oneToFour()).containsFun(context(1.2), context(4.3), context(5.7), context()) + }.toThrow { messageContains("a group of values cannot be empty") } + } + } - fun Expect>.containsFun(t1: Group, t2: Group, vararg tX: Group) = - containsFunArr(t1, t2, tX) - - describeFun(describe) { - context("throws an $illegalArgumentException") { - it("if an empty group is given as first parameter") { - expect { - expect(oneToFour()).containsFun(context(), context(-1.2)) - }.toThrow { messageContains("a group of values cannot be empty") } - } - it("if an empty group is given as second parameter") { - expect { - expect(oneToFour()).containsFun(context(1.2), context()) - }.toThrow { messageContains("a group of values cannot be empty") } - } - it("if an empty group is given as third parameter") { - expect { - expect(oneToFour()).containsFun(context(1.2), context(4.3), context()) - }.toThrow { messageContains("a group of values cannot be empty") } - } - it("if an empty group is given as fourth parameter") { - expect { - expect(oneToFour()).containsFun(context(1.2), context(4.3), context(5.7), context()) - }.toThrow { messageContains("a group of values cannot be empty") } + context("empty collection") { + it("(1.0), (1.2) throws AssertionError") { + expect { + expect(fluentEmpty()).containsFun(context(1.0), context(1.2)) + }.toThrow { + message { + contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") + indexFail(0, sizeExceeded, 1.0) + indexFail(1, sizeExceeded, 1.2) + containsNot(additionalEntries) + containsSize(0, 2) } } + } + } - context("empty collection") { - it("(1.0), (1.2) throws AssertionError") { - expect { - fluentEmpty.containsFun(context(1.0), context(1.2)) - }.toThrow { - message { - contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") - indexFail(0, sizeExceeded, 1.0) - indexFail(1, sizeExceeded, 1.2) - containsNot(additionalEntries) - containsSize(0, 2) - } + context("iterable ${oneToFour().toList()}") { + + context("happy case") { + it("(1.0), (2.0, 3.0), (4.0, 4.0)") { + expect(oneToFour()).containsFun(context(1.0), context(2.0, 3.0), context(4.0, 4.0)) + } + it("(2.0, 1.0), (4.0, 3.0), (4.0)") { + expect(oneToFour()).containsFun(context(2.0, 1.0), context(4.0, 3.0), context(4.0)) + } + it("(2.0, 3.0, 1.0), (4.0), (4.0)") { + expect(oneToFour()).containsFun(context(2.0, 3.0, 1.0), context(4.0), context(4.0)) + } + it("(1.0, 2.0), (4.0, 3.0, 4.0)") { + expect(oneToFour()).containsFun(context(1.0, 2.0), context(4.0, 3.0, 4.0)) + } + } + + context("error cases (throws AssertionError)") { + + it("(4.0, 1.0), (2.0, 3.0, 4.0) -- wrong order") { + expect { + expect(oneToFour()).containsFun(context(4.0, 1.0), context(2.0, 3.0, 4.0)) + }.toThrow { + message { + contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") + indexFail( + 0, 1, listOf(1.0, 2.0), + failAfterFail(4.0), + successAfterFail(1.0), + successSizeAfterFail(2), + mismatchesAfterFail(2.0) + ) + indexFail( + 2, 4, listOf(3.0, 4.0, 4.0), + failAfterFail(2.0), + successAfterFail(3.0), + successAfterFail(4.0), + successSizeAfterFail(3), + mismatchesAfterFail(4.0) + ) + containsRegex(size(indentBulletPoint, successfulBulletPoint, 5, 5)) } } } - context("iterable ${oneToFour().toList()}") { - - context("happy case") { - it("(1.0), (2.0, 3.0), (4.0, 4.0)") { - expect(oneToFour()).containsFun(context(1.0), context(2.0, 3.0), context(4.0, 4.0)) - } - it("(2.0, 1.0), (4.0, 3.0), (4.0)") { - expect(oneToFour()).containsFun(context(2.0, 1.0), context(4.0, 3.0), context(4.0)) - } - it("(2.0, 3.0, 1.0), (4.0), (4.0)") { - expect(oneToFour()).containsFun(context(2.0, 3.0, 1.0), context(4.0), context(4.0)) - } - it("(1.0, 2.0), (4.0, 3.0, 4.0)") { - expect(oneToFour()).containsFun(context(1.0, 2.0), context(4.0, 3.0, 4.0)) + it("(1.0), (4.0, 3.0, 2.0) -- 4.0 was missing") { + expect { + expect(oneToFour()).containsFun(context(1.0), context(4.0, 2.0, 3.0)) + }.toThrow { + message { + contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") + indexSuccess(0, 1.0) + indexSuccess( + 1, 3, listOf(2.0, 3.0, 4.0), + successAfterSuccess(4.0, 2.0, 3.0), + successSizeAfterSuccess(3) + ) + containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 4)) + containsRegex(additional(4 to 4.0)) } } + } - context("error cases (throws AssertionError)") { - - it("(4.0, 1.0), (2.0, 3.0, 4.0) -- wrong order") { - expect { - expect(oneToFour()).containsFun(context(4.0, 1.0), context(2.0, 3.0, 4.0)) - }.toThrow { - message { - contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") - indexFail( - 0, 1, listOf(1.0, 2.0), - failAfterFail(4.0), - successAfterFail(1.0), - successSizeAfterFail(2), - mismatchesAfterFail(2.0) - ) - indexFail( - 2, 4, listOf(3.0, 4.0, 4.0), - failAfterFail(2.0), - successAfterFail(3.0), - successAfterFail(4.0), - successSizeAfterFail(3), - mismatchesAfterFail(4.0) - ) - containsRegex(size(indentBulletPoint, successfulBulletPoint, 5, 5)) - } - } + it("(1.0), (4.0) -- 2.0, 3.0 and 4.0 was missing") { + expect { + expect(oneToFour()).containsFun(context(1.0), context(4.0)) + }.toThrow { + message { + contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") + indexSuccess(0, 1.0) + indexFail(1, 2.0, 4.0) + containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 2)) + containsRegex(additional(2 to 3.0, 3 to 4.0, 4 to 4.0)) } - - it("(1.0), (4.0, 3.0, 2.0) -- 4.0 was missing") { - expect { - expect(oneToFour()).containsFun(context(1.0), context(4.0, 2.0, 3.0)) - }.toThrow { - message { - contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") - indexSuccess(0, 1.0) - indexSuccess( - 1, 3, listOf(2.0, 3.0, 4.0), - successAfterSuccess(4.0, 2.0, 3.0), - successSizeAfterSuccess(3) - ) - containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 4)) - containsRegex(additional(4 to 4.0)) - } - } + } + } + it("(1.0, 3.0), (5.0) -- 5.0 is wrong and 4.0 and 4.0 are missing") { + expect { + expect(oneToFour()).containsFun(context(1.0, 3.0), context(5.0)) + }.toThrow { + message { + contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") + indexFail( + 0, 1, listOf(1.0, 2.0), + successAfterFail(1.0), + failAfterFail(3.0), + successSizeAfterFail(2), + mismatchesAfterFail(2.0) + ) + indexFail(2, 3.0, 5.0) + containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 3)) + containsRegex(additional(3 to 4.0, 4 to 4.0)) } - - it("(1.0), (4.0) -- 2.0, 3.0 and 4.0 was missing") { - expect { - expect(oneToFour()).containsFun(context(1.0), context(4.0)) - }.toThrow { - message { - contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") - indexSuccess(0, 1.0) - indexFail(1, 2.0, 4.0) - containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 2)) - containsRegex(additional(2 to 3.0, 3 to 4.0, 4 to 4.0)) - } - } - } - it("(1.0, 3.0), (5.0) -- 5.0 is wrong and 4.0 and 4.0 are missing") { - expect { - expect(oneToFour()).containsFun(context(1.0, 3.0), context(5.0)) - }.toThrow { - message { - contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") - indexFail( - 0, 1, listOf(1.0, 2.0), - successAfterFail(1.0), - failAfterFail(3.0), - successSizeAfterFail(2), - mismatchesAfterFail(2.0) - ) - indexFail(2, 3.0, 5.0) - containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 3)) - containsRegex(additional(3 to 4.0, 4 to 4.0)) - } - } - } - it("( 4.0, 1.0, 3.0, 2.0), (5.0, 4.0) -- 5.0 too much") { - expect { - expect(oneToFour()).containsFun(context(4.0, 1.0, 3.0, 2.0), context(5.0, 4.0)) - }.toThrow { - message { - contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") - indexSuccess( - 0, 3, listOf(1.0, 2.0, 3.0, 4.0), - successAfterSuccess(4.0, 1.0, 3.0, 2.0), - successSizeAfterSuccess(4) - ) - indexFail( - 4, 5, listOf(4.0), - failAfterFail(5.0), - successAfterFail(4.0), - failSizeAfterFail(1, 2) - ) - containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 6)) - } - } + } + } + it("( 4.0, 1.0, 3.0, 2.0), (5.0, 4.0) -- 5.0 too much") { + expect { + expect(oneToFour()).containsFun(context(4.0, 1.0, 3.0, 2.0), context(5.0, 4.0)) + }.toThrow { + message { + contains.exactly(1).value("$rootBulletPoint$containsInOrderOnlyGrouped:") + indexSuccess( + 0, 3, listOf(1.0, 2.0, 3.0, 4.0), + successAfterSuccess(4.0, 1.0, 3.0, 2.0), + successSizeAfterSuccess(4) + ) + indexFail( + 4, 5, listOf(4.0), + failAfterFail(5.0), + successAfterFail(4.0), + failSizeAfterFail(1, 2) + ) + containsRegex(size(indentBulletPoint, failingBulletPoint, 5, 6)) } } } @@ -327,7 +303,7 @@ abstract class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec( nullableCases(describePrefix) { - describeFun("$containsInOrderOnlyGroupedNullableValues for nullable") { + describeFun(containsInOrderOnlyGroupedNullableValues) { val null1null3 = { sequenceOf(null, 1.0, null, 3.0).constrainOnce().asIterable() } context("iterable ${null1null3().toList()}") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyValuesAssertionsSpec.kt index 2338a56a0..4a7f77be8 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsInOrderOnlyValuesAssertionsSpec.kt @@ -71,7 +71,7 @@ abstract class IterableContainsInOrderOnlyValuesAssertionsSpec( context("empty collection") { it("1.0 throws AssertionError") { expect { - fluentEmpty.containsFun(1.0) + expect(fluentEmpty()).containsFun(1.0) }.toThrow { message { contains("$rootBulletPoint$containsInOrderOnly:") @@ -83,7 +83,7 @@ abstract class IterableContainsInOrderOnlyValuesAssertionsSpec( } it("1.0 and 4.0 throws AssertionError") { expect { - fluentEmpty.containsFun(1.0, 4.0) + expect(fluentEmpty()).containsFun(1.0, 4.0) }.toThrow { message { contains("$rootBulletPoint$containsInOrderOnly:") @@ -199,7 +199,7 @@ abstract class IterableContainsInOrderOnlyValuesAssertionsSpec( nullableCases(describePrefix) { - describeFun("${containsInOrderOnlyNullableValues.name} for nullable") { + describeFun(containsInOrderOnlyNullableValues) { val null1null3 = { sequenceOf(null, 1.0, null, 3.0).constrainOnce().asIterable() } context("iterable ${null1null3().toList()}") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotEntriesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotEntriesAssertionsSpec.kt index 7b8285425..97257e0d1 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotEntriesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotEntriesAssertionsSpec.kt @@ -47,10 +47,6 @@ abstract class IterableContainsNotEntriesAssertionsSpec( ) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - - fun Expect>.containsNotNullableFun( a: (Expect.() -> Unit)?, vararg aX: (Expect.() -> Unit)? @@ -177,7 +173,7 @@ abstract class IterableContainsNotEntriesAssertionsSpec( } nullableCases(describePrefix) { - describeFun("${containsNotNullableEntries.name} for nullable") { + describeFun(containsNotNullableEntries) { context("iterable ${oneToSeven().toList()}") { it("null does not throw") { expect(oneToSeven() as Iterable).containsNotNullableFun(null) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotValuesAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotValuesAssertionsSpec.kt index 6ca3ab444..b13a1b059 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotValuesAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsNotValuesAssertionsSpec.kt @@ -31,10 +31,6 @@ abstract class IterableContainsNotValuesAssertionsSpec( containsNotNullableValues.forSubjectLess(2.3, arrayOf()) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - - fun Expect>.containsNotNullableFun(a: Double?, vararg aX: Double?) = containsNotNullableValues(this, a, aX) @@ -69,7 +65,7 @@ abstract class IterableContainsNotValuesAssertionsSpec( it("4.0 throws AssertionError") { expect { - fluentEmpty.containsNotFun(4.0) + expect(fluentEmpty()).containsNotFun(4.0) }.toThrow { message { containsRegex( @@ -164,7 +160,7 @@ abstract class IterableContainsNotValuesAssertionsSpec( } nullableCases(describePrefix) { - describeFun("${containsNotNullableValues.name} for nullable") { + describeFun(containsNotNullableValues) { context("iterable ${oneToSeven().toList()}") { it("null does not throw") { expect(oneToSeven() as Iterable).containsNotNullableFun(null) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsSpecBase.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsSpecBase.kt index b618ed894..3c8fed80b 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsSpecBase.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableContainsSpecBase.kt @@ -3,10 +3,8 @@ package ch.tutteli.atrium.specs.integration import ch.tutteli.atrium.api.fluent.en_GB.contains import ch.tutteli.atrium.api.fluent.en_GB.exactly import ch.tutteli.atrium.api.fluent.en_GB.regex -import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.format -import ch.tutteli.atrium.specs.lineSeperator +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionIterableAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.dsl.Root @@ -48,35 +46,31 @@ abstract class IterableContainsSpecBase(spec: Root.() -> Unit) : Spek(spec) { val atLeast = DescriptionIterableAssertion.AT_LEAST.getDefault() val atMost = DescriptionIterableAssertion.AT_MOST.getDefault() - val fluentEmpty = expect(setOf() as Iterable) + val fluentEmpty = { sequenceOf().constrainOnce().asIterable() } val illegalArgumentException = IllegalArgumentException::class.simpleName val separator = lineSeperator fun Expect.containsSize(actual: Int, expected: Int) = contains.exactly(1).regex("size: $actual[^:]+: $expected") - fun Suite.describeFun(funName: String, body: Suite.() -> Unit) = context("fun `$funName`", body = body) + fun Suite.describeFun(spec: SpecPair<*>, body: Suite.() -> Unit) = describeFun(spec.name, body) + private fun Suite.describeFun(funName: String, body: Suite.() -> Unit) = context("fun `$funName`", body = body) fun Root.nullableCases(describePrefix: String, body: Suite.() -> Unit) { - describe("$describePrefix describe nullable cases", body = body) + describe("$describePrefix nullable cases", body = body) } - fun Root.nonNullableCases( + fun Root.nonNullableCases( describePrefix: String, - containsPair: Pair>.(Double, Array) -> Expect>>, - containsNullablePair: Pair>.(Double?, Array) -> Expect>>, - action: Suite.(Expect>.(Double, Array) -> Any) -> Unit + nonNullableFun: SpecPair, + nullableFun: Any, + action: Suite.(F) -> Unit ) { - describe("$describePrefix describe non-nullable cases") { - mapOf>.(Double, Array) -> Any>( - containsPair.first to { a, aX -> containsPair.second(this, a, aX) }, - containsNullablePair.first to { a, aX -> - @Suppress("UNCHECKED_CAST") - containsNullablePair.second(this as Expect>, a, aX) - } - ).forEach { (describe, containsEntriesFunArr) -> - describeFun(describe) { - action(containsEntriesFunArr) + describe("$describePrefix non-nullable cases") { + val functions = uncheckedToNonNullable(nonNullableFun, nullableFun) + functions.forEach { (name, funArr) -> + describeFun(name) { + action(funArr) } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneAssertionsSpec.kt index 0e04479f4..a2f828069 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneAssertionsSpec.kt @@ -5,7 +5,6 @@ import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionIterableAssertion -import org.spekframework.spek2.style.specification.Suite abstract class IterableNoneAssertionsSpec( none: Fun1, Expect.() -> Unit>, @@ -18,7 +17,7 @@ abstract class IterableNoneAssertionsSpec( featureArrow: String, featureBulletPoint: String, describePrefix: String = "[Atrium] " -) : IterablePredicateSpecBase({ +) : IterableContainsEntriesSpecBase({ include(object : SubjectLessSpec>(describePrefix, none.forSubjectLess { toBe(2.3) } @@ -36,10 +35,6 @@ abstract class IterableNoneAssertionsSpec( noneNullable.forAssertionCreatorSpec("$isGreaterThanDescr: 10.0") { isGreaterThan(10.0) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - - val containsNotDescr = DescriptionIterableAssertion.CONTAINS_NOT.getDefault() val hasElement = DescriptionIterableAssertion.HAS_ELEMENT.getDefault() @@ -63,6 +58,16 @@ abstract class IterableNoneAssertionsSpec( noneNullable ) { noneFun -> + context("empty collection") { + it("throws AssertionError as there needs to be at least one element") { + expect { + expect(fluentEmpty()).noneFun { isLessThan(1.0) } + }.toThrow { + messageContains("$featureArrow$hasElement: false") + } + } + } + context("iterable ${oneToSeven().toList()}") { context("happy case") { listOf(1.1, 2.2, 3.3).forEach { @@ -93,9 +98,8 @@ abstract class IterableNoneAssertionsSpec( } } } - nullableCases(describePrefix) { - describeFun("${noneNullable.name} for nullable") { + describeFun(noneNullable) { val noneFun = noneNullable.lambda context("iterable ${oneToSeven().toList()}") { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterablePredicateSpecBase.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterablePredicateSpecBase.kt deleted file mode 100644 index 9d2e77cab..000000000 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterablePredicateSpecBase.kt +++ /dev/null @@ -1,33 +0,0 @@ -package ch.tutteli.atrium.specs.integration - -import ch.tutteli.atrium.creating.Expect -import org.spekframework.spek2.dsl.Root -import org.spekframework.spek2.style.specification.Suite -import org.spekframework.spek2.style.specification.describe - -abstract class IterablePredicateSpecBase(spec: Root.() -> Unit) : - IterableContainsEntriesSpecBase(spec) { - companion object { - - fun Root.nonNullableCases( - describePrefix: String, - containsPair: Pair>.(Expect.() -> Unit) -> Expect>>, - containsNullablePair: Pair>.((Expect.() -> Unit)?) -> Expect>>, - action: Suite.(Expect>.(Expect.() -> Unit) -> Any) -> Unit - ) { - describe("$describePrefix describe non-nullable cases") { - mapOf>.(Expect.() -> Unit) -> Any>( - containsPair.first to { a -> containsPair.second(this, a) }, - "${containsNullablePair.first} for nullable" to { a -> - @Suppress("UNCHECKED_CAST") - containsNullablePair.second(this as Expect>, a) - } - ).forEach { (describe, containsEntriesFunArr) -> - describeFun(describe) { - action(containsEntriesFunArr) - } - } - } - } - } -} diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt index feecd6b04..a59958291 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt @@ -75,7 +75,7 @@ abstract class ListFeatureAssertionsSpec( describeFun(getFeatureNullable, getNullable) { val getFunctions = unifySignatures(getFeatureNullable, getNullable) context("list $listNullable") { - getFunctions.forEach { (name, getFun, hasExtraHint) -> + getFunctions.forEach { (name, getFun, _) -> it("$name - can perform sub-assertion on existing index with value null") { fluentNullable.getFun(1) { toBe(null) } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt index b4fbf52ba..5f81787ca 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapAssertionsSpec.kt @@ -9,12 +9,20 @@ import ch.tutteli.atrium.translations.DescriptionComparableAssertion import ch.tutteli.atrium.translations.DescriptionMapAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite +import kotlin.reflect.KFunction3 + +typealias MFun2 = Fun2, Pair, Array>> + +fun mfun2( + f: KFunction3>, Pair, Array>, Expect>> +) = fun2(f) + abstract class MapAssertionsSpec( - contains: Fun2, Pair, Array>>, - containsNullable: Fun2, Pair, Array>>, - containsKeyWithValueAssertions: Fun2, Pair.() -> Unit>, Array.() -> Unit>>>, - containsKeyWithNullableValueAssertions: Fun2, Pair.() -> Unit)?>, Array.() -> Unit)?>>>, + contains: MFun2, + containsNullable: MFun2, + containsKeyWithValueAssertions: MFun2.() -> Unit>, + containsKeyWithNullableValueAssertions: MFun2.() -> Unit)?>, containsKey: Fun1, String>, containsKeyNullable: Fun1, String?>, containsNotKey: Fun1, String>, diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index c692059f9..591908af1 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -6,7 +6,6 @@ import ch.tutteli.atrium.core.polyfills.format import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.subExpect import ch.tutteli.atrium.translations.DescriptionBasic -import ch.tutteli.kbox.glue import kotlin.jvm.JvmName import kotlin.reflect.KFunction1 import kotlin.reflect.KFunction2 From 84a2c0a8980e0cac1f2c22ceb01b7d667d89819e Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 10:27:06 +0100 Subject: [PATCH 099/142] add JS-tests to test and not to check --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index f0d9d4a32..929bde2c5 100644 --- a/build.gradle +++ b/build.gradle @@ -472,11 +472,11 @@ def createJsTestTask(String... subprojectNames) { } task prepareMocha(dependsOn: [compileTestKotlin2Js, populateNodeModules, installMocha]) - task runMocha(type: NodeTask, dependsOn: [prepareMocha, test]) { + task runMocha(type: NodeTask, dependsOn: [prepareMocha]) { script = file("$nodeModulesParentDir/node_modules/mocha/bin/mocha") args = [compileTestKotlin2Js.outputFile] } - check.dependsOn runMocha + test.dependsOn runMocha } } From d4a613c1c9a11b2f5a7eda54d4fd07ee3ecebfa1 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 10:38:53 +0100 Subject: [PATCH 100/142] depend only on api and not on bundle in tests of core modules --- core/api/atrium-core-api-android/build.gradle | 2 +- core/api/atrium-core-api-js/build.gradle | 2 +- core/api/atrium-core-api-jvm/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/api/atrium-core-api-android/build.gradle b/core/api/atrium-core-api-android/build.gradle index da3cfc9ce..bce8f42d7 100644 --- a/core/api/atrium-core-api-android/build.gradle +++ b/core/api/atrium-core-api-android/build.gradle @@ -4,7 +4,7 @@ dependencies { api kbox(), excludeKotlin api kotlinReflect() - testImplementation prefixedProject('cc-infix-en_GB-robstoll-android') + testImplementation prefixedProject('api-cc-infix-en_GB-android') testImplementation prefixedProject('specs-android') } diff --git a/core/api/atrium-core-api-js/build.gradle b/core/api/atrium-core-api-js/build.gradle index 59ed687f8..adf762f36 100644 --- a/core/api/atrium-core-api-js/build.gradle +++ b/core/api/atrium-core-api-js/build.gradle @@ -3,6 +3,6 @@ description = 'API of the core of Atrium for the JS platform.' dependencies { api "ch.tutteli.kbox:kbox-js:$kbox_version", excludeKotlin - testImplementation prefixedProject('cc-infix-en_GB-robstoll-js') + testImplementation prefixedProject('api-cc-infix-en_GB-js') testImplementation prefixedProject('specs-js') } diff --git a/core/api/atrium-core-api-jvm/build.gradle b/core/api/atrium-core-api-jvm/build.gradle index 6643c8c12..f50672e8e 100644 --- a/core/api/atrium-core-api-jvm/build.gradle +++ b/core/api/atrium-core-api-jvm/build.gradle @@ -4,6 +4,6 @@ dependencies { api kbox(), excludeKotlin api kotlinReflect() - testImplementation prefixedProject('cc-infix-en_GB-robstoll-jvm') + testImplementation prefixedProject('api-cc-infix-en_GB-jvm') testImplementation prefixedProject('specs-jvm') } From 1ec86fe48f7689c45cfddd8a824714bb344d2093 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 10:51:49 +0100 Subject: [PATCH 101/142] move isADescr to testUtils --- .../ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt | 1 - .../atrium/specs/integration/ResultFeatureAssertionsSpec.kt | 1 - .../src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt | 2 ++ 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt index 9730d3e72..b87f7fcea 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt @@ -76,7 +76,6 @@ abstract class Fun0AssertionsSpec( } } - val isADescr = DescriptionAnyAssertion.IS_A.getDefault() val messageDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_MESSAGE.getDefault() val stackTraceDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_STACKTRACE.getDefault() val causeDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_CAUSE.getDefault() diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt index 3b8d69497..0538b34d7 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt @@ -67,7 +67,6 @@ abstract class ResultFeatureAssertionsSpec( val isNotSuccessDescr = DescriptionResultAssertion.IS_NOT_SUCCESS.getDefault() val isNotFailureDescr = DescriptionResultAssertion.IS_NOT_FAILURE.getDefault() val exceptionDescr = DescriptionResultAssertion.EXCEPTION.getDefault() - val isADescr = DescriptionAnyAssertion.IS_A.getDefault() describeFun(isSuccessFeature, isSuccess, isSuccessFeatureNullable, isSuccessNullable, isFailureFeature, isFailure) { val successFunctions = uncheckedToNonNullable( diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index 591908af1..bd50d8611 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -5,6 +5,7 @@ package ch.tutteli.atrium.specs import ch.tutteli.atrium.core.polyfills.format import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.subExpect +import ch.tutteli.atrium.translations.DescriptionAnyAssertion import ch.tutteli.atrium.translations.DescriptionBasic import kotlin.jvm.JvmName import kotlin.reflect.KFunction1 @@ -210,5 +211,6 @@ fun String.Companion.format(string: String, arg: Any, vararg otherArgs: Any): St val toBeDescr = DescriptionBasic.TO_BE.getDefault() val isDescr = DescriptionBasic.IS.getDefault() val isNotDescr = DescriptionBasic.IS_NOT.getDefault() +val isADescr = DescriptionAnyAssertion.IS_A.getDefault() expect val lineSeperator: String From ef44b5641bc58d7b14319d51620b91773abebd6d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 11:12:36 +0100 Subject: [PATCH 102/142] add Fun0AssertionsJvmSpec to the new infix API --- .../api/infix/en_GB/Fun0AssertionsJvmSpec.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsJvmSpec.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsJvmSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsJvmSpec.kt new file mode 100644 index 000000000..57347f264 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsJvmSpec.kt @@ -0,0 +1,22 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.feature0 +import ch.tutteli.atrium.specs.feature1 +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.withFeatureSuffix + +class Fun0AssertionsJvmSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsJvmSpec( + ("toThrow" to Companion::toThrowFeature).withFeatureSuffix(), + "toThrow" to Companion::toThrow, + feature0<() -> Int, Int>(Expect<() -> Int>::notToThrow), + feature1<() -> Int, Expect.() -> Unit, Int>(Expect<() -> Int>::notToThrow), + "- ", "» " +) { + + companion object : WithAsciiReporter() { + fun toThrowFeature(expect: Expect Any?>) = expect.toThrow() + fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = + expect.toThrow { assertionCreator() } + } +} From 4f2a01c995675dcf46766cbae908ce163218ba03 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 10:50:38 +0100 Subject: [PATCH 103/142] simplify Fun0Assertions, fix/workaround for KT-23178 --- .../api/fluent/en_GB/Fun0AssertionsJvmSpec.kt | 3 +- .../atrium/core/polyfills/kClassExtensions.kt | 13 +- .../ch/tutteli/atrium/specs/SpekExtensions.kt | 14 - .../specs/integration/Fun0AssertionsSpec.kt | 338 +++++++++--------- .../integration/ListFeatureAssertionsSpec.kt | 2 +- .../integration/MapFeatureAssertionsSpec.kt | 5 +- .../ResultFeatureAssertionsSpec.kt | 4 +- .../integration/ThrowableAssertionsSpec.kt | 2 +- .../ch/tutteli/atrium/specs/testUtils.kt | 2 + .../integration/Fun0AssertionsJvmSpec.kt | 194 +++++----- 10 files changed, 271 insertions(+), 306 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsJvmSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsJvmSpec.kt index 9d8ad3fd6..b3af86b30 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsJvmSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsJvmSpec.kt @@ -3,9 +3,10 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.feature0 import ch.tutteli.atrium.specs.feature1 +import ch.tutteli.atrium.specs.withFeatureSuffix class Fun0AssertionsJvmSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsJvmSpec( - "toThrow" to Companion::toThrowFeature, + ("toThrow" to Companion::toThrowFeature).withFeatureSuffix(), "toThrow" to Companion::toThrow, feature0<() -> Int, Int>(Expect<() -> Int>::notToThrow), feature1<() -> Int, Expect.() -> Unit, Int>(Expect<() -> Int>::notToThrow), diff --git a/core/api/atrium-core-api-jvm/src/main/kotlin/ch/tutteli/atrium/core/polyfills/kClassExtensions.kt b/core/api/atrium-core-api-jvm/src/main/kotlin/ch/tutteli/atrium/core/polyfills/kClassExtensions.kt index a6970b893..416fbbe72 100644 --- a/core/api/atrium-core-api-jvm/src/main/kotlin/ch/tutteli/atrium/core/polyfills/kClassExtensions.kt +++ b/core/api/atrium-core-api-jvm/src/main/kotlin/ch/tutteli/atrium/core/polyfills/kClassExtensions.kt @@ -10,7 +10,18 @@ import kotlin.reflect.full.cast as kotlinCast * (e.g. `int` vs. `Integer`) and returns also a name for anonymous classes. */ actual val KClass<*>.fullName: String - get() = if (!java.isPrimitive) qualifiedName ?: java.name else java.name + get() { + return if (!java.isPrimitive) { + try { + qualifiedName + } catch (_: Throwable) { + // workaround for https://youtrack.jetbrains.com/issue/KT-37656 there are cases where Kotlin does not + // find the class it defined, java.name works though + null + } ?: java.name + } else java.name + } + /** * Returns [KClass.java].[name][Class.name]. diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SpekExtensions.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SpekExtensions.kt index b6c647b3e..b5ae7e78f 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SpekExtensions.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/SpekExtensions.kt @@ -35,21 +35,7 @@ fun GroupBody.prefixedDescribeTemplate( body: Suite.() -> Unit ): Unit = describe("${prefix}describe$suffix $description", body = body) -fun Suite.checkNarrowingAssertion( - description: String, - act: (Expect.() -> Unit) -> Unit, - lazy: (Expect.() -> Unit), - vararg otherMethods: Pair.() -> Unit)> -) { - checkGenericNarrowingAssertion(description, act, lazy, *otherMethods) -} -fun Suite.checkGenericNarrowingAssertion( - description: String, - act: (T.() -> Unit) -> Unit, - lazy: (T.() -> Unit), - vararg otherMethods: Pair Unit)> -): Unit = checkGenericNarrowingAssertion(description, act, "lazy" to lazy, *otherMethods) fun Suite.checkGenericNarrowingAssertion( description: String, act: (T.() -> Unit) -> Unit, vararg methods: Pair Unit)> diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt index b87f7fcea..863704843 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsSpec.kt @@ -6,6 +6,7 @@ import ch.tutteli.atrium.core.polyfills.fullName import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionAnyAssertion +import ch.tutteli.atrium.translations.DescriptionBasic import ch.tutteli.atrium.translations.DescriptionFunLikeAssertion import ch.tutteli.atrium.translations.DescriptionThrowableAssertion import org.spekframework.spek2.Spek @@ -21,7 +22,14 @@ abstract class Fun0AssertionsSpec( describePrefix: String = "[Atrium] " ) : Spek({ - include(object : SubjectLessSpec<() -> Any?>(describePrefix, + @Suppress("NAME_SHADOWING") + val toThrow = toThrow.adjustName { it.substringBefore(" (feature)") } + + @Suppress("NAME_SHADOWING") + val notToThrow = notToThrow.adjustName { it.substringBefore(" (feature)") } + + include(object : SubjectLessSpec<() -> Any?>( + "$describePrefix[toThrow] ", toThrowFeature.forSubjectLess().adjustName { "$it feature" }, toThrow.forSubjectLess { messageContains("bla") } ) {}) @@ -32,7 +40,7 @@ abstract class Fun0AssertionsSpec( ) {}) include(object : AssertionCreatorSpec<() -> Any?>( - describePrefix, { throw IllegalArgumentException("bla") }, + "$describePrefix[toThrow] ", { throw IllegalArgumentException("bla") }, assertionCreatorSpecTriple( toThrow.name, "bla", @@ -51,30 +59,8 @@ abstract class Fun0AssertionsSpec( ) ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - - fun Suite.checkToThrow( - description: String, - act: (Expect Any?>.() -> Unit) -> Unit, - lazy: (Expect Any?>.() -> Unit), - immediate: (Expect Any?>.() -> Unit) - ) { - checkGenericNarrowingAssertion(description, act, lazy, "immediate" to immediate) - } - - fun expectThrowsAssertionErrorAndMessageContainsRegex( - toThrowFun: Expect<() -> R>.() -> Unit, - throwable: Throwable, - pattern: String, vararg otherPatterns: String - ) { - expect { - val act: () -> R = { throw throwable } - expect(act).toThrowFun() - }.toThrow { - message { containsRegex(pattern, *otherPatterns) } - } - } + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val messageDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_MESSAGE.getDefault() val stackTraceDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_STACKTRACE.getDefault() @@ -87,179 +73,179 @@ abstract class Fun0AssertionsSpec( "\\s+\\Q$explanationBulletPoint\\E$stackTraceDescr: $separator" + "\\s+\\Q$listBulletPoint\\E${Fun0AssertionsSpec::class.fullName}" - describeFun("${toThrowFeature.name} feature and ${toThrow.name}") { - val toThrowFeatureFun = toThrowFeature.lambda - val toThrowFun = toThrow.lambda + describeFun(toThrowFeature, toThrow, notToThrowFeature, notToThrow) { + val toThrowFunctions = unifySignatures(toThrowFeature, toThrow) + val notToThrowFunctions = unifySignatures(notToThrowFeature, notToThrow) - checkToThrow("it throws an AssertionError when no exception occurs", { doToThrow -> - expect { - expect { /* no exception occurs */ 1 }.doToThrow() - }.toThrow { - message { - contains.exactly(1).regex( - "${DescriptionFunLikeAssertion.THROWN_EXCEPTION_WHEN_CALLED.getDefault()}: " + - DescriptionFunLikeAssertion.NO_EXCEPTION_OCCURRED.getDefault(), - "$isADescr: ${IllegalArgumentException::class.simpleName}" - ) + context("no exception occurs") { + toThrowFunctions.forEach { (name, toThrowFun, hasExtraHint) -> + it("$name - throws an AssertionError" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect<() -> Any?> { /* no exception occurs */ 1 }.toThrowFun { toBe(IllegalArgumentException("what")) } + }.toThrow { + message { + contains.exactly(1).regex( + "${DescriptionFunLikeAssertion.THROWN_EXCEPTION_WHEN_CALLED.getDefault()}: " + + DescriptionFunLikeAssertion.NO_EXCEPTION_OCCURRED.getDefault(), + "$isADescr: ${IllegalArgumentException::class.simpleName}" + ) + if (hasExtraHint) contains("$toBeDescr: ${IllegalArgumentException::class.fullName}") + } + } } } - }, { toThrowFun { toBe(IllegalArgumentException("what")) } }, { toThrowFeatureFun() }) + notToThrowFunctions.forEach { (name, notToThrowFun, _) -> + it("$name - does not throw, allows to make a sub assertion") { + expect { 1 }.notToThrowFun { toBe(1) } + } + } + } - checkToThrow( - "it allows to define assertions for the Throwable if the correct exception is thrown", - { toThrowWithCheck -> - expect { - throw IllegalArgumentException("hello") - }.toThrowWithCheck() - }, - { toThrowFun { message { toBe("hello") } } }, { toThrowFeatureFun().message.toBe("hello") }) + context("exception is thrown") { - context("wrong exception") { + val wrongException = UnsupportedOperationException(errMessage) - checkToThrow("it throws an AssertionError and shows message and stacktrace as extra hint", { doToThrow -> - expectThrowsAssertionErrorAndMessageContainsRegex( - doToThrow, - UnsupportedOperationException(errMessage), - "$isADescr:.+" + IllegalArgumentException::class.fullName, - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace(errMessage) - ) - }, { toThrowFun { message { toBe("hello") } } }, { toThrowFeatureFun().message.toBe("hello") }) + toThrowFunctions.forEach { (name, toThrowFun, hasExtraHint) -> + it("$name - allows to define assertions for the Throwable if the correct exception is thrown") { + expect<() -> Any?> { + throw IllegalArgumentException("hello") + }.toThrowFun { message.toBe("hello") } + } + + it( + "$name - throws an AssertionError in case of a wrong exception and shows message and stacktrace as extra hint" + + showsSubAssertionIf(hasExtraHint) + ) { + expect { + expect<() -> Any?> { + throw wrongException + }.toThrowFun { message.toBe("hello") } + }.toThrow { + message { + containsRegex( + "$isADescr:.+" + IllegalArgumentException::class.fullName, + UnsupportedOperationException::class.simpleName + separator + + messageAndStackTrace(errMessage) + ) + if (hasExtraHint) contains("$toBeDescr: \"hello\"") + } + } + } + } + + notToThrowFunctions.forEach { (name, notToThrowFun, hasExtraHint) -> + it( + "$name - throws an AssertionError and shows message and stacktrace as extra hint" + + showsSubAssertionIf(hasExtraHint) + ) { + expect { + expect<() -> Int> { + throw wrongException + }.notToThrowFun { toBe(2) } + }.toThrow { + message { + containsRegex( + "${DescriptionFunLikeAssertion.IS_NOT_THROWING_1.getDefault()}: "+ + DescriptionFunLikeAssertion.IS_NOT_THROWING_2.getDefault(), + UnsupportedOperationException::class.simpleName + separator + + messageAndStackTrace(errMessage) + ) + if (hasExtraHint) contains("$toBeDescr: 2") + } + } + } + } context("with a cause") { - checkToThrow("shows cause as extra hint", { doToThrow -> - expectThrowsAssertionErrorAndMessageContainsRegex( - doToThrow, - UnsupportedOperationException("not supported", IllegalStateException(errMessage)), - UnsupportedOperationException::class.simpleName + separator + - messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) - ) - }, { toThrowFun { message { toBe("hello") } } }, { toThrowFeatureFun() }) + val exceptionWithCause = + UnsupportedOperationException("not supported", IllegalStateException(errMessage)) - checkToThrow( - "with nested cause, shows both causes as extra hint", - { doToThrow -> - expectThrowsAssertionErrorAndMessageContainsRegex( - doToThrow, - UnsupportedOperationException( - "not supported", - RuntimeException("io", IllegalStateException(errMessage)) - ), + fun Expect.expectCauseInReporting() = + message { + containsRegex( UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${RuntimeException::class.fullName}" + - messageAndStackTrace("io"), "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + messageAndStackTrace(errMessage) ) - }, - { toThrowFun { message { toBe("hello") } } }, - { toThrowFeatureFun().message.toBe("hello") }) - } - } - } - describeFun("${notToThrowFeature.name} feature") { - val notToThrowFeatureFun = notToThrowFeature.lambda + } - context("no exception occurs") { - it("does not throw, allows to make a sub assertion") { - expect { 1 }.notToThrowFeatureFun().toBe(1) - } - } - context("exception is thrown") { - val notThrown: Expect<() -> Int>.() -> Unit = { notToThrowFeatureFun().toBe(1) } - - it("throws an AssertionError and shows message and stackTrace as well as intended sub assertion") { - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - UnsupportedOperationException(errMessage), - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace(errMessage), - "..." - ) - } - - context("with a cause") { - it("shows cause as extra hint") { - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - UnsupportedOperationException("not supported", IllegalStateException(errMessage)), - UnsupportedOperationException::class.simpleName + separator + - messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) - ) + toThrowFunctions.forEach { (name, toThrowFun, hasExtraHint) -> + it( + "$name - shows cause as extra hint in case of a wrong exception" + + showsSubAssertionIf(hasExtraHint) + ) { + expect { + expect<() -> Any?> { + throw exceptionWithCause + }.toThrowFun { message.toBe("hello") } + }.toThrow { + expectCauseInReporting() + if (hasExtraHint) messageContains("$toBeDescr: \"hello\"") + } + } } - it("with nested cause, shows both causes as extra hint") { - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - UnsupportedOperationException( - "not supported", - RuntimeException("io", IllegalStateException(errMessage)) - ), - UnsupportedOperationException::class.simpleName + separator + - messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${RuntimeException::class.fullName}" + - messageAndStackTrace("io"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) - ) - } - } - } - } - - describeFun(notToThrow.name) { - val notToThrowFun = notToThrow.lambda - - context("no exception occurs") { - it("does not throw, allows to make a sub assertion") { - expect { 1 }.notToThrowFun { toBe(1) } - } - } - context("exception is thrown") { - val notThrown: Expect<() -> Int>.() -> Unit = { notToThrowFun { toBe(1) } } - - it("throws an AssertionError and shows message and stackTrace as well as intended sub assertion") { - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - UnsupportedOperationException(errMessage), - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace(errMessage), - "...", - "$toBeDescr: 1" - ) - } - - context("with a cause") { - it("shows cause as extra hint") { - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - UnsupportedOperationException("not supported", IllegalStateException(errMessage)), - UnsupportedOperationException::class.simpleName + separator + - messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) - ) + notToThrowFunctions.forEach { (name, notToThrowFun, hasExtraHint) -> + it("$name - shows cause as extra hint" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect<() -> Int> { + throw exceptionWithCause + }.notToThrowFun { toBe(2) } + }.toThrow { + expectCauseInReporting() + if (hasExtraHint) messageContains("$toBeDescr: 2") + } + } } - it("with nested cause, shows both causes as extra hint") { - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - UnsupportedOperationException( - "not supported", - RuntimeException("io", IllegalStateException(errMessage)) - ), - UnsupportedOperationException::class.simpleName + separator + - messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${RuntimeException::class.fullName}" + - messageAndStackTrace("io"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) + context("with nested cause") { + val exceptionWithNestedCause = UnsupportedOperationException( + "not supported", + RuntimeException("io", IllegalStateException(errMessage)) ) + + fun Expect.expectCauseAndNestedInReporting() = + message { + containsRegex( + UnsupportedOperationException::class.simpleName + separator + + messageAndStackTrace("not supported"), + "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${RuntimeException::class.fullName}" + + messageAndStackTrace("io"), + "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + + messageAndStackTrace(errMessage) + ) + } + + + toThrowFunctions.forEach { (name, toThrowFun, hasExtraHint) -> + it("$name - shows both causes as extra hint" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect<() -> Any?> { + throw exceptionWithNestedCause + }.toThrowFun { message.toBe("hello") } + }.toThrow { + expectCauseAndNestedInReporting() + if (hasExtraHint) messageContains("$toBeDescr: \"hello\"") + } + } + } + + notToThrowFunctions.forEach { (name, notToThrowFun, hasExtraHint) -> + it("$name - shows both causes as extra hint" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect<() -> Int> { + throw exceptionWithNestedCause + }.notToThrowFun { toBe(2) } + }.toThrow { + expectCauseAndNestedInReporting() + if (hasExtraHint) messageContains("$toBeDescr: 2") + } + } + } } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt index a59958291..fe9c4743e 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ListFeatureAssertionsSpec.kt @@ -58,7 +58,7 @@ abstract class ListFeatureAssertionsSpec( it("$name - can perform sub-assertion on existing index") { fluent.getFun(0) { toBe(1) } } - it("$name - non-existing index throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + it("$name - non-existing index throws" + showsSubAssertionIf(hasExtraHint)) { expect { fluent.getFun(4) { toBe(3) } }.toThrow { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt index 7d7803ba7..189116557 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/MapFeatureAssertionsSpec.kt @@ -4,7 +4,6 @@ import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* -import ch.tutteli.atrium.translations.DescriptionCollectionAssertion import ch.tutteli.atrium.translations.DescriptionMapAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite @@ -96,7 +95,7 @@ abstract class MapFeatureAssertionsSpec( it("$name - can perform sub-assertion on existing key") { fluent.getExistingFun("a") { toBe(1) } } - it("$name - non-existing key throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + it("$name - non-existing key throws" + showsSubAssertionIf(hasExtraHint)) { expect { fluent.getExistingFun("c") { toBe(3) } }.toThrow { @@ -122,7 +121,7 @@ abstract class MapFeatureAssertionsSpec( it("$name - can perform sub-assertion on existing key whose value is null") { fluentNullable.getExistingFun("b") { toBe(null) } } - it("$name - non-existing key throws" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + it("$name - non-existing key throws" + showsSubAssertionIf(hasExtraHint)) { expect { fluentNullable.getExistingFun("c") { toBe(null) } }.toThrow { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt index 0538b34d7..028cdb0e7 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ResultFeatureAssertionsSpec.kt @@ -111,7 +111,7 @@ abstract class ResultFeatureAssertionsSpec( context("subject is $resultFailure") { successFunctions.forEach { (name, isSuccessFun, hasExtraHint) -> - it("$name throws AssertionError" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + it("$name throws AssertionError" + showsSubAssertionIf(hasExtraHint)) { expect { expect(resultFailure).isSuccessFun { toBe(1) } }.toThrow { @@ -157,7 +157,7 @@ abstract class ResultFeatureAssertionsSpec( } context("subject is $resultNullableFailure") { - it("${isSuccessFeature.name} throws AssertionError" + if (hasExtraHint) " but shows intended sub-assertion" else "") { + it("${isSuccessFeature.name} throws AssertionError" + showsSubAssertionIf(hasExtraHint)) { expect { expect(resultNullableFailure).isSuccessFun { toBe(1) } }.toThrow { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt index 031e7d06c..49d73e156 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/ThrowableAssertionsSpec.kt @@ -48,7 +48,7 @@ abstract class ThrowableAssertionsSpec( val throwable: Throwable = IllegalArgumentException() messageFunctions.forEach { (name, messageFun, hasExtraHint) -> - it("$name - throws an AssertionError" + if (hasExtraHint) " which shows intended sub assertion" else "") { + it("$name - throws an AssertionError" + showsSubAssertionIf(hasExtraHint)) { expect { expect(throwable).messageFun { toBe("hello") } }.toThrow { diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt index bd50d8611..c98239986 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/testUtils.kt @@ -214,3 +214,5 @@ val isNotDescr = DescriptionBasic.IS_NOT.getDefault() val isADescr = DescriptionAnyAssertion.IS_A.getDefault() expect val lineSeperator: String + +fun showsSubAssertionIf(hasExtraHint: Boolean): String = if (hasExtraHint) "; shows intended sub assertion" else "" diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsJvmSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsJvmSpec.kt index aa2ea1746..be7fcd168 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsJvmSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/Fun0AssertionsJvmSpec.kt @@ -2,10 +2,7 @@ package ch.tutteli.atrium.specs.integration -import ch.tutteli.atrium.api.fluent.en_GB.containsRegex -import ch.tutteli.atrium.api.fluent.en_GB.message -import ch.tutteli.atrium.api.fluent.en_GB.toBe -import ch.tutteli.atrium.api.fluent.en_GB.toThrow +import ch.tutteli.atrium.api.fluent.en_GB.* import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.core.polyfills.fullName import ch.tutteli.atrium.creating.Expect @@ -25,30 +22,14 @@ abstract class Fun0AssertionsJvmSpec( describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) + @Suppress("NAME_SHADOWING") + val toThrow = toThrow.adjustName { it.substringBefore(" (feature)") } - fun Suite.checkToThrow( - description: String, - act: (Expect Any?>.() -> Unit) -> Unit, - lazy: (Expect Any?>.() -> Unit), - immediate: (Expect Any?>.() -> Unit) - ) { - checkGenericNarrowingAssertion(description, act, lazy, "immediate" to immediate) - } + @Suppress("NAME_SHADOWING") + val notToThrow = notToThrow.adjustName { it.substringBefore(" (feature)") } - fun expectThrowsAssertionErrorAndMessageContainsRegex( - toThrowFun: Expect<() -> R>.() -> Unit, - throwable: Throwable, - pattern: String, vararg otherPatterns: String - ) { - expect { - val act: () -> R = { throw throwable } - expect(act).toThrowFun() - }.toThrow { - message { containsRegex(pattern, *otherPatterns) } - } - } + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) val messageDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_MESSAGE.getDefault() val stackTraceDescr = DescriptionThrowableAssertion.OCCURRED_EXCEPTION_STACKTRACE.getDefault() @@ -63,97 +44,96 @@ abstract class Fun0AssertionsJvmSpec( "\\s+\\Q$explanationBulletPoint\\E$stackTraceDescr: $separator" + "\\s+\\Q$listBulletPoint\\E${Fun0AssertionsJvmSpec::class.fullName}" - describeFun("${toThrowFeature.name} feature and ${toThrow.name}") { - val toThrowFeatureFun = toThrowFeature.lambda - val toThrowFun = toThrow.lambda + describeFun(toThrowFeature, toThrow, notToThrowFeature, notToThrow) { + val toThrowFunctions = unifySignatures(toThrowFeature, toThrow) + val notToThrowFunctions = unifySignatures(notToThrowFeature, notToThrow) context("wrong exception with suppressed") { + val exceptionWithSuppressed = UnsupportedOperationException("not supported") + exceptionWithSuppressed.addSuppressed(IllegalStateException("not good")) + exceptionWithSuppressed.addSuppressed(IllegalArgumentException(errMessage)) - checkToThrow("shows all suppressed as extra hint", { doToThrow -> - val ex = UnsupportedOperationException("not supported") - ex.addSuppressed(IllegalStateException("not good")) - ex.addSuppressed(IllegalArgumentException(errMessage)) - expectThrowsAssertionErrorAndMessageContainsRegex( - doToThrow, - ex, - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace("not good"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalArgumentException::class.fullName}" + - messageAndStackTrace(errMessage) - ) - }, { toThrowFun { message { toBe("hello") } } }, { toThrowFeatureFun() }) - } - } + fun Expect.expectSuppressedInReporting() = + message { + containsRegex( + UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), + "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalStateException::class.fullName}" + + messageAndStackTrace("not good"), + "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalArgumentException::class.fullName}" + + messageAndStackTrace(errMessage) + ) + } - describeFun("${notToThrowFeature.name} feature") { - val notToThrowFeatureFun = notToThrowFeature.lambda + toThrowFunctions.forEach { (name, toThrowFun, hasExtraHint) -> + it("$name - shows all suppressed as extra hint" + showsSubAssertionIf(hasExtraHint)) { - context("exception is thrown with suppressed") { - val notThrown: Expect<() -> Int>.() -> Unit = { notToThrowFeatureFun().toBe(1) } - - it("shows all suppressed as extra hint") { - val ex = UnsupportedOperationException("not supported") - ex.addSuppressed(IllegalStateException("not good")) - ex.addSuppressed(IllegalArgumentException(errMessage)) - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - ex, - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace("not good"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalArgumentException::class.fullName}" + - messageAndStackTrace(errMessage) - ) + expect { + expect<() -> Any?> { + throw exceptionWithSuppressed + }.toThrowFun { message.toBe("hello") } + }.toThrow { + expectSuppressedInReporting() + if (hasExtraHint) messageContains("$toBeDescr: \"hello\"") + } + } } - it("with nested cause, shows both causes as extra hint") { - val ex = UnsupportedOperationException("not supported") - ex.addSuppressed(IOException("io", IllegalStateException(errMessage))) - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - ex, - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IOException::class.fullName}" + - messageAndStackTrace("io"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) - ) + + notToThrowFunctions.forEach { (name, notToThrowFun, hasExtraHint) -> + it("$name - shows all suppressed as extra hint" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect<() -> Int> { + throw exceptionWithSuppressed + }.notToThrowFun { toBe(2) } + }.toThrow { + expectSuppressedInReporting() + if (hasExtraHint) messageContains("$toBeDescr: 2") + } + } } - } - } - describeFun(notToThrow.name) { - val notToThrowFun = notToThrow.lambda - context("exception is thrown with suppressed") { - val notThrown: Expect<() -> Int>.() -> Unit = { notToThrowFun { toBe(1) } } + context("with nested cause") { + val exceptionWithSuppressedWhichHasCause = UnsupportedOperationException("not supported") + exceptionWithSuppressedWhichHasCause.addSuppressed(IOException("io", IllegalStateException(errMessage))) - it("shows all suppressed as extra hint") { - val ex = UnsupportedOperationException("not supported") - ex.addSuppressed(IllegalStateException("not good")) - ex.addSuppressed(IllegalArgumentException(errMessage)) - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - ex, - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace("not good"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IllegalArgumentException::class.fullName}" + - messageAndStackTrace(errMessage) - ) - } - it("with nested cause, shows both causes as extra hint") { - val ex = UnsupportedOperationException("not supported") - ex.addSuppressed(IOException("io", IllegalStateException(errMessage))) - expectThrowsAssertionErrorAndMessageContainsRegex( - notThrown, - ex, - UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), - "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IOException::class.fullName}" + - messageAndStackTrace("io"), - "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + - messageAndStackTrace(errMessage) - ) + fun Expect.expectSuppressedAndCauseInReporting() = + message { + containsRegex( + UnsupportedOperationException::class.simpleName + separator + messageAndStackTrace("not supported"), + "\\s+\\Q$explanationBulletPoint\\E$supressedDescr: ${IOException::class.fullName}" + + messageAndStackTrace("io"), + "\\s+\\Q$explanationBulletPoint\\E$causeDescr: ${IllegalStateException::class.fullName}" + + messageAndStackTrace(errMessage) + ) + + } + + toThrowFunctions.forEach { (name, toThrowFun, hasExtraHint) -> + it("$name -shows suppressed including cause as extra hint" + showsSubAssertionIf(hasExtraHint)) { + + expect { + expect<() -> Any?> { + throw exceptionWithSuppressedWhichHasCause + }.toThrowFun { message.toBe("hello") } + }.toThrow { + expectSuppressedAndCauseInReporting() + if (hasExtraHint) messageContains("$toBeDescr: \"hello\"") + } + } + } + + notToThrowFunctions.forEach { (name, notToThrowFun, hasExtraHint) -> + it("$name - shows suppressed including cause as extra hint" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect<() -> Int> { + throw exceptionWithSuppressedWhichHasCause + }.notToThrowFun { toBe(2) } + }.toThrow { + expectSuppressedAndCauseInReporting() + if (hasExtraHint) messageContains("$toBeDescr: 2") + } + } + } } } } From a377e5d2bef47a45f012c4120b284f516c64d81d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 22:19:21 +0100 Subject: [PATCH 104/142] move functions back into companion in specs I started to move them out but realised that it makes more sense to keep them there as we can define BaseSpecs this way providing some utility functionality. This could be moved out as well of course but this is really not worth the effort. --- .../en_GB/CharSequenceContainsSpecBase.kt | 4 +- .../fluent/en_GB/CollectionAssertionsSpec.kt | 4 +- .../en_GB/CollectionFeatureAssertionsSpec.kt | 6 +- .../api/fluent/en_GB/Fun0AssertionsSpec.kt | 18 +- .../fluent/en_GB/ListFeatureAssertionsSpec.kt | 4 +- .../api/fluent/en_GB/MapAssertionsSpec.kt | 42 +++-- .../fluent/en_GB/ThrowableAssertionsSpec.kt | 31 ++-- .../api/infix/en_GB/AnyAssertionsSpec.kt | 114 ++++++------ .../infix/en_GB/CharSequenceAssertionsSpec.kt | 16 +- ...quenceContainsContainsNotAssertionsSpec.kt | 24 +-- .../en_GB/CharSequenceContainsSpecBase.kt | 2 +- .../infix/en_GB/CollectionAssertionsSpec.kt | 16 +- .../en_GB/CollectionFeatureAssertionsSpec.kt | 6 +- .../api/infix/en_GB/Fun0AssertionsSpec.kt | 19 +- .../infix/en_GB/IterableAllAssertionsSpec.kt | 4 +- .../infix/en_GB/ListFeatureAssertionsSpec.kt | 34 ++-- .../api/infix/en_GB/MapAssertionsSpec.kt | 170 +++++++++--------- .../api/infix/en_GB/MapEntryAssertionsSpec.kt | 19 +- .../infix/en_GB/MapFeatureAssertionsSpec.kt | 34 ++-- .../infix/en_GB/ThrowableAssertionsSpec.kt | 40 +++-- .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 29 +-- .../en_GB/jdk8/PathFeatureAssertionsSpec.kt | 18 +- 22 files changed, 347 insertions(+), 307 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt index f7c2f6886..63a753e78 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt @@ -32,7 +32,7 @@ abstract class CharSequenceContainsSpecBase { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - val a1: Expect = notImplemented() + val a1: Expect = notImplemented() a1.contains.atLeast(1).value(1) a1.contains.atMost(2).values("a", 1) @@ -53,7 +53,7 @@ abstract class CharSequenceContainsSpecBase { a1.contains.ignoringCase.values("a", 'b') a1.contains.ignoringCase.regex("a") a1.contains.ignoringCase.regex("a", "bl") - //TODO add to infix as well as fluent + //TODO add (also to infix API) // a1.contains.ignoringCase.elementsOf(listOf(1, 2))("a", "bl") } } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionAssertionsSpec.kt index e0523bce2..0e62df1b7 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionAssertionsSpec.kt @@ -10,8 +10,8 @@ object CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.Collection ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - val a1: Expect> = notImplemented() - val a1b: Expect> = notImplemented() + val a1: Expect> = notImplemented() + val a1b: Expect> = notImplemented() val star: Expect> = notImplemented() diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionFeatureAssertionsSpec.kt index 77150aae4..80bb1df3b 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CollectionFeatureAssertionsSpec.kt @@ -11,10 +11,10 @@ object CollectionFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.Col ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() - var star: Expect> = notImplemented() + var star: Expect> = notImplemented() a1.size a1 = a1.size { } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt index 6ec6d3c08..7843e4d1f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/Fun0AssertionsSpec.kt @@ -7,12 +7,21 @@ import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.withFeatureSuffix class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpec( - ("toThrow" to ::toThrowFeature).withFeatureSuffix(), - "toThrow" to ::toThrow, + ("toThrow" to Companion::toThrowFeature).withFeatureSuffix(), + "toThrow" to Companion::toThrow, feature0<() -> Int, Int>(Expect<() -> Int>::notToThrow), feature1<() -> Int, Expect.() -> Unit, Int>(Expect<() -> Int>::notToThrow), "⚬ ", "» " ) { + companion object { + private fun toThrowFeature(expect: Expect Any?>) = + expect.toThrow() + + private fun toThrow( + expect: Expect Any?>, + assertionCreator: Expect.() -> Unit + ) = expect.toThrow { assertionCreator() } + } @Suppress("unused", "UNUSED_VALUE", "UNUSED_VARIABLE") private fun ambiguityTest() { @@ -33,8 +42,3 @@ class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpe } } -private fun toThrowFeature(expect: Expect Any?>) = - expect.toThrow() - -private fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = - expect.toThrow { assertionCreator() } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt index 6247a9a4f..d8ca71bbc 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ListFeatureAssertionsSpec.kt @@ -11,8 +11,8 @@ object ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatu ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() var star: Expect> = notImplemented() diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt index bc0320c7f..7077f4f70 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/MapAssertionsSpec.kt @@ -9,8 +9,9 @@ import kotlin.jvm.JvmName class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( mfun2(Expect>::contains), mfun2(Expect>::contains).withNullableSuffix(), - mfun2.() -> Unit>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, - mfun2.() -> Unit)?>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }.withNullableSuffix(), + mfun2.() -> Unit>(Companion::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, + mfun2.() -> Unit)?>(Companion::contains).adjustName { "$it ${KeyValue::class.simpleName}" } + .withNullableSuffix(), fun1(Expect>::containsKey), fun1(Expect>::containsKey).withNullableSuffix(), fun1(Expect>::containsNotKey), @@ -19,6 +20,26 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( fun0(Expect>::isNotEmpty) ) { + companion object { + private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit>, + otherKeyValues: Array.() -> Unit>> + ) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect.contains(first, *others) + } + + @JvmName("containsNullable") + private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit)?>, + otherKeyValues: Array.() -> Unit)?>> + ) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect.contains(first, *others) + } + + } + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var map: Expect> = notImplemented() @@ -184,20 +205,3 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( } } - -private fun contains( - expect: Expect>, - keyValue: Pair.() -> Unit>, - otherKeyValues: Array.() -> Unit>> -) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect.contains(first, *others) -} - -@JvmName("containsNullable") -private fun contains( - expect: Expect>, - keyValue: Pair.() -> Unit)?>, - otherKeyValues: Array.() -> Unit)?>> -) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect.contains(first, *others) -} diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt index 3fba5a683..d26cab9af 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ThrowableAssertionsSpec.kt @@ -1,20 +1,30 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.fun2 -import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.property -import ch.tutteli.atrium.specs.withFeatureSuffix +import ch.tutteli.atrium.specs.* class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAssertionsSpec( property(Expect::message), fun1.() -> Unit>(Expect::message), fun2(Expect::messageContains), - ("cause" to ::causeFeature).withFeatureSuffix(), - "cause" to ::cause + ("cause" to Companion::causeFeature).withFeatureSuffix(), + "cause" to Companion::cause ) { + companion object { + + @Suppress("RemoveExplicitTypeArguments") + private fun causeFeature(expect: Expect): Expect = + expect.cause() + + @Suppress("RemoveExplicitTypeArguments") + private fun cause( + expect: Expect, + assertionCreator: Expect.() -> Unit + ) = expect.cause(assertionCreator) + + } + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var a1: Expect = notImplemented() @@ -27,10 +37,3 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1.cause { } } } - -@Suppress("RemoveExplicitTypeArguments") -private fun causeFeature(expect: Expect): Expect = expect.cause() - -@Suppress("RemoveExplicitTypeArguments") -private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = - expect.cause(assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt index 54338cc49..2153dab93 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt @@ -26,24 +26,69 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( fun1(Expect::isNotSameAs).withNullableSuffix(), fun1(Expect::isNotSameAs).withNullableSuffix(), - "${Expect::toBe.name}(null)" to ::toBeNull, + "${Expect::toBe.name}(null)" to Companion::toBeNull, fun1(Expect::toBeNullIfNullGivenElse), - "isA" to ::isAFeature, - "isA" to ::isAStringToInt, - "isA" to ::isAStringToInt, - "isA" to ::isAString, - "isA" to ::isACharSequence, - "isA" to ::isASubType, - "isA" to ::isAIntLess, - "notToBeNull" to ::notToBeNull, - ::notToBeNullLess, - ::notToBeNullGreaterAndLess, + "isA" to Companion::isAFeature, + "isA" to Companion::isAStringToInt, + "isA" to Companion::isAStringToInt, + "isA" to Companion::isAString, + "isA" to Companion::isACharSequence, + "isA" to Companion::isASubType, + "isA" to Companion::isAIntLess, + "notToBeNull" to Companion::notToBeNull, + Companion::notToBeNullLess, + Companion::notToBeNullGreaterAndLess, getAndImmediatePair(), getAndLazyPair() ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter(){ + private fun toBeNull(expect: Expect) = expect toBe null + + @Suppress("RemoveExplicitTypeArguments") + private fun isAFeature(expect: Expect): Expect = expect.isA() + + private fun getAndImmediatePair(): Pair.() -> Expect> = + "non existing in infix" to { e: Expect -> e } + + private val andLazyName: KFunction2, Expect.() -> Unit, Expect> = Expect::and + private fun getAndLazyPair(): Pair.(Expect.() -> Unit) -> Expect> = + andLazyName.name to Expect::and + + private inline fun isA( + expect: Expect<*>, + noinline assertionCreator: Expect.() -> Unit + ) = expect.isA(assertionCreator) + + //TODO get rid of different overloads as soon as https://youtrack.jetbrains.com/issue/KT-19884 is fixed + private fun isAStringToInt(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + + private fun isAString(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + + private fun isACharSequence(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + + private fun isASubType(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = + isA(expect, assertionCreator) + + private fun isAIntLess(expect: Expect, number: Int) = + expect.isA { o isLessThan number } + + private fun notToBeNull(expect: Expect, assertionCreator: Expect.() -> Unit) = + expect notToBeNull assertionCreator + + private fun notToBeNullLess(expect: Expect, number: Int) = + expect.notToBeNull { isLessThan(number) } + + private fun notToBeNullGreaterAndLess(expect: Expect, lowerBound: Int, upperBound: Int) = + expect.notToBeNull { + o isGreaterThan lowerBound + o isLessThan upperBound + } + } @Suppress("unused") fun ambiguityTest() { @@ -83,48 +128,3 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( @Suppress("unused") fun Expect>.firstIs(value: E) = o get index(0) { o toBe value } } - -private fun toBeNull(expect: Expect) = expect toBe null - -@Suppress("RemoveExplicitTypeArguments") -private fun isAFeature(expect: Expect): Expect = expect.isA() - -private fun getAndImmediatePair(): Pair.() -> Expect> = - "non existing in infix" to { e: Expect -> e } - -private val andLazyName: KFunction2, Expect.() -> Unit, Expect> = Expect::and -private fun getAndLazyPair(): Pair.(Expect.() -> Unit) -> Expect> = - andLazyName.name to Expect::and - -private inline fun isA( - expect: Expect<*>, - noinline assertionCreator: Expect.() -> Unit -) = expect.isA(assertionCreator) - -//TODO get rid of different overloads as soon as https://youtrack.jetbrains.com/issue/KT-19884 is fixed -private fun isAStringToInt(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = - isA(expect, assertionCreator) - -private fun isAString(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = - isA(expect, assertionCreator) - -private fun isACharSequence(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = - isA(expect, assertionCreator) - -private fun isASubType(expect: Expect<*>, assertionCreator: Expect.() -> Unit) = - isA(expect, assertionCreator) - -private fun isAIntLess(expect: Expect, number: Int) = - expect.isA { o isLessThan number } - -private fun notToBeNull(expect: Expect, assertionCreator: Expect.() -> Unit) = - expect notToBeNull assertionCreator - -private fun notToBeNullLess(expect: Expect, number: Int) = - expect.notToBeNull { isLessThan(number) } - -private fun notToBeNullGreaterAndLess(expect: Expect, lowerBound: Int, upperBound: Int) = - expect.notToBeNull { - o isGreaterThan lowerBound - o isLessThan upperBound - } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt index 59a7deb8f..a609ed362 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt @@ -6,9 +6,9 @@ import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec( - "toBe ${Empty::class.simpleName}" to ::toBeEmpty, - "notToBe ${Empty::class.simpleName}" to ::notToBeEmpty, - "notToBe ${Blank::class.simpleName}" to ::notToBeBlank, + "toBe ${Empty::class.simpleName}" to Companion::toBeEmpty, + "notToBe ${Empty::class.simpleName}" to Companion::notToBeEmpty, + "notToBe ${Blank::class.simpleName}" to Companion::notToBeBlank, fun1(Expect::startsWith), fun1(Expect::startsWith), fun1(Expect::startsNotWith), @@ -20,7 +20,11 @@ class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSeque fun1(Expect::matches), fun1(Expect::mismatches) ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter(){ + private fun toBeEmpty(expect: Expect) = expect toBe Empty + private fun notToBeEmpty(expect: Expect) = expect notToBe Empty + private fun notToBeBlank(expect: Expect) = expect notToBe Blank + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -44,7 +48,3 @@ class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSeque a1 mismatches Regex("a") } } - -private fun toBeEmpty(expect: Expect) = expect toBe Empty -private fun notToBeEmpty(expect: Expect) = expect notToBe Empty -private fun notToBeBlank(expect: Expect) = expect notToBe Blank diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index 0f195dc14..087f9b912 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -7,11 +7,21 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CharSequenceContainsContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( - fun2>(::contains), - fun2>(::containsNot), + fun2>(Companion::contains), + fun2>(Companion::containsNot), "* ", "- ", ">> " ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + + private fun contains(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains a + else expect contains Values(a, *aX) + + private fun containsNot(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect containsNot a + else expect containsNot Values(a, *aX) + + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -21,11 +31,3 @@ class CharSequenceContainsContainsNotAssertionsSpec : a1 containsNot Values(1, "a", 'c') } } - -private fun contains(expect: Expect, a: Any, aX: Array) = - if (aX.isEmpty()) expect contains a - else expect contains Values(a, *aX) - -private fun containsNot(expect: Expect, a: Any, aX: Array) = - if (aX.isEmpty()) expect containsNot a - else expect containsNot Values(a, *aX) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index b28852362..ced5a1fbc 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -33,7 +33,7 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - val a1: Expect = notImplemented() + val a1: Expect = notImplemented() a1 contains o atLeast 1 value 1 a1 contains o atMost 2 the Values("a", 1) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt index ea4802747..ecc1cef15 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt @@ -5,15 +5,19 @@ import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionAssertionsSpec( - "toBe ${Empty::class.simpleName}" to ::isEmpty, - "notToBe ${Empty::class.simpleName}" to ::isNotEmpty + "toBe ${Empty::class.simpleName}" to Companion::isEmpty, + "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + private fun isEmpty(expect: Expect>) = expect toBe Empty + private fun isNotEmpty(expect: Expect>) = expect notToBe Empty + + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - val a1: Expect> = notImplemented() - val a1b: Expect> = notImplemented() + val a1: Expect> = notImplemented() + val a1b: Expect> = notImplemented() val star: Expect> = notImplemented() @@ -28,5 +32,3 @@ class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionA } } -private fun isEmpty(expect: Expect>) = expect toBe Empty -private fun isNotEmpty(expect: Expect>) = expect notToBe Empty diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt index 5ffd4c4eb..232baf974 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt @@ -14,10 +14,10 @@ class CollectionFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.Coll @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() - var star: Expect> = notImplemented() + var star: Expect> = notImplemented() a1.size a1 = a1 size { } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt index c96eb1f86..6c53d3f42 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/Fun0AssertionsSpec.kt @@ -8,13 +8,21 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.specs.withFeatureSuffix class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpec( - ("toThrow" to ::toThrowFeature).withFeatureSuffix(), - "toThrow" to ::toThrow, + ("toThrow" to Companion::toThrowFeature).withFeatureSuffix(), + "toThrow" to Companion::toThrow, feature0<() -> Int, Int>(Expect<() -> Int>::notToThrow), feature1<() -> Int, Expect.() -> Unit, Int>(Expect<() -> Int>::notToThrow), "- ", "» " ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + private fun toThrowFeature(expect: Expect Any?>) = + expect.toThrow() + + private fun toThrow( + expect: Expect Any?>, + assertionCreator: Expect.() -> Unit + ) = expect.toThrow { assertionCreator() } + } @Suppress("unused", "UNUSED_VALUE", "UNUSED_VARIABLE") private fun ambiguityTest() { @@ -35,8 +43,3 @@ class Fun0AssertionsSpec : ch.tutteli.atrium.specs.integration.Fun0AssertionsSpe } } -private fun toThrowFeature(expect: Expect Any?>) = - expect.toThrow() - -private fun toThrow(expect: Expect Any?>, assertionCreator: Expect.() -> Unit) = - expect.toThrow { assertionCreator() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt index 4fcbc4b91..48caa24d3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllAssertionsSpec.kt @@ -15,8 +15,8 @@ class IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAl @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() var star: Expect> = notImplemented() diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt index 4441ce7bc..1c70fce8d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ListFeatureAssertionsSpec.kt @@ -10,18 +10,30 @@ import kotlin.jvm.JvmName class ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatureAssertionsSpec( feature1, Int, Int>(Expect>::get), - fun2, Int, Expect.() -> Unit>(::get), + fun2, Int, Expect.() -> Unit>(Companion::get), feature1, Int, Int?>(Expect>::get).withNullableSuffix(), - fun2, Int, Expect.() -> Unit>(::get).withNullableSuffix() + fun2, Int, Expect.() -> Unit>(Companion::get).withNullableSuffix() ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + + private fun get(expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit) = + expect get index(index) { assertionCreator() } + + @JvmName("getNullable") + private fun get( + expect: Expect>, + index: Int, + assertionCreator: Expect.() -> Unit + ) = expect get index(index) { assertionCreator() } + + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() - var star: Expect> = notImplemented() + var star: Expect> = notImplemented() a1 get 1 a1 = a1 get index(1) { } @@ -33,13 +45,3 @@ class ListFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.ListFeatur star = star get index(1) { } } } - -private fun get(expect: Expect>, index: Int, assertionCreator: Expect.() -> Unit) = - expect get index(index) { assertionCreator() } - -@JvmName("getNullable") -private fun get( - expect: Expect>, - index: Int, - assertionCreator: Expect.() -> Unit -) = expect get index(index) { assertionCreator() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index cfdd9f2aa..1de6996c0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -8,18 +8,93 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import kotlin.jvm.JvmName class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( - mfun2(::contains), - mfun2(::contains).withNullableSuffix(), - mfun2.() -> Unit>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, - mfun2.() -> Unit)?>(::contains).adjustName { "$it ${KeyValue::class.simpleName}" }.withNullableSuffix(), - fun1, String>(::containsKey), - fun1, String?>(::containsKey).withNullableSuffix(), - fun1, String>(::containsNotKey), - fun1, String?>(::containsNotKey).withNullableSuffix(), - "toBe ${Empty::class.simpleName}" to ::isEmpty, - "notToBe ${Empty::class.simpleName}" to ::isNotEmpty + mfun2(Companion::contains), + mfun2(Companion::contains).withNullableSuffix(), + mfun2.() -> Unit>(Companion::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, + mfun2.() -> Unit)?>(Companion::contains).adjustName { "$it ${KeyValue::class.simpleName}" }.withNullableSuffix(), + fun1, String>(Companion::containsKey), + fun1, String?>(Companion::containsKey).withNullableSuffix(), + fun1, String>(Companion::containsNotKey), + fun1, String?>(Companion::containsNotKey).withNullableSuffix(), + "toBe ${Empty::class.simpleName}" to Companion::isEmpty, + "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter(){ + + private fun contains( + expect: Expect>, + pair: Pair, + otherPairs: Array> + ): Expect> { + return if (otherPairs.isEmpty()) { + expect contains (pair.first to pair.second) + } else { + expect contains Pairs(pair, *otherPairs) + } + } + + @JvmName("containsNullable") + private fun contains( + expect: Expect>, + pair: Pair, + otherPairs: Array> + ): Expect> { + return if (otherPairs.isEmpty()) { + expect contains (pair.first to pair.second) + } else { + expect contains Pairs(pair, *otherPairs) + } + } + + @JvmName("containsKeyWithValueAssertions") + private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit>, + otherKeyValues: Array.() -> Unit>> + ): Expect> { + return if (otherKeyValues.isEmpty()) { + expect contains KeyValue(keyValue.first, keyValue.second) + } else { + mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect contains All(first, *others) + } + } + } + + @JvmName("containsKeyWithNullableValueAssertions") + private fun contains( + expect: Expect>, + keyValue: Pair.() -> Unit)?>, + otherKeyValues: Array.() -> Unit)?>> + ): Expect> { + return if (otherKeyValues.isEmpty()) { + expect contains KeyValue(keyValue.first, keyValue.second) + } else { + mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> + expect contains All(first, *others) + } + } + } + + private fun containsKey(expect: Expect>, key: String) = + expect containsKey key + + @JvmName("containsKeyNullable") + private fun containsKey(expect: Expect>, key: String?) = + expect containsKey key + + private fun containsNotKey(expect: Expect>, key: String) = + expect containsNotKey key + + @JvmName("containsNotKeyNullable") + private fun containsNotKey(expect: Expect>, key: String?) = + expect containsNotKey key + + private fun isEmpty(expect: Expect>) = expect toBe Empty + + private fun isNotEmpty(expect: Expect>) = expect notToBe Empty + + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -186,76 +261,3 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( } } - -private fun contains( - expect: Expect>, - pair: Pair, - otherPairs: Array> -): Expect> { - return if (otherPairs.isEmpty()) { - expect contains (pair.first to pair.second) - } else { - expect contains Pairs(pair, *otherPairs) - } -} - -@JvmName("containsNullable") -private fun contains( - expect: Expect>, - pair: Pair, - otherPairs: Array> -): Expect> { - return if (otherPairs.isEmpty()) { - expect contains (pair.first to pair.second) - } else { - expect contains Pairs(pair, *otherPairs) - } -} - -@JvmName("containsKeyWithValueAssertions") -private fun contains( - expect: Expect>, - keyValue: Pair.() -> Unit>, - otherKeyValues: Array.() -> Unit>> -): Expect> { - return if (otherKeyValues.isEmpty()) { - expect contains KeyValue(keyValue.first, keyValue.second) - } else { - mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect contains All(first, *others) - } - } -} - -@JvmName("containsKeyWithNullableValueAssertions") -private fun contains( - expect: Expect>, - keyValue: Pair.() -> Unit)?>, - otherKeyValues: Array.() -> Unit)?>> -): Expect> { - return if (otherKeyValues.isEmpty()) { - expect contains KeyValue(keyValue.first, keyValue.second) - } else { - mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect contains All(first, *others) - } - } -} - -private fun containsKey(expect: Expect>, key: String) = - expect containsKey key - -@JvmName("containsKeyNullable") -private fun containsKey(expect: Expect>, key: String?) = - expect containsKey key - -private fun containsNotKey(expect: Expect>, key: String) = - expect containsNotKey key - -@JvmName("containsNotKeyNullable") -private fun containsNotKey(expect: Expect>, key: String?) = - expect containsNotKey key - -private fun isEmpty(expect: Expect>) = expect toBe Empty - -private fun isNotEmpty(expect: Expect>) = expect notToBe Empty diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt index ad3660463..116e485fc 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryAssertionsSpec.kt @@ -8,10 +8,17 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.specs.withNullableSuffix class MapEntryAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryAssertionsSpec( - fun1(Expect>::isKeyValue).name to ::isKeyValue, - (fun1(Expect>::isKeyValue).name to ::isKeyValueNullable).withNullableSuffix() + fun1(Expect>::isKeyValue).name to Companion::isKeyValue, + (fun1(Expect>::isKeyValue).name to Companion::isKeyValueNullable).withNullableSuffix() ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + + private fun isKeyValue(expect: Expect>, key: String, value: Int) = + expect isKeyValue (key to value) + + private fun isKeyValueNullable(expect: Expect>, key: String?, value: Int?) = + expect isKeyValue (key to value) + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -34,9 +41,3 @@ class MapEntryAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryAsser star isKeyValue (null to null) } } - -private fun isKeyValue(expect: Expect>, key: String, value: Int) = - expect isKeyValue (key to value) - -private fun isKeyValueNullable(expect: Expect>, key: String?, value: Int?) = - expect isKeyValue (key to value) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt index 4e3532f5b..b910e13d8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapFeatureAssertionsSpec.kt @@ -11,11 +11,26 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA property, Collection>(Expect>::values), fun1, Expect>.() -> Unit>(Expect>::values), feature1, String, Int>(Expect>::getExisting), - fun2, String, Expect.() -> Unit>(::getExisting), + fun2, String, Expect.() -> Unit>(Companion::getExisting), feature1, String?, Int?>(Expect>::getExisting).withNullableSuffix(), - fun2, String?, Expect.() -> Unit>(::getExisting).withNullableSuffix() + fun2, String?, Expect.() -> Unit>(Companion::getExisting).withNullableSuffix() ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + + private fun getExisting( + expect: Expect>, + key: String, + assertionCreator: Expect.() -> Unit + ): Expect> = expect getExisting key(key) { assertionCreator() } + + @JvmName("getExistingNullable") + private fun getExisting( + expect: Expect>, + key: String?, + assertionCreator: Expect.() -> Unit + ): Expect> = expect getExisting key(key) { assertionCreator() } + + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -36,16 +51,3 @@ class MapFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapFeatureA star = star getExisting key("a") { } } } - -private fun getExisting( - expect: Expect>, - key: String, - assertionCreator: Expect.() -> Unit -): Expect> = expect getExisting key(key) { assertionCreator() } - -@JvmName("getExistingNullable") -private fun getExisting( - expect: Expect>, - key: String?, - assertionCreator: Expect.() -> Unit -): Expect> = expect getExisting key(key) { assertionCreator() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt index dafb037b7..65f638b55 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -3,17 +3,35 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.specs.testutils.WithAsciiReporter -import ch.tutteli.atrium.specs.withFeatureSuffix class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAssertionsSpec( property(Expect::message), fun1.() -> Unit>(Expect::message), - fun2(::messageContains), - ("cause" to ::causeFeature).withFeatureSuffix(), - "cause" to ::cause + fun2(Companion::messageContains), + ("cause" to Companion::causeFeature).withFeatureSuffix(), + "cause" to Companion::cause ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + + private fun messageContains( + expect: Expect, + expected: Any, + vararg otherExpected: Any + ): Expect = + if (otherExpected.isEmpty()) expect messageContains expected + else expect messageContains Values(expected, *otherExpected) + + @Suppress("RemoveExplicitTypeArguments") + private fun causeFeature(expect: Expect): Expect = + expect.cause() + + @Suppress("RemoveExplicitTypeArguments") + private fun cause( + expect: Expect, + assertionCreator: Expect.() -> Unit + ) = expect.cause(assertionCreator) + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -29,15 +47,3 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1.cause { message { } } } } - -private fun messageContains(expect: Expect, expected: Any, vararg otherExpected: Any): Expect = - if (otherExpected.isEmpty()) expect messageContains expected - else expect messageContains Values(expected, *otherExpected) - -@Suppress("RemoveExplicitTypeArguments") -private fun causeFeature(expect: Expect): Expect = - expect.cause() - -@Suppress("RemoveExplicitTypeArguments") -private fun cause(expect: Expect, assertionCreator: Expect.() -> Unit) = - expect.cause(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index 00d1d0d4a..25b3427df 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -9,18 +9,26 @@ import java.nio.file.Path import java.nio.file.Paths class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpec( - fun1(Expect::to).name to ::exists, - fun1(Expect::notTo).name to ::existsNot, + fun1(Expect::to).name to Companion::exists, + fun1(Expect::notTo).name to Companion::existsNot, fun1(Expect::startsWith), fun1(Expect::startsNotWith), fun1(Expect::endsWith), fun1(Expect::endsNotWith), - fun1(Expect::toBe).name to ::isReadable, - fun1(Expect::toBe).name to ::isWritable, - fun1(Expect::toBe).name to ::isRegularFile, - fun1(Expect::toBe).name to ::isDirectory + fun1(Expect::toBe).name to Companion::isReadable, + fun1(Expect::toBe).name to Companion::isWritable, + fun1(Expect::toBe).name to Companion::isRegularFile, + fun1(Expect::toBe).name to Companion::isDirectory ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter(){ + + private fun exists(expect: Expect) = expect to exist + private fun existsNot(expect: Expect) = expect notTo exist + private fun isReadable(expect: Expect) = expect toBe readable + private fun isWritable(expect: Expect) = expect toBe writable + private fun isRegularFile(expect: Expect) = expect toBe aRegularFile + private fun isDirectory(expect: Expect) = expect toBe aDirectory + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -39,11 +47,4 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe } } -private fun exists(expect: Expect) = expect to exist -private fun existsNot(expect: Expect) = expect notTo exist -private fun isReadable(expect: Expect) = expect toBe readable -private fun isWritable(expect: Expect) = expect toBe writable -private fun isRegularFile(expect: Expect) = expect toBe aRegularFile -private fun isDirectory(expect: Expect) = expect toBe aDirectory - class DummyPath(path: Path) : Path by path diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt index dbd8fbcc6..0ad8952ac 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -1,7 +1,10 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.feature1 +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.property import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import java.nio.file.Path @@ -9,7 +12,7 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur property(Expect::parent), fun1.() -> Unit>(Expect::parent), feature1(Expect::resolve), - "resolve with assertionCreator not implemented in this API" to ::resolve, + "resolve with assertionCreator not implemented in this API" to Companion::resolve, property(Expect::fileName), fun1.() -> Unit>(Expect::fileName), property(Expect::fileNameWithoutExtension), @@ -17,7 +20,14 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur property(Expect::extension), fun1.() -> Unit>(Expect::extension) ) { - companion object : WithAsciiReporter() + companion object : WithAsciiReporter() { + + private fun resolve( + expect: Expect, + other: String, + assertionCreator: Expect.() -> Unit + ): Expect = (expect resolve other).addAssertionsCreatedBy(assertionCreator) + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { @@ -39,5 +49,3 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur } } -private fun resolve(expect: Expect, other: String, assertionCreator: Expect.() -> Unit): Expect = - (expect resolve other).addAssertionsCreatedBy(assertionCreator) From 2363f798313c3a698108da0d751ba3d2a3d9a8a8 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 21 Mar 2020 22:55:28 +0100 Subject: [PATCH 105/142] add resolve with assertionCreator to the new infix API --- .../api/fluent/en_GB/jdk8/pathAssertions.kt | 4 ++-- .../jdk8/creating/path/PathWithCreator.kt | 15 ++++++++++++ .../api/infix/en_GB/jdk8/pathAssertions.kt | 23 ++++++++++++++++++- .../en_GB/jdk8/PathFeatureAssertionsSpec.kt | 10 ++++---- 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt index 445fe5071..d89c7efe1 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/pathAssertions.kt @@ -146,7 +146,7 @@ val Expect.parent: Expect get() = ExpectImpl.path.parent(this).getExpectOfFeature() /** - * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the + * Expects that this [Path] has a [parent][Path.getParent], that the parent holds all assertions the * given [assertionCreator] creates for it and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. @@ -170,7 +170,7 @@ fun Expect.resolve(other: String): Expect = ExpectImpl.path.resolve(this, other).getExpectOfFeature() /** - * Expects that [other] resolves against this [Path] and that the resolved [Path] holds all assertions the + * Expects that [other] resolves against this [Path], that the resolved [Path] holds all assertions the * given [assertionCreator] creates for it and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt new file mode 100644 index 000000000..8a8fa4dde --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt @@ -0,0 +1,15 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.path + +import ch.tutteli.atrium.creating.Expect + +/** + * Parameter object which combines an [path] (as [String]) with an [assertionCreator] which defines assertions for + * a resulting feature of type [E]. + * + * Use the function `path(String) { ... }` to create this representation. + * + * @since 0.11.0 + */ +data class PathWithCreator(val path: String, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index 69296b108..b63fe1add 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -2,6 +2,7 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 +import ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.path.PathWithCreator import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.path @@ -148,7 +149,7 @@ val Expect.parent: Expect get() = ExpectImpl.path.parent(this).getExpectOfFeature() /** - * Expects that this [Path] has a [parent][Path.getParent] and that the parent holds all assertions the + * Expects that this [Path] has a [parent][Path.getParent], that the parent holds all assertions the * given [assertionCreator] creates for it and returns an [Expect] for the current subject of the assertion. * * @return An [Expect] for the current subject of the assertion. @@ -171,6 +172,26 @@ infix fun Expect.parent(assertionCreator: Expect.() -> Unit) infix fun Expect.resolve(other: String): Expect = ExpectImpl.path.resolve(this, other).getExpectOfFeature() +/** + * Expects that [PathWithCreator.path] resolves against this [Path], that the resolved [Path] holds all assertions the + * given [PathWithCreator.assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. + * + * Use the function `path(String) { ... }` to create a [PathWithCreator]. + * + * @return The newly created [Expect] for the extracted feature. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun Expect.resolve(path: PathWithCreator): Expect = + ExpectImpl.path.resolve(this, path.path).addToInitial(path.assertionCreator) + +/** + * Helper function to create an [PathWithCreator] based on the given [path] and [assertionCreator]. + */ +fun path(path: String, assertionCreator: Expect.() -> Unit) = PathWithCreator(path, assertionCreator) + /** * Expects that the subject of the assertion (a [Path]) is readable; * meaning that there is a file system entry at the location the [Path] points to and diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt index 0ad8952ac..9cc4619fa 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathFeatureAssertionsSpec.kt @@ -1,10 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.feature1 -import ch.tutteli.atrium.specs.fun1 -import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import java.nio.file.Path @@ -12,7 +9,7 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur property(Expect::parent), fun1.() -> Unit>(Expect::parent), feature1(Expect::resolve), - "resolve with assertionCreator not implemented in this API" to Companion::resolve, + fun2(Companion::resolve), property(Expect::fileName), fun1.() -> Unit>(Expect::fileName), property(Expect::fileNameWithoutExtension), @@ -26,7 +23,7 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur expect: Expect, other: String, assertionCreator: Expect.() -> Unit - ): Expect = (expect resolve other).addAssertionsCreatedBy(assertionCreator) + ): Expect = expect resolve path(other) { assertionCreator() } } @Suppress("unused", "UNUSED_VALUE") @@ -46,6 +43,7 @@ class PathFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.PathFeatur a1 parent {} a1 resolve "test" + a1 resolve path("test") {} } } From 58d3d8b2fe485d2c9b02e300adae2f9a25372093 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sun, 22 Mar 2020 22:19:06 +0100 Subject: [PATCH 106/142] change Charsequence `contains not` to `containsNot o` Even though `contains not` looks nicer it is better to have `containsNot o` as it fits into the other `containsNot` functions. --- ...quenceContainsContainsNotAssertionsSpec.kt | 43 ++++++++++++++++--- .../api/infix/en_GB/charSequenceAssertions.kt | 8 ++-- ...quenceContainsContainsNotAssertionsSpec.kt | 41 ++++++++++++++---- .../CharSequenceContainsNotAssertionsSpec.kt | 8 ++-- .../en_GB/CharSequenceContainsSpecBase.kt | 17 ++++++++ ...quenceContainsContainsNotAssertionsSpec.kt | 4 +- 6 files changed, 96 insertions(+), 25 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index 8ea1a64ec..01e19abd6 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -3,13 +3,44 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented +import org.spekframework.spek2.Spek -class CharSequenceContainsContainsNotAssertionsSpec : - ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( - fun2>(Expect::contains), - fun2>(Expect::containsNot), - "◆ ", "⚬ ", "▶ " - ) { +class CharSequenceContainsContainsNotAssertionsSpec : Spek({ + + include(object : ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( + getContainsPair(), + getContainsNotPair(), + "◆ ", "⚬ ", "▶ ", + "[Atrium][Builder]" + ) {}) + + include(object : ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( + getContainsShortcutPair(), + getContainsNotShortcutPair(), + "◆ ", "⚬ ", "▶ ", + "[Atrium][Shortcut]" + ) {}) +}) { + companion object : CharSequenceContainsSpecBase() { + private fun getContainsPair() = "$contains.$atLeast(1).values" to Companion::containsValues + + private fun containsValues(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect.contains.atLeast(1).value(a) + else expect.contains.atLeast(1).values(a, *aX) + + private fun getContainsNotPair() = + "${super.containsNot} o $atLeast 1 value/the Values" to Companion::containsNotValues + + private fun containsNotValues(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect.containsNot.value(a) + else expect.containsNot.values(a, *aX) + + private fun getContainsShortcutPair() = + fun2>(Expect::contains) + + private fun getContainsNotShortcutPair() = + fun2>(Expect::containsNot) + } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt index 955aaac46..ec6e5d2fc 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -28,8 +28,8 @@ infix fun Expect.contains( * * @return The newly created builder. */ -infix fun Expect.contains( - @Suppress("UNUSED_PARAMETER") not: not +infix fun Expect.containsNot( + @Suppress("UNUSED_PARAMETER") o: o ): NotCheckerOption = NotCheckerOptionImpl(ExpectImpl.charSequence.containsNotBuilder(this)) @@ -90,7 +90,7 @@ infix fun Expect.contains(values: Values): Expect * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.containsNot(expected: Any) = - this contains not value expected + this containsNot O value expected /** * Expects that the subject of the assertion (a [CharSequence]) does not contain the [toString] representation @@ -105,7 +105,7 @@ infix fun Expect.containsNot(expected: Any) = * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.containsNot(values: Values) = - this contains not the values + this containsNot O the values /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index 087f9b912..a2af35ca0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -3,15 +3,39 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import org.spekframework.spek2.Spek -class CharSequenceContainsContainsNotAssertionsSpec : - ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( - fun2>(Companion::contains), - fun2>(Companion::containsNot), - "* ", "- ", ">> " - ) { - companion object : WithAsciiReporter() { +class CharSequenceContainsContainsNotAssertionsSpec : Spek({ + + include(object : ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( + getContainsPair(), + getContainsNotPair(), + "* ", "- ", ">> ", + "[Atrium][Builder]" + ) {}) + + include(object : ch.tutteli.atrium.specs.integration.CharSequenceContainsContainsNotAssertionsSpec( + getContainsShortcutPair(), + getContainsNotShortcutPair(), + "* ", "- ", ">> ", + "[Atrium][Shortcut]" + ) {}) +}) { + companion object : CharSequenceContainsSpecBase() { + + private fun getContainsPair() = "$contains o $atLeast 1 value/the Values" to Companion::containsBuilder + + private fun containsBuilder(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect contains o atLeast 1 value a + else expect contains o atLeast 1 the Values(a, *aX) + + private fun getContainsNotPair() = "$containsNot o $atLeast 1 value/the Values" to Companion::containsNotBuilder + private fun containsNotBuilder(expect: Expect, a: Any, aX: Array) = + if (aX.isEmpty()) expect containsNot o value a + else expect containsNot o the Values(a, *aX) + + private fun getContainsShortcutPair() = fun2>(Companion::contains) + private fun getContainsNotShortcutPair() = fun2>(Companion::containsNot) private fun contains(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect contains a @@ -20,7 +44,6 @@ class CharSequenceContainsContainsNotAssertionsSpec : private fun containsNot(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot a else expect containsNot Values(a, *aX) - } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt index 6a83923e7..00562a552 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt @@ -15,15 +15,15 @@ class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integratio (containsNotValues to Companion::containsNotFun) private fun containsNotFun(expect: Expect, a: Any, aX: Array) = - if (aX.isEmpty()) expect contains not value a - else expect contains not the Values(a, *aX) + if (aX.isEmpty()) expect containsNot o value a + else expect containsNot o the Values(a, *aX) private fun getContainsNotIgnoringCaseTriple() = { what: String -> "$containsNotValues $ignoringCase $what" } to ("$containsNotValues o $ignoringCase" to Companion::containsNotIgnoringCase) private fun containsNotIgnoringCase(expect: Expect, a: Any, aX: Array) = - if (aX.isEmpty()) expect contains not ignoring case value a - else expect contains not ignoring case the Values(a, *aX) + if (aX.isEmpty()) expect containsNot o ignoring case value a + else expect containsNot o ignoring case the Values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index ced5a1fbc..ed8c72dfa 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -1,9 +1,11 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour +import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NotSearchBehaviour import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented @@ -14,6 +16,10 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { private val containsProp: KFunction2, o, CharSequenceContains.Builder> = Expect::contains protected val contains = containsProp.name + private val containsNotProp: KFunction2, o, NotCheckerOption> = + Expect::containsNot + protected val containsNot = containsNotProp.name + private val containsNotFun: KFunction2, Any, Expect> = Expect::containsNot protected val containsNotValues = "${containsNotFun.name} ${Values::class.simpleName}" protected val containsRegex = fun1(Expect::containsRegex).name @@ -42,6 +48,7 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { a1 contains o atLeast 2 matchFor Regex("bla") a1 contains o atLeast 2 matchFor All(Regex("bla"), Regex("b")) a1 contains o atLeast 2 elementsOf listOf(1, 2) + a1 containsNot o a1 contains o ignoring case atLeast 1 value "a" a1 contains o ignoring case atLeast 1 the Values("a", 'b') @@ -56,5 +63,15 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { a1 contains o ignoring case the RegexPatterns("a", "bl") //TODO add to infix as well as fluent //a1 contains o ignoring case elementsOf listOf(1, 2) + + + + a1 and { o contains O atLeast 1 value 1 } + a1 and { o contains O atMost 2 the Values("a", 1) } + a1 and { o contains O notOrAtMost 2 regex "h|b" } + a1 and { o contains O exactly 2 the RegexPatterns("h|b", "b") } + a1 and { o contains O atLeast 2 matchFor Regex("bla") } + a1 and { o contains O atLeast 2 matchFor All(Regex("bla"), Regex("b")) } + a1 and { o contains O atLeast 2 elementsOf listOf(1, 2) } } } diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotAssertionsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotAssertionsSpec.kt index 92189eb8a..244b86b0a 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -8,8 +8,8 @@ import ch.tutteli.atrium.translations.DescriptionCharSequenceAssertion.CONTAINS_ import org.spekframework.spek2.style.specification.Suite abstract class CharSequenceContainsContainsNotAssertionsSpec( - contains: Fun2>, - containsNot: Fun2>, + contains: Fun2>, + containsNot: Fun2>, rootBulletPoint: String, listBulletPoint: String, featureArrow: String, From cb920d56573dcf4d122d922022ceec1e19673082 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2020 04:34:36 +0000 Subject: [PATCH 107/142] Bump junit-jupiter-engine from 5.6.0 to 5.6.1 Bumps [junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.6.0 to 5.6.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.6.0...r5.6.1) Signed-off-by: dependabot-preview[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 929bde2c5..58b00e5c8 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { // test jacoco_tool_version = '0.8.5' junit_platform_version = '1.6.0' - jupiter_version = '5.6.0' + jupiter_version = '5.6.1' spek_version = '1.1.5' spek2_version = '2.0.10' spekExtensions_version = '1.1.0' From 603dbf51a226248e71e9d98699d7dd52e3c2a5e9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2020 06:03:28 +0000 Subject: [PATCH 108/142] Bump junit-platform-console from 1.6.0 to 1.6.1 Bumps [junit-platform-console](https://github.com/junit-team/junit5) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/commits) Signed-off-by: dependabot-preview[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 58b00e5c8..9624a44dc 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ buildscript { // test jacoco_tool_version = '0.8.5' - junit_platform_version = '1.6.0' + junit_platform_version = '1.6.1' jupiter_version = '5.6.1' spek_version = '1.1.5' spek2_version = '2.0.10' From 37c30c1bf2ee289b4ca17e196903bc50f3772af0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2020 04:34:50 +0000 Subject: [PATCH 109/142] Bump kotlin_version from 1.3.70 to 1.3.71 Bumps `kotlin_version` from 1.3.70 to 1.3.71. Updates `kotlin-stdlib-jdk8` from 1.3.70 to 1.3.71 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.3.71/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.70...v1.3.71) Updates `kotlin-reflect` from 1.3.70 to 1.3.71 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.3.71/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.70...v1.3.71) Updates `kotlin-gradle-plugin` from 1.3.70 to 1.3.71 Signed-off-by: dependabot-preview[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9624a44dc..5d8da2dc8 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { kbox = { "ch.tutteli.kbox:kbox:$kbox_version" } niok_version = '1.3.4' niok = { "ch.tutteli.niok:niok:$niok_version" } - kotlin_version = '1.3.70' + kotlin_version = '1.3.71' // test jacoco_tool_version = '0.8.5' From f28bde30ac9f05269c61fd595b2c00e12b868855 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 25 Mar 2020 21:19:09 +0100 Subject: [PATCH 110/142] change `o` to `it` there are two reasons for this: - people are confused about `o` - Kotlins bug that val has precedence over an object --- .../atrium/api/infix/en_GB/anyAssertions.kt | 6 +- .../api/infix/en_GB/charSequenceAssertions.kt | 29 +++---- .../atrium/api/infix/en_GB/keywords.kt | 10 --- .../api/infix/en_GB/throwableAssertions.kt | 4 +- .../api/infix/en_GB/AnyAssertionsSpec.kt | 10 +-- ...arSequenceContainsAtLeastAssertionsSpec.kt | 4 +- .../en_GB/CharSequenceContainsSpecBase.kt | 16 ++-- ...sertionsBoundedReferenceAlternativeSpec.kt | 78 +++++++++---------- .../FeatureAssertionsBoundedReferenceSpec.kt | 76 +++++++++--------- .../FeatureAssertionsClassReferenceSpec.kt | 78 +++++++++---------- .../en_GB/FeatureAssertionsManualSpec.kt | 77 +++++++++--------- 11 files changed, 191 insertions(+), 197 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt index be575a646..8f3bc3d7d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/anyAssertions.kt @@ -60,6 +60,8 @@ inline infix fun Expect.toBeNullIfNullGivenElse( * * It delegates to [isA] with [T] as type. * + * @param o The filler object [o]. + * * @return An [Expect] with the non-nullable type [T] (was `T?` before). * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @@ -154,6 +156,8 @@ inline infix fun Expect<*>.isA(noinline assertionCreator: E * asserts that 1 is greater than 0. If the first assertion fails, then usually (depending on the configured * [AssertionChecker]) the second assertion is not evaluated. * + * @param o The filler object [o]. + * * @return An [Expect] for the current subject of the assertion. * * @since 0.11.0 @@ -194,4 +198,4 @@ infix fun Expect.and(assertionCreator: Expect.() -> Unit): Expect = * * @return `this` */ -inline val Expect.o get() : Expect = this +inline val Expect.it get() : Expect = this diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt index ec6e5d2fc..59b75e47d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -13,8 +13,7 @@ import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours. * Creates a [CharSequenceContains.Builder] based on this [Expect] which allows to define * a sophisticated `contains` assertion. * - * @param o The filler object [o]; use [O] in case you are in an [Expect] context due to a Kotlin bug - * (see type alias for more information) + * @param o The filler object [o]. * * @return The newly created builder. */ @@ -26,6 +25,8 @@ infix fun Expect.contains( * Creates a [CharSequenceContains.Builder] based on this [Expect] which allows to define * more sophisticated `contains not` assertion. * + * @param o The filler object [o]. + * * @return The newly created builder. */ infix fun Expect.containsNot( @@ -47,7 +48,7 @@ infix fun Expect.containsNot( * [CharSequence], [Number] or [Char]. */ infix fun Expect.contains(expected: Any): Expect = - this contains O atLeast 1 value expected + this contains o atLeast 1 value expected /** * Expects that the subject of the assertion (a [CharSequence]) contains the [toString] representation of the @@ -76,7 +77,7 @@ infix fun Expect.contains(expected: Any): Expect = * [CharSequence], [Number] or [Char]. */ infix fun Expect.contains(values: Values): Expect = - this contains O atLeast 1 the values + this contains o atLeast 1 the values /** * Expects that the subject of the assertion (a [CharSequence]) does not contain [expected]'s [toString] representation. @@ -90,7 +91,7 @@ infix fun Expect.contains(values: Values): Expect * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.containsNot(expected: Any) = - this containsNot O value expected + this containsNot o value expected /** * Expects that the subject of the assertion (a [CharSequence]) does not contain the [toString] representation @@ -105,7 +106,7 @@ infix fun Expect.containsNot(expected: Any) = * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.containsNot(values: Values) = - this containsNot O the values + this containsNot o the values /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given @@ -119,7 +120,7 @@ infix fun Expect.containsNot(values: Values) = * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.containsRegex(pattern: String): Expect = - this contains O atLeast 1 regex pattern + this contains o atLeast 1 regex pattern /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given @@ -133,7 +134,7 @@ infix fun Expect.containsRegex(pattern: String): Expect * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.contains(pattern: Regex): Expect = - this contains O atLeast 1 matchFor pattern + this contains o atLeast 1 matchFor pattern /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given @@ -158,7 +159,7 @@ infix fun Expect.contains(pattern: Regex): Expect = * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.containsRegex(patterns: RegexPatterns): Expect = - this contains O atLeast 1 the patterns + this contains o atLeast 1 the patterns /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given @@ -183,7 +184,7 @@ infix fun Expect.containsRegex(patterns: RegexPatterns): E * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.contains(patterns: All): Expect = - this contains O atLeast 1 matchFor patterns + this contains o atLeast 1 matchFor patterns /** * Expects that the subject of the assertion (a [CharSequence]) starts with [expected]. * @@ -202,7 +203,7 @@ infix fun Expect.startsWith(expected: CharSequence) = * @since 0.11.0 */ infix fun Expect.startsWith(expected: Char) = - o startsWith expected.toString() + it startsWith expected.toString() /** * Expects that the subject of the assertion (a [CharSequence]) does not start with [expected]. @@ -222,7 +223,7 @@ infix fun Expect.startsNotWith(expected: CharSequence) = * @since 0.11.0 */ infix fun Expect.startsNotWith(expected: Char) = - o startsNotWith expected.toString() + it startsNotWith expected.toString() /** @@ -243,7 +244,7 @@ infix fun Expect.endsWith(expected: CharSequence) = * @since 0.11.0 */ infix fun Expect.endsWith(expected: Char) = - o endsWith expected.toString() + it endsWith expected.toString() /** * Expects that the subject of the assertion (a [CharSequence]) does not end with [expected]. @@ -263,7 +264,7 @@ infix fun Expect.endsNotWith(expected: CharSequence) = * @since 0.11.0 */ infix fun Expect.endsNotWith(expected: Char) = - o endsNotWith expected.toString() + it endsNotWith expected.toString() /** diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 225a2e150..157da351a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -71,16 +71,6 @@ object not : Keyword */ object o : Keyword -/** - * Workaround for https://youtrack.jetbrains.com/issue/KT-36624, extension property takes precedence over object. - * - * In case you want to refer to the pseudo-keyword `o` inside an [Expect] context, - * then you can use this type alias instead to circumvent the bug. - * - * @since 0.11.0 - */ -typealias O = o - /** * Represents the pseudo keyword `only` as in [and] `only`. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt index 35b904e22..c44a293e6 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -11,7 +11,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ val Expect.message: Expect - get() = o feature Throwable::message notToBeNull O + get() = it feature Throwable::message notToBeNull o /** * Expects that the property [Throwable.message] of the subject of the assertion is not null and @@ -22,7 +22,7 @@ val Expect.message: Expect * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.message(assertionCreator: Expect.() -> Unit): Expect = - o feature of(Throwable::message) { o notToBeNull assertionCreator } + it feature of(Throwable::message) { it notToBeNull assertionCreator } /** * Expects that the property [Throwable.message] of the subject of the assertion is not null and contains diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt index 2153dab93..dd9b69d48 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/AnyAssertionsSpec.kt @@ -75,7 +75,7 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( isA(expect, assertionCreator) private fun isAIntLess(expect: Expect, number: Int) = - expect.isA { o isLessThan number } + expect.isA { it isLessThan number } private fun notToBeNull(expect: Expect, assertionCreator: Expect.() -> Unit) = expect notToBeNull assertionCreator @@ -85,8 +85,8 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( private fun notToBeNullGreaterAndLess(expect: Expect, lowerBound: Int, upperBound: Int) = expect.notToBeNull { - o isGreaterThan lowerBound - o isLessThan upperBound + it isGreaterThan lowerBound + it isLessThan upperBound } } @@ -121,10 +121,10 @@ class AnyAssertionsSpec : ch.tutteli.atrium.specs.integration.AnyAssertionsSpec( a1b notToBeNull {} a1 and o toBe 1 - a1 and { o toBe 1 } + a1 and { it toBe 1 } } //regression for #298, should compile without the need for E : Any or List @Suppress("unused") - fun Expect>.firstIs(value: E) = o get index(0) { o toBe value } + fun Expect>.firstIs(value: E) = it get index(0) { it toBe value } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index 47cbe2149..74e664bbf 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -33,14 +33,14 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ it("passing an empty iterable throws an IllegalArgumentException") { expect { expect("test") contains o atLeast 1 elementsOf emptyList() - }.toThrow { o messageContains "Iterable without elements are not allowed" } + }.toThrow { it messageContains "Iterable without elements are not allowed" } } } describe("elementsOf ignoring case") { it("passing an empty iterable throws an IllegalArgumentException") { expect { expect("test") contains o ignoring case atLeast 1 elementsOf emptyList() - }.toThrow { o messageContains "Iterable without elements are not allowed" } + }.toThrow { it messageContains "Iterable without elements are not allowed" } } } }) {}) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index ed8c72dfa..ea4aecd41 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -64,14 +64,12 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { //TODO add to infix as well as fluent //a1 contains o ignoring case elementsOf listOf(1, 2) - - - a1 and { o contains O atLeast 1 value 1 } - a1 and { o contains O atMost 2 the Values("a", 1) } - a1 and { o contains O notOrAtMost 2 regex "h|b" } - a1 and { o contains O exactly 2 the RegexPatterns("h|b", "b") } - a1 and { o contains O atLeast 2 matchFor Regex("bla") } - a1 and { o contains O atLeast 2 matchFor All(Regex("bla"), Regex("b")) } - a1 and { o contains O atLeast 2 elementsOf listOf(1, 2) } + a1 and { it contains o atLeast 1 value 1 } + a1 and { it contains o atMost 2 the Values("a", 1) } + a1 and { it contains o notOrAtMost 2 regex "h|b" } + a1 and { it contains o exactly 2 the RegexPatterns("h|b", "b") } + a1 and { it contains o atLeast 2 matchFor Regex("bla") } + a1 and { it contains o atLeast 2 matchFor All(Regex("bla"), Regex("b")) } + a1 and { it contains o atLeast 2 elementsOf listOf(1, 2) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt index 5019cbc67..f98a20180 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceAlternativeSpec.kt @@ -55,57 +55,57 @@ class FeatureAssertionsBoundedReferenceAlternativeSpec : ch.tutteli.atrium.specs //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again companion object : WithAsciiReporter() { //@formatter:off - val propertyImmediate: F = { o feature { p(it::nonNullValue) } contains "hello" } - val propertyLazy: F = { o feature of({ p(it::nonNullValue) }) { o contains "hello" } } - val f0Immediate: F = { o feature { f0(it::return0) } contains "hello" } - val f1Immediate: F = { o feature { f1(it::return1, "a") } contains "hello" } - val f2Immediate: F = { o feature { f2(it::return2, "a", 1) } contains "hello" } - val f3Immediate: F = { o feature { f3(it::return3, "a", 1, true) } contains "hello" } - val f4Immediate: F = { o feature { f4(it::return4, "a", 1, true, 1.2) } contains "hello" } - val f5Immediate: F = { o feature { f5(it::return5, "a", 1, true, 1.2, 'b') } contains "hello" } - val f0Lazy: F = { o feature of({ f0(it::return0) }) { o contains "hello" } } - val f1Lazy: F = { o feature of({ f1(it::return1, "a") }) { o contains "hello" } } - val f2Lazy: F = { o feature of({ f2(it::return2, "a", 1) }) { o contains "hello" } } - val f3Lazy: F = { o feature of({ f3(it::return3, "a", 1, true) }) { o contains "hello" } } - val f4Lazy: F = { o feature of({ f4(it::return4, "a", 1, true, 1.2) }) { o contains "hello" } } - val f5Lazy: F = { o feature of({ f5(it::return5, "a", 1, true, 1.2, 'b') }) { o contains "hello" } } + val propertyImmediate: F = { it feature { p(it::nonNullValue) } contains "hello" } + val propertyLazy: F = { it feature of({ p(it::nonNullValue) }) { it contains "hello" } } + val f0Immediate: F = { it feature { f0(it::return0) } contains "hello" } + val f1Immediate: F = { it feature { f1(it::return1, "a") } contains "hello" } + val f2Immediate: F = { it feature { f2(it::return2, "a", 1) } contains "hello" } + val f3Immediate: F = { it feature { f3(it::return3, "a", 1, true) } contains "hello" } + val f4Immediate: F = { it feature { f4(it::return4, "a", 1, true, 1.2) } contains "hello" } + val f5Immediate: F = { it feature { f5(it::return5, "a", 1, true, 1.2, 'b') } contains "hello" } + val f0Lazy: F = { it feature of({ f0(it::return0) }) { it contains "hello" } } + val f1Lazy: F = { it feature of({ f1(it::return1, "a") }) { it contains "hello" } } + val f2Lazy: F = { it feature of({ f2(it::return2, "a", 1) }) { it contains "hello" } } + val f3Lazy: F = { it feature of({ f3(it::return3, "a", 1, true) }) { it contains "hello" } } + val f4Lazy: F = { it feature of({ f4(it::return4, "a", 1, true, 1.2) }) { it contains "hello" } } + val f5Lazy: F = { it feature of({ f5(it::return5, "a", 1, true, 1.2, 'b') }) { it contains "hello" } } - val propertyNullableDoesNotHold: F = { o feature { p(it::nullableValue) } toBe null } - val f0NullableDoesNotHold: F = { o feature { f0(it::returnNullable0) } toBe null } - val f1NullableDoesNotHold: F = { o feature { f1(it::returnNullable1, "a") } toBe null } - val f2NullableDoesNotHold: F = { o feature { f2(it::returnNullable2, "a", 1) } toBe null } - val f3NullableDoesNotHold: F = { o feature { f3(it::returnNullable3, "a", 1, true) } toBe null } - val f4NullableDoesNotHold: F = { o feature { f4(it::returnNullable4, "a", 1, true, 1.2) } toBe null } - val f5NullableDoesNotHold: F = { o feature { f5(it::returnNullable5, "a", 1, true, 1.2, 'b') } toBe null } + val propertyNullableDoesNotHold: F = { it feature { p(it::nullableValue) } toBe null } + val f0NullableDoesNotHold: F = { it feature { f0(it::returnNullable0) } toBe null } + val f1NullableDoesNotHold: F = { it feature { f1(it::returnNullable1, "a") } toBe null } + val f2NullableDoesNotHold: F = { it feature { f2(it::returnNullable2, "a", 1) } toBe null } + val f3NullableDoesNotHold: F = { it feature { f3(it::returnNullable3, "a", 1, true) } toBe null } + val f4NullableDoesNotHold: F = { it feature { f4(it::returnNullable4, "a", 1, true, 1.2) } toBe null } + val f5NullableDoesNotHold: F = { it feature { f5(it::returnNullable5, "a", 1, true, 1.2, 'b') } toBe null } - val propertyNullableHolds: F = { o feature { p(it::nullableValue) } notToBeNull { o toBe 1 } } - val f0NullableHolds: F = { o feature { f0(it::returnNullable0) } notToBeNull { o toBe 1 } } - val f1NullableHolds: F = { o feature { f1(it::returnNullable1, "a") } notToBeNull { o toBe 1 } } - val f2NullableHolds: F = { o feature { f2(it::returnNullable2, "a", 1) } notToBeNull { o toBe 1 } } - val f3NullableHolds: F = { o feature { f3(it::returnNullable3, "a", 1, true) } notToBeNull { o toBe 1 } } - val f4NullableHolds: F = { o feature { f4(it::returnNullable4, "a", 1, true, 1.2) } notToBeNull { o toBe 1 } } - val f5NullableHolds: F = { o feature { f5(it::returnNullable5, "a", 1, true, 1.2, 'b') } notToBeNull { o toBe 1 } } + val propertyNullableHolds: F = { it feature { p(it::nullableValue) } notToBeNull { it toBe 1 } } + val f0NullableHolds: F = { it feature { f0(it::returnNullable0) } notToBeNull { it toBe 1 } } + val f1NullableHolds: F = { it feature { f1(it::returnNullable1, "a") } notToBeNull { it toBe 1 } } + val f2NullableHolds: F = { it feature { f2(it::returnNullable2, "a", 1) } notToBeNull { it toBe 1 } } + val f3NullableHolds: F = { it feature { f3(it::returnNullable3, "a", 1, true) } notToBeNull { it toBe 1 } } + val f4NullableHolds: F = { it feature { f4(it::returnNullable4, "a", 1, true, 1.2) } notToBeNull { it toBe 1 } } + val f5NullableHolds: F = { it feature { f5(it::returnNullable5, "a", 1, true, 1.2, 'b') } notToBeNull { it toBe 1 } } //@formatter:on val propertyLazyWithNestedImmediate: F = { - o feature { p(it::nonNullValue) } it { - o feature { p(it::length) } toBe 12 + it feature { p(it::nonNullValue) } it { + it feature { p(it::length) } toBe 12 } } val propertyLazyWithNestedLazy: F = { - o feature { p(it::nonNullValue) } it { - o feature { p(it::length) } it { o toBe 12 } + it feature { p(it::nonNullValue) } it { + it feature { p(it::length) } it { it toBe 12 } } } - val propertyEmptyAssertionCreator: F = { o feature of({ p(it::nonNullValue) }) {} } - val f0EmptyAssertionCreator: F = { o feature of({ f0(it::return0) }) {} } - val f1EmptyAssertionCreator: F = { o feature of({ f1(it::return1, "a") }) {} } - val f2EmptyAssertionCreator: F = { o feature of({ f2(it::return2, "a", 1) }) {} } - val f3EmptyAssertionCreator: F = { o feature of({ f3(it::return3, "a", 1, true) }) {} } - val f4EmptyAssertionCreator: F = { o feature of({ f4(it::return4, "a", 1, true, 1.2) }) {} } + val propertyEmptyAssertionCreator: F = { it feature of({ p(it::nonNullValue) }) {} } + val f0EmptyAssertionCreator: F = { it feature of({ f0(it::return0) }) {} } + val f1EmptyAssertionCreator: F = { it feature of({ f1(it::return1, "a") }) {} } + val f2EmptyAssertionCreator: F = { it feature of({ f2(it::return2, "a", 1) }) {} } + val f3EmptyAssertionCreator: F = { it feature of({ f3(it::return3, "a", 1, true) }) {} } + val f4EmptyAssertionCreator: F = { it feature of({ f4(it::return4, "a", 1, true, 1.2) }) {} } val f5EmptyAssertionCreator: F = - { o feature (of({ f5(it::return5, "a", 1, true, 1.2, 'b') }) {}) } + { it feature (of({ f5(it::return5, "a", 1, true, 1.2, 'b') }) {}) } } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt index 9fa1463b9..c384f8abb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsBoundedReferenceSpec.kt @@ -57,57 +57,57 @@ class FeatureAssertionsBoundedReferenceSpec : ch.tutteli.atrium.specs.integratio //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again companion object : WithAsciiReporter() { //@formatter:off - val propertyImmediate: F = { o feature { f(it::nonNullValue) } contains "hello" } - val propertyLazy: F = { o feature of({ f(it::nonNullValue) }) { o contains "hello" } } - val f0Immediate: F = { o feature { f(it::return0) } contains "hello" } - val f1Immediate: F = { o feature { f(it::return1, "a") } contains "hello" } - val f2Immediate: F = { o feature { f(it::return2, "a", 1) } contains "hello" } - val f3Immediate: F = { o feature { f(it::return3, "a", 1, true) } contains "hello" } - val f4Immediate: F = { o feature { f(it::return4, "a", 1, true, 1.2) } contains "hello" } - val f5Immediate: F = { o feature { f(it::return5, "a", 1, true, 1.2, 'b') } contains "hello" } - val f0Lazy: F = { o feature of({ f(it::return0) }) { o contains "hello" } } - val f1Lazy: F = { o feature of({ f(it::return1, "a") }) { o contains "hello" } } - val f2Lazy: F = { o feature of({ f(it::return2, "a", 1) }) { o contains "hello" } } - val f3Lazy: F = { o feature of({ f(it::return3, "a", 1, true) }) { o contains "hello" } } - val f4Lazy: F = { o feature of({ f(it::return4, "a", 1, true, 1.2) }) { o contains "hello" } } - val f5Lazy: F = { o feature of({ f(it::return5, "a", 1, true, 1.2, 'b') }) { o contains "hello" } } + val propertyImmediate: F = { it feature { f(it::nonNullValue) } contains "hello" } + val propertyLazy: F = { it feature of({ f(it::nonNullValue) }) { it contains "hello" } } + val f0Immediate: F = { it feature { f(it::return0) } contains "hello" } + val f1Immediate: F = { it feature { f(it::return1, "a") } contains "hello" } + val f2Immediate: F = { it feature { f(it::return2, "a", 1) } contains "hello" } + val f3Immediate: F = { it feature { f(it::return3, "a", 1, true) } contains "hello" } + val f4Immediate: F = { it feature { f(it::return4, "a", 1, true, 1.2) } contains "hello" } + val f5Immediate: F = { it feature { f(it::return5, "a", 1, true, 1.2, 'b') } contains "hello" } + val f0Lazy: F = { it feature of({ f(it::return0) }) { it contains "hello" } } + val f1Lazy: F = { it feature of({ f(it::return1, "a") }) { it contains "hello" } } + val f2Lazy: F = { it feature of({ f(it::return2, "a", 1) }) { it contains "hello" } } + val f3Lazy: F = { it feature of({ f(it::return3, "a", 1, true) }) { it contains "hello" } } + val f4Lazy: F = { it feature of({ f(it::return4, "a", 1, true, 1.2) }) { it contains "hello" } } + val f5Lazy: F = { it feature of({ f(it::return5, "a", 1, true, 1.2, 'b') }) { it contains "hello" } } - val propertyNullableDoesNotHold: F = { o feature { f(it::nullableValue) } toBe null } - val f0NullableDoesNotHold: F = { o feature { f(it::returnNullable0) } toBe null } - val f1NullableDoesNotHold: F = { o feature { f(it::returnNullable1, "a") } toBe null } - val f2NullableDoesNotHold: F = { o feature { f(it::returnNullable2, "a", 1) } toBe null } - val f3NullableDoesNotHold: F = { o feature { f(it::returnNullable3, "a", 1, true) } toBe null } - val f4NullableDoesNotHold: F = { o feature { f(it::returnNullable4, "a", 1, true, 1.2) } toBe null } - val f5NullableDoesNotHold: F = { o feature { f(it::returnNullable5, "a", 1, true, 1.2, 'b') } toBe null } + val propertyNullableDoesNotHold: F = { it feature { f(it::nullableValue) } toBe null } + val f0NullableDoesNotHold: F = { it feature { f(it::returnNullable0) } toBe null } + val f1NullableDoesNotHold: F = { it feature { f(it::returnNullable1, "a") } toBe null } + val f2NullableDoesNotHold: F = { it feature { f(it::returnNullable2, "a", 1) } toBe null } + val f3NullableDoesNotHold: F = { it feature { f(it::returnNullable3, "a", 1, true) } toBe null } + val f4NullableDoesNotHold: F = { it feature { f(it::returnNullable4, "a", 1, true, 1.2) } toBe null } + val f5NullableDoesNotHold: F = { it feature { f(it::returnNullable5, "a", 1, true, 1.2, 'b') } toBe null } - val propertyNullableHolds: F = { o feature { f(it::nullableValue) } notToBeNull { o toBe 1 } } - val f0NullableHolds: F = { o feature { f(it::returnNullable0) } notToBeNull { o toBe 1 } } - val f1NullableHolds: F = { o feature { f(it::returnNullable1, "a") } notToBeNull { o toBe 1 } } - val f2NullableHolds: F = { o feature { f(it::returnNullable2, "a", 1) } notToBeNull { o toBe 1 } } - val f3NullableHolds: F = { o feature { f(it::returnNullable3, "a", 1, true) } notToBeNull { o toBe 1 } } - val f4NullableHolds: F = { o feature { f(it::returnNullable4, "a", 1, true, 1.2) } notToBeNull { o toBe 1 } } - val f5NullableHolds: F = { o feature { f(it::returnNullable5, "a", 1, true, 1.2, 'b') } notToBeNull { o toBe 1 } } + val propertyNullableHolds: F = { it feature { f(it::nullableValue) } notToBeNull { it toBe 1 } } + val f0NullableHolds: F = { it feature { f(it::returnNullable0) } notToBeNull { it toBe 1 } } + val f1NullableHolds: F = { it feature { f(it::returnNullable1, "a") } notToBeNull { it toBe 1 } } + val f2NullableHolds: F = { it feature { f(it::returnNullable2, "a", 1) } notToBeNull { it toBe 1 } } + val f3NullableHolds: F = { it feature { f(it::returnNullable3, "a", 1, true) } notToBeNull { it toBe 1 } } + val f4NullableHolds: F = { it feature { f(it::returnNullable4, "a", 1, true, 1.2) } notToBeNull { it toBe 1 } } + val f5NullableHolds: F = { it feature { f(it::returnNullable5, "a", 1, true, 1.2, 'b') } notToBeNull { it toBe 1 } } //@formatter:on val propertyLazyWithNestedImmediate: F = { - o feature of({ f(it::nonNullValue) }) { + it feature of({ f(it::nonNullValue) }) { feature { f(it::length) } toBe 12 } } val propertyLazyWithNestedLazy: F = { - o feature of({ f(it::nonNullValue) }) { - feature { f(it::length) } it { o toBe 12 } + it feature of({ f(it::nonNullValue) }) { + feature { f(it::length) } it { it toBe 12 } } } - val propertyEmptyAssertionCreator: F = { o feature of({ f(it::nonNullValue) }) {} } - val f0EmptyAssertionCreator: F = { o feature of({ f(it::return0) }) {} } - val f1EmptyAssertionCreator: F = { o feature of({ f(it::return1, "a") }) {} } - val f2EmptyAssertionCreator: F = { o feature of({ f(it::return2, "a", 1) }) {} } - val f3EmptyAssertionCreator: F = { o feature of({ f(it::return3, "a", 1, true) }) {} } - val f4EmptyAssertionCreator: F = { o feature of({ f(it::return4, "a", 1, true, 1.2) }) {} } + val propertyEmptyAssertionCreator: F = { it feature of({ f(it::nonNullValue) }) {} } + val f0EmptyAssertionCreator: F = { it feature of({ f(it::return0) }) {} } + val f1EmptyAssertionCreator: F = { it feature of({ f(it::return1, "a") }) {} } + val f2EmptyAssertionCreator: F = { it feature of({ f(it::return2, "a", 1) }) {} } + val f3EmptyAssertionCreator: F = { it feature of({ f(it::return3, "a", 1, true) }) {} } + val f4EmptyAssertionCreator: F = { it feature of({ f(it::return4, "a", 1, true, 1.2) }) {} } val f5EmptyAssertionCreator: F = - { o feature of({ f(it::return5, "a", 1, true, 1.2, 'b') }) {} } + { it feature of({ f(it::return5, "a", 1, true, 1.2, 'b') }) {} } } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt index 901cde901..5eb91a462 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsClassReferenceSpec.kt @@ -54,56 +54,56 @@ class FeatureAssertionsClassReferenceSpec : ch.tutteli.atrium.specs.integration. //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again companion object : WithAsciiReporter() { //@formatter:off - val propertyImmediate: F = { o feature TestData::nonNullValue contains "hello" } - val propertyLazy: F = { o feature of(TestData::nonNullValue) { o contains "hello" } } - val return0ValueImmediate: F = { o feature TestData::return0 contains "hello" } - val return1ValueImmediate: F = { o feature of(TestData::return1, "a") contains "hello" } - val return2ValueImmediate: F = { o feature of(TestData::return2, "a", 1) contains "hello" } - val return3ValueImmediate: F = { o feature of(TestData::return3, "a", 1, true) contains "hello" } - val return4ValueImmediate: F = { o feature of(TestData::return4, "a", 1, true, 1.2) contains "hello" } - val return5ValueImmediate: F = { o feature of(TestData::return5, "a", 1, true, 1.2, 'b') contains "hello" } - val return0ValueLazy: F = { o feature of(TestData::return0) { contains("hello") } } - val return1ValueLazy: F = { o feature of(TestData::return1, "a") { contains("hello") } } - val return2ValueLazy: F = { o feature of(TestData::return2, "a", 1) { contains("hello") } } - val return3ValueLazy: F = { o feature of(TestData::return3, "a", 1, true) { contains("hello") } } - val return4ValueLazy: F = { o feature of(TestData::return4, "a", 1, true, 1.2) { contains("hello") } } - val return5ValueLazy: F = { o feature of(TestData::return5, "a", 1, true, 1.2, 'b') { contains("hello") } } + val propertyImmediate: F = { it feature TestData::nonNullValue contains "hello" } + val propertyLazy: F = { it feature of(TestData::nonNullValue) { it contains "hello" } } + val return0ValueImmediate: F = { it feature TestData::return0 contains "hello" } + val return1ValueImmediate: F = { it feature of(TestData::return1, "a") contains "hello" } + val return2ValueImmediate: F = { it feature of(TestData::return2, "a", 1) contains "hello" } + val return3ValueImmediate: F = { it feature of(TestData::return3, "a", 1, true) contains "hello" } + val return4ValueImmediate: F = { it feature of(TestData::return4, "a", 1, true, 1.2) contains "hello" } + val return5ValueImmediate: F = { it feature of(TestData::return5, "a", 1, true, 1.2, 'b') contains "hello" } + val return0ValueLazy: F = { it feature of(TestData::return0) { contains("hello") } } + val return1ValueLazy: F = { it feature of(TestData::return1, "a") { contains("hello") } } + val return2ValueLazy: F = { it feature of(TestData::return2, "a", 1) { contains("hello") } } + val return3ValueLazy: F = { it feature of(TestData::return3, "a", 1, true) { contains("hello") } } + val return4ValueLazy: F = { it feature of(TestData::return4, "a", 1, true, 1.2) { contains("hello") } } + val return5ValueLazy: F = { it feature of(TestData::return5, "a", 1, true, 1.2, 'b') { contains("hello") } } - val propertyNullableDoesNotHold: F = { o feature TestData::nullableValue toBe null } - val return0ValueNullableDoesNotHold: F = { o feature TestData::returnNullable0 toBe null } - val return1ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable1, "a") toBe null } - val return2ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable2, "a", 1) toBe null } - val return3ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable3, "a", 1, true) toBe null } - val return4ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable4, "a", 1, true, 1.2) toBe null } - val return5ValueNullableDoesNotHold: F = { o feature of(TestData::returnNullable5, "a", 1, true, 1.2, 'b') toBe null } + val propertyNullableDoesNotHold: F = { it feature TestData::nullableValue toBe null } + val return0ValueNullableDoesNotHold: F = { it feature TestData::returnNullable0 toBe null } + val return1ValueNullableDoesNotHold: F = { it feature of(TestData::returnNullable1, "a") toBe null } + val return2ValueNullableDoesNotHold: F = { it feature of(TestData::returnNullable2, "a", 1) toBe null } + val return3ValueNullableDoesNotHold: F = { it feature of(TestData::returnNullable3, "a", 1, true) toBe null } + val return4ValueNullableDoesNotHold: F = { it feature of(TestData::returnNullable4, "a", 1, true, 1.2) toBe null } + val return5ValueNullableDoesNotHold: F = { it feature of(TestData::returnNullable5, "a", 1, true, 1.2, 'b') toBe null } - val propertyNullableHolds: F = { o feature TestData::nullableValue notToBeNull { o toBe 1 } } - val return0ValueNullableHolds: F = { o feature TestData::returnNullable0 notToBeNull { o toBe 1 } } - val return1ValueNullableHolds: F = { o feature of(TestData::returnNullable1, "a") notToBeNull { o toBe 1 } } - val return2ValueNullableHolds: F = { o feature of(TestData::returnNullable2, "a", 1) notToBeNull { o toBe 1 } } - val return3ValueNullableHolds: F = { o feature of(TestData::returnNullable3, "a", 1, true) notToBeNull { o toBe 1 } } - val return4ValueNullableHolds: F = { o feature of(TestData::returnNullable4, "a", 1, true, 1.2) notToBeNull { o toBe 1 } } - val return5ValueNullableHolds: F = { o feature of(TestData::returnNullable5, "a", 1, true, 1.2, 'b') notToBeNull { o toBe 1 } } + val propertyNullableHolds: F = { it feature TestData::nullableValue notToBeNull { it toBe 1 } } + val return0ValueNullableHolds: F = { it feature TestData::returnNullable0 notToBeNull { it toBe 1 } } + val return1ValueNullableHolds: F = { it feature of(TestData::returnNullable1, "a") notToBeNull { it toBe 1 } } + val return2ValueNullableHolds: F = { it feature of(TestData::returnNullable2, "a", 1) notToBeNull { it toBe 1 } } + val return3ValueNullableHolds: F = { it feature of(TestData::returnNullable3, "a", 1, true) notToBeNull { it toBe 1 } } + val return4ValueNullableHolds: F = { it feature of(TestData::returnNullable4, "a", 1, true, 1.2) notToBeNull { it toBe 1 } } + val return5ValueNullableHolds: F = { it feature of(TestData::returnNullable5, "a", 1, true, 1.2, 'b') notToBeNull { it toBe 1 } } //@formatter:on val propertyLazyWithNestedImmediate: F = { - o feature of(TestData::nonNullValue) { - o feature String::length toBe 12 + it feature of(TestData::nonNullValue) { + it feature String::length toBe 12 } } val propertyLazyWithNestedLazy: F = { - o feature of(TestData::nonNullValue) { - o feature of(String::length) { o toBe (12) } + it feature of(TestData::nonNullValue) { + it feature of(String::length) { it toBe (12) } } } - val propertyEmptyAssertionCreator: F = { o feature of(TestData::nonNullValue) {} } - val f0EmptyAssertionCreator: F = { o feature of(TestData::return0) {} } - val f1EmptyAssertionCreator: F = { o feature of(TestData::return1, "a") {} } - val f2EmptyAssertionCreator: F = { o feature of(TestData::return2, "a", 1) {} } - val f3EmptyAssertionCreator: F = { o feature of(TestData::return3, "a", 1, true) {} } - val f4EmptyAssertionCreator: F = { o feature of(TestData::return4, "a", 1, true, 1.2) {} } - val f5EmptyAssertionCreator: F = { o feature of(TestData::return5, "a", 1, true, 1.2, 'b') {} } + val propertyEmptyAssertionCreator: F = { it feature of(TestData::nonNullValue) {} } + val f0EmptyAssertionCreator: F = { it feature of(TestData::return0) {} } + val f1EmptyAssertionCreator: F = { it feature of(TestData::return1, "a") {} } + val f2EmptyAssertionCreator: F = { it feature of(TestData::return2, "a", 1) {} } + val f3EmptyAssertionCreator: F = { it feature of(TestData::return3, "a", 1, true) {} } + val f4EmptyAssertionCreator: F = { it feature of(TestData::return4, "a", 1, true, 1.2) {} } + val f5EmptyAssertionCreator: F = { it feature of(TestData::return5, "a", 1, true, 1.2, 'b') {} } } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt index 9a544d521..e2514dbdb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/FeatureAssertionsManualSpec.kt @@ -53,63 +53,64 @@ class FeatureAssertionsManualSpec : ch.tutteli.atrium.specs.integration.FeatureA //TODO remove type parameters for `of` with Kotiln 1.4 including parentheses (make the calls infix again companion object : WithAsciiReporter() { //@formatter:off - val propertyImmediate: F = { o feature { f("nonNullValue", it.nonNullValue) } contains "hello" } + val propertyImmediate: F = { it feature { f("nonNullValue", it.nonNullValue) } contains "hello" } - val propertyLazy: F = { o feature(of({ f("nonNullValue", it.nonNullValue) }) { o contains "hello" }) } - val f0Immediate: F = { o feature { f("return0()", it.return0()) } contains "hello" } - val f1Immediate: F = { o feature { f("return1(\"a\")", it.return1("a")) } contains "hello" } - val f2Immediate: F = { o feature { f("return2(\"a\", 1)", it.return2("a", 1)) } contains "hello" } - val f3Immediate: F = { o feature { f("return3(\"a\", 1, true)", it.return3("a", 1, true)) } contains "hello" } - val f4Immediate: F = { o feature { f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) } contains "hello" } - val f5Immediate: F = { o feature { f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) } contains "hello" } - val f0Lazy: F = { o feature of({ f("return0()", it.return0()) }) { o contains "hello" } } - val f1Lazy: F = { o feature of({ f("return1(\"a\")", it.return1("a")) }) { o contains "hello" } } - val f2Lazy: F = { o feature of({ f("return2(\"a\", 1)", it.return2("a", 1)) }) { o contains "hello" } } - val f3Lazy: F = { o feature of({ f("return3(\"a\", 1, true)", it.return3("a", 1, true)) }) { o contains "hello" } } - val f4Lazy: F = { o feature of({ f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) }) { o contains "hello" } } - val f5Lazy: F = { o feature of({ f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) }) { o contains "hello" } } + val propertyLazy: F = { it feature(of({ f("nonNullValue", it.nonNullValue) }) { it contains "hello" }) } + val f0Immediate: F = { it feature { f("return0()", it.return0()) } contains "hello" } + val f1Immediate: F = { it feature { f("return1(\"a\")", it.return1("a")) } contains "hello" } + val f2Immediate: F = { it feature { f("return2(\"a\", 1)", it.return2("a", 1)) } contains "hello" } + val f3Immediate: F = { it feature { f("return3(\"a\", 1, true)", it.return3("a", 1, true)) } contains "hello" } + val f4Immediate: F = { it feature { f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) } contains "hello" } + val f5Immediate: F = { it feature { f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) } contains "hello" } + val f0Lazy: F = { it feature of({ f("return0()", it.return0()) }) { it contains "hello" } } + val f1Lazy: F = { it feature of({ f("return1(\"a\")", it.return1("a")) }) { it contains "hello" } } + val f2Lazy: F = { it feature of({ f("return2(\"a\", 1)", it.return2("a", 1)) }) { it contains "hello" } } + val f3Lazy: F = { it feature of({ f("return3(\"a\", 1, true)", it.return3("a", 1, true)) }) { it contains "hello" } } + val f4Lazy: F = { it feature of({ f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) }) { it contains "hello" } } + val f5Lazy: F = { it feature of({ f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) }) { it contains "hello" } } - val propertyNullableDoesNotHold: F = { o feature { f("nullableValue", it.nullableValue) } toBe null } - val f0NullableDoesNotHold: F = { o feature { f("returnNullable0()", it.returnNullable0()) } toBe null } - val f1NullableDoesNotHold: F = { o feature { f("returnNullable1(\"a\")", it.returnNullable1("a")) } toBe null } - val f2NullableDoesNotHold: F = { o feature { f("returnNullable2(\"a\", 1)", it.returnNullable2("a", 1)) } toBe null } - val f3NullableDoesNotHold: F = { o feature { f("returnNullable3(\"a\", 1, true)", it.returnNullable3("a", 1, true)) } toBe null } - val f4NullableDoesNotHold: F = { o feature { f("returnNullable4(\"a\", 1, true, 1.2)", it.returnNullable4("a", 1, true, 1.2)) } toBe null } - val f5NullableDoesNotHold: F = { o feature { f("returnNullable5(\"a\", 1, true, 1.2, 'b')", it.returnNullable5("a", 1, true, 1.2, 'b')) } toBe null } + val propertyNullableDoesNotHold: F = { it feature { f("nullableValue", it.nullableValue) } toBe null } + val f0NullableDoesNotHold: F = { it feature { f("returnNullable0()", it.returnNullable0()) } toBe null } + val f1NullableDoesNotHold: F = { it feature { f("returnNullable1(\"a\")", it.returnNullable1("a")) } toBe null } + val f2NullableDoesNotHold: F = { it feature { f("returnNullable2(\"a\", 1)", it.returnNullable2("a", 1)) } toBe null } + val f3NullableDoesNotHold: F = { it feature { f("returnNullable3(\"a\", 1, true)", it.returnNullable3("a", 1, true)) } toBe null } + val f4NullableDoesNotHold: F = { it feature { f("returnNullable4(\"a\", 1, true, 1.2)", it.returnNullable4("a", 1, true, 1.2)) } toBe null } + val f5NullableDoesNotHold: F = { it feature { f("returnNullable5(\"a\", 1, true, 1.2, 'b')", it.returnNullable5("a", 1, true, 1.2, 'b')) } toBe null } - val propertyNullableHolds: F = { o feature { f("nullableValue", it.nullableValue) } notToBeNull { o toBe 1 } } - val f0NullableHolds: F = { o feature { f("returnNullable0()", it.returnNullable0()) } notToBeNull { o toBe 1 } } - val f1NullableHolds: F = { o feature { f("returnNullable1(\"a\")", it.returnNullable1("a")) } notToBeNull { o toBe 1 } } - val f2NullableHolds: F = { o feature { f("returnNullable2(\"a\", 1)", it.returnNullable2("a", 1)) } notToBeNull { o toBe 1 } } - val f3NullableHolds: F = { o feature { f("returnNullable3(\"a\", 1, true)", it.returnNullable3("a", 1, true)) } notToBeNull { o toBe 1 } } - val f4NullableHolds: F = { o feature { f("returnNullable4(\"a\", 1, true, 1.2)", it.returnNullable4("a", 1, true, 1.2)) } notToBeNull { o toBe 1 } } - val f5NullableHolds: F = { o feature { f("returnNullable5(\"a\", 1, true, 1.2, 'b')", it.returnNullable5("a", 1, true, 1.2, 'b')) } notToBeNull { o toBe 1 } } + val propertyNullableHolds: F = { it feature { f("nullableValue", it.nullableValue) } notToBeNull { it toBe 1 } } + val f0NullableHolds: F = { it feature { f("returnNullable0()", it.returnNullable0()) } notToBeNull { it toBe 1 } } + val f1NullableHolds: F = { it feature { f("returnNullable1(\"a\")", it.returnNullable1("a")) } notToBeNull { it toBe 1 } } + val f2NullableHolds: F = { it feature { f("returnNullable2(\"a\", 1)", it.returnNullable2("a", 1)) } notToBeNull { it toBe 1 } } + val f3NullableHolds: F = { it feature { f("returnNullable3(\"a\", 1, true)", it.returnNullable3("a", 1, true)) } notToBeNull { it toBe 1 } } + val f4NullableHolds: F = { it feature { f("returnNullable4(\"a\", 1, true, 1.2)", it.returnNullable4("a", 1, true, 1.2)) } notToBeNull { it toBe 1 } } + val f5NullableHolds: F = { it feature { f("returnNullable5(\"a\", 1, true, 1.2, 'b')", it.returnNullable5("a", 1, true, 1.2, 'b')) } notToBeNull { it toBe 1 } } //@formatter:on val propertyLazyWithNestedImmediate: F = { - o feature of({ f("nonNullValue", it.nonNullValue) }) { + it feature of({ f("nonNullValue", it.nonNullValue) }) { feature { f("length", it.length) } toBe 12 } } val propertyLazyWithNestedLazy: F = { - o feature of({ f("nonNullValue", it.nonNullValue) }) { - feature { f("length", it.length) } it { o toBe 12 } + it feature of({ f("nonNullValue", it.nonNullValue) }) { + feature { f("length", it.length) } it { it toBe 12 } } } val propertyEmptyAssertionCreator: F = - { o feature of({ f("nonNullValue", it.nonNullValue) }) {} } - val f0EmptyAssertionCreator: F = { o feature of({ f("return0()", it.return0()) }) {} } - val f1EmptyAssertionCreator: F = { o feature of({ f("return1(\"a\")", it.return1("a")) }) {} } + { it feature of({ f("nonNullValue", it.nonNullValue) }) {} } + val f0EmptyAssertionCreator: F = { it feature of({ f("return0()", it.return0()) }) {} } + val f1EmptyAssertionCreator: F = + { it feature of({ f("return1(\"a\")", it.return1("a")) }) {} } val f2EmptyAssertionCreator: F = - { o feature of({ f("return2(\"a\", 1)", it.return2("a", 1)) }) {} } + { it feature of({ f("return2(\"a\", 1)", it.return2("a", 1)) }) {} } val f3EmptyAssertionCreator: F = - { o feature of({ f("return3(\"a\", 1, true)", it.return3("a", 1, true)) }) {} } + { it feature of({ f("return3(\"a\", 1, true)", it.return3("a", 1, true)) }) {} } val f4EmptyAssertionCreator: F = - { o feature of({ f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) }) {} } + { it feature of({ f("return4(\"a\", 1, true, 1.2)", it.return4("a", 1, true, 1.2)) }) {} } val f5EmptyAssertionCreator: F = { - o feature of({ + it feature of({ f("return5(\"a\", 1, true, 1.2, 'b')", it.return5("a", 1, true, 1.2, 'b')) }) {} } From 92f47e592e0cfad6a522747ec80c45037f079059 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Mon, 30 Mar 2020 13:59:56 +0200 Subject: [PATCH 111/142] test isPresent and isPresentFeature in OptionalAssertionsSpec --- .../integration/OptionalAssertionsSpec.kt | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/OptionalAssertionsSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/OptionalAssertionsSpec.kt index 008a784a3..0ad4484ca 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/OptionalAssertionsSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/OptionalAssertionsSpec.kt @@ -9,8 +9,7 @@ import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionOptionalAssertion import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite -import java.lang.AssertionError -import java.util.Optional +import java.util.* abstract class OptionalAssertionsSpec( isEmpty: Fun0>, @@ -30,32 +29,33 @@ abstract class OptionalAssertionsSpec( isPresent.forAssertionCreatorSpec("$toBeDescr: 2") { toBe(2) } ) {}) - fun describeFun(vararg funName: String, body: Suite.() -> Unit) = - describeFunTemplate(describePrefix, funName, body = body) - describeFun(isEmpty.name, isPresent.name) { + fun describeFun(vararg pairs: SpecPair<*>, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body) + + describeFun(isEmpty, isPresentFeature, isPresent) { val isEmptyFun = isEmpty.lambda - val isPresentFun = isPresentFeature.lambda + val isPresentFunctions = unifySignatures(isPresentFeature, isPresent) val emptyValue = Optional.empty() context("$emptyValue") { it("${isEmpty.name} - does not throw") { expect(emptyValue).isEmptyFun() } - it("${isPresent.name} - throws an AssertionError") { - expect { - expect(emptyValue).isPresentFun() - }.toThrow { - messageContains(DescriptionOptionalAssertion.IS_NOT_PRESENT.getDefault()) + isPresentFunctions.forEach { (name, isPresentFun, hasExtraHint) -> + it("$name - throws an AssertionError" + showsSubAssertionIf(hasExtraHint)) { + expect { + expect(emptyValue).isPresentFun { toBe(2) } + }.toThrow { + messageContains(DescriptionOptionalAssertion.IS_NOT_PRESENT.getDefault()) + if (hasExtraHint) messageContains("$toBeDescr: 2") + } } } } val presentValue: Optional = Optional.of(2) context("$presentValue") { - it("${isPresent.name} - can perform sub-assertion which holds") { - expect(presentValue).isPresentFun() - } it("${isEmpty.name} - throws an AssertionError") { expect { expect(presentValue).isEmptyFun() @@ -63,6 +63,12 @@ abstract class OptionalAssertionsSpec( messageContains("$isDescr: ${DescriptionOptionalAssertion.EMPTY.getDefault()}") } } + + isPresentFunctions.forEach { (name, isPresentFun, hasExtraHint) -> + it("$name - can perform sub-assertion which holds") { + expect(presentValue).isPresentFun { toBe(2) } + } + } } } }) From 7d1dd0297ce786bde7fa13934edffc4195f1ca14 Mon Sep 17 00:00:00 2001 From: Ivan <37676744+name213@users.noreply.github.com> Date: Tue, 31 Mar 2020 16:42:12 +0200 Subject: [PATCH 112/142] Migrate resultAssertions to Infix api (#414) --- .../atrium/api/infix/en_GB/keywords.kt | 7 ++ .../creating/result/SuccessWithCreator.kt | 12 ++++ .../en_GB/kotlin_1_3/resultAssertions.kt | 64 +++++++++++++++++++ .../kotlin_1_3/ResultFeatureAssertionsSpec.kt | 62 ++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt create mode 100644 apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt create mode 100644 apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 157da351a..a3ea9697b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -83,3 +83,10 @@ object only : Keyword */ object order : Keyword +/** + * Represents the pseudo keyword `success` as in [toBe] `success. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * + * @since 0.11.0 + */ +object success : Keyword diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt new file mode 100644 index 000000000..95d86a1b2 --- /dev/null +++ b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt @@ -0,0 +1,12 @@ +package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3.creating.result + +import ch.tutteli.atrium.creating.Expect + +/** + * Parameter object that takes [assertionCreator] which defines assertions for a resulting feature of type [E]. + * + * Use the function `success { ... }` to create a [SuccessWithCreator]. + * + * @since 0.11.0 + */ +data class SuccessWithCreator(val assertionCreator: Expect.() -> Unit); diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt new file mode 100644 index 000000000..44d941a7c --- /dev/null +++ b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt @@ -0,0 +1,64 @@ +package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3 + +import ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3.creating.result.SuccessWithCreator +import ch.tutteli.atrium.api.infix.en_GB.success +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.kotlin_1_3.result + +/** + * Expects that the subject of the assertion (a [Result]) is a Success + * and returns an [Expect] for the inner type [E]. + * + * @return The newly created [Expect] if the given assertion is success + * @throws AssertionError Might throw an [AssertionError] if the given assertion is not a success. + * + * @since 0.11.0 + */ +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") success: success): Expect = + ExpectImpl.result.isSuccess(this).getExpectOfFeature() + +/** + * Expects that the subject of the assertion (a [Result]]) is a Success and + * that it holds all assertions the given [SuccessWithCreator.assertionCreator] creates. + * + * Use the function `success { ... }` to create a [SuccessWithCreator]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the given assertions are not success. + * + * @since 0.11.0 + */ +infix fun > Expect.toBe(success: SuccessWithCreator): Expect = + ExpectImpl.result.isSuccess(this).addToInitial(success.assertionCreator) + +/** + * Expects that the subject of the assertion (a [Result]) is a Failure and + * that it encapsulates an exception of type [TExpected]. + * + * @return An [Expect] with the new type [TExpected] + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +inline fun Expect>.isFailure(): Expect = + ExpectImpl.result.isFailure(this, TExpected::class).getExpectOfFeature() + +/** + * Expects that the subject of the assertion (a [Result]) is a Failure, + * it encapsulates an exception of type [TExpected] and that the exception + * holds all assertions the given [assertionCreator] creates. + * + * @return An [Expect] with the new type [TExpected] + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +inline infix fun Expect>.isFailure( + noinline assertionCreator: Expect.() -> Unit +): Expect = ExpectImpl.result.isFailure(this, TExpected::class).addToFeature(assertionCreator) + +/** + * Helper function to create an [SuccessWithCreator] based on the given [assertionCreator]. + */ +fun success(assertionCreator: Expect.() -> Unit) = SuccessWithCreator(assertionCreator) diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt new file mode 100644 index 000000000..abecddb10 --- /dev/null +++ b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt @@ -0,0 +1,62 @@ +package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.integration.ResultFeatureAssertionsSpec +import ch.tutteli.atrium.api.infix.en_GB.success + +class ResultFeatureAssertionsSpec : ResultFeatureAssertionsSpec( + ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessFeature)).withFeatureSuffix(), + "toBe ${success::class::simpleName}" to Companion::toBeSuccess, + ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessFeatureNullable)).withFeatureSuffix().withNullableSuffix(), + ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessNullable)).withNullableSuffix(), + ("isFailure" to Companion::isFailureFeature).withFeatureSuffix(), + "isFailure" to Companion::isFailure +) { + companion object { + private fun toBeSuccessFeature(expect: Expect>) = expect toBe success + private fun isFailureFeature(expect: Expect>) = expect.isFailure() + + private fun toBeSuccessFeatureNullable(expect: Expect>) = expect toBe success + + private fun toBeSuccessNullable( + expect: Expect>, + assertionCreator: Expect.() -> Unit + ) = expect toBe success { assertionCreator() } + + private fun toBeSuccess( + expect: Expect>, + assertionCreator: Expect.() -> Unit + ) = expect toBe success { assertionCreator() } + private fun isFailure( + expect: Expect>, + assertionCreator: Expect.() -> Unit + ) = expect.isFailure { assertionCreator() } + + @Suppress("unused", "UNUSED_VALUE", "UNUSED_VARIABLE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + + var star: Expect> = notImplemented() + + a1 toBe success + a1 = a1 toBe success { } + + a1.isFailure() + val r1: Expect = a1.isFailure { } + + a1b toBe success + a1b = a1b toBe success { } + + a1b.isFailure() + val r1b: Expect = a1b.isFailure { } + + star toBe success + star = star toBe success { } + + star.isFailure() + val r3: Expect = star.isFailure { } + } + } +} From a17ea85703da471958d8542a0e458edbce111c34 Mon Sep 17 00:00:00 2001 From: Assaf L Date: Tue, 31 Mar 2020 21:26:04 +0300 Subject: [PATCH 113/142] #116 migrate spek 1.x to 2.x (#405) - migrate all remaining specs in core-robstoll-lib and domain-robstoll-lib --- .../TranslationSupplierBasedTranslator.kt | 5 +- .../checking/ThrowingAssertionCheckerSpec.kt | 1 - .../AssertionFormatterControllerSpec.kt | 1 - ...tExplanatoryAssertionGroupFormatterSpec.kt | 4 +- .../TextFallbackAssertionFormatterSpec.kt | 8 +-- .../TextFeatureAssertionGroupFormatterSpec.kt | 4 +- .../TextIndentAssertionGroupFormatterSpec.kt | 70 ------------------- .../TextListAssertionGroupFormatterSpec.kt | 4 +- .../reporting/TextMethodCallFormatterSpec.kt | 1 - .../TextNextLineAssertionPairFormatterSpec.kt | 10 ++- .../TextSummaryAssertionGroupFormatterSpec.kt | 4 +- .../translating/LocaleOrderDeciderSpec.kt | 1 - .../ResourceBundleBasedTranslatorSpec.kt | 3 +- .../TranslationSupplierBasedTranslatorSpec.kt | 4 +- .../LazyThreadUnsafeAssertionGroupSpec.kt | 29 ++++---- .../checking/ThrowingAssertionCheckerSpec.kt | 26 ++++--- .../specs/reporting/ObjectFormatterSpec.kt | 0 .../reporting/OnlyFailureReporterSpec.kt | 3 +- .../reporting/TextMethodCallFormatterSpec.kt | 13 ++-- .../atrium/specs/SpecBodyExtensions.kt | 26 ------- .../AssertionFormatterControllerSpec.kt | 13 ++-- .../specs/reporting/AssertionFormatterSpec.kt | 16 ++--- .../reporting/AssertionFormatterSpecBase.kt | 10 ++- ...meAndSubjectAssertionGroupFormatterSpec.kt | 13 ++-- .../SingleAssertionGroupTypeFormatterSpec.kt | 12 ++-- ...tExplanatoryAssertionGroupFormatterSpec.kt | 4 +- ...anatoryBasedAssertionGroupFormatterSpec.kt | 4 +- .../TextFallbackAssertionFormatterSpec.kt | 13 ++-- .../TextFeatureAssertionGroupFormatterSpec.kt | 11 ++- .../TextIndentAssertionGroupFormatterSpec.kt | 4 -- ...tIndentBasedAssertionGroupFormatterSpec.kt | 13 ++-- .../TextListAssertionGroupFormatterSpec.kt | 1 - ...extListBasedAssertionGroupFormatterSpec.kt | 11 ++- .../TextSummaryAssertionGroupFormatterSpec.kt | 14 ++-- .../TextWarningAssertionGroupFormatterSpec.kt | 1 - .../translating/LocaleOrderDeciderSpec.kt | 14 ++-- .../TranslationSupplierBasedTranslatorSpec.kt | 37 +++++----- .../translating/TranslatorErrorCaseSpec.kt | 14 ++-- .../translating/TranslatorIntSpec.kt | 33 ++++----- 39 files changed, 144 insertions(+), 311 deletions(-) delete mode 100644 core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatterSpec.kt rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt (71%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt (100%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt (96%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt (90%) delete mode 100644 misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/SpecBodyExtensions.kt diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslator.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslator.kt index 15396135a..a30049568 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslator.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/main/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslator.kt @@ -30,9 +30,10 @@ class TranslationSupplierBasedTranslator( fallbackLocales: List ) : ArgumentsSupportingTranslator(primaryLocale, fallbackLocales) { - override fun translateWithoutArgs(translatable: Translatable): String = - localeOrderDecider.determineOrder(primaryLocale, fallbackLocales) + override fun translateWithoutArgs(translatable: Translatable): String { + return localeOrderDecider.determineOrder(primaryLocale, fallbackLocales) .map { translationSupplier.get(translatable, it) } .firstOrNull { it != null } ?: translatable.getDefault() + } } diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt index da519a3bc..3da334295 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.core.robstoll.lib.checking -//TODO #116 migrate spek1 to spek2 - move to common module object ThrowingAssertionCheckerSpec : ch.tutteli.atrium.specs.checking.ThrowingAssertionCheckerSpec( ::ThrowingAssertionChecker ) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AssertionFormatterControllerSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AssertionFormatterControllerSpec.kt index ffbea9ee7..bafc55138 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AssertionFormatterControllerSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/AssertionFormatterControllerSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting -//TODO #116 migrate spek1 to spek2 - move to common module object AssertionFormatterControllerSpec : ch.tutteli.atrium.specs.reporting.AssertionFormatterControllerSpec( ::AssertionFormatterControllerImpl ) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt index 291aae731..967169fa8 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt @@ -6,11 +6,9 @@ import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType import ch.tutteli.atrium.reporting.AssertionFormatterController import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to common module class TextExplanatoryAssertionGroupFormatterSpec : Spek({ include(AtriumsTextExplanatoryAssertionFormatterSpec) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFallbackAssertionFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFallbackAssertionFormatterSpec.kt index b10e8b584..ab01b38f5 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFallbackAssertionFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFallbackAssertionFormatterSpec.kt @@ -18,14 +18,10 @@ import ch.tutteli.atrium.specs.reporting.alwaysTrueAssertionFilter import ch.tutteli.atrium.translations.DescriptionBasic.NOT_TO_BE import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE import ch.tutteli.atrium.api.verbs.internal.AssertionVerb.EXPECT -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to common module class TextFallbackAssertionFormatterSpec : Spek({ include(AtriumsTextFallbackAssertionFormatterSpec) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFeatureAssertionGroupFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFeatureAssertionGroupFormatterSpec.kt index 7918b09d0..6e1787850 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFeatureAssertionGroupFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextFeatureAssertionGroupFormatterSpec.kt @@ -6,11 +6,9 @@ import ch.tutteli.atrium.assertions.FeatureAssertionGroupType import ch.tutteli.atrium.reporting.AssertionFormatterController import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to common module class TextFeatureAssertionGroupFormatterSpec : Spek({ include(AtriumsTextFeatureAssertionGroupFormatterSpec) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatterSpec.kt deleted file mode 100644 index 917bff162..000000000 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextIndentAssertionGroupFormatterSpec.kt +++ /dev/null @@ -1,70 +0,0 @@ -@file:Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) - -package ch.tutteli.atrium.core.robstoll.lib.reporting - -import ch.tutteli.atrium.assertions.BulletPointIdentifier -import ch.tutteli.atrium.assertions.DefaultIndentAssertionGroupType -import ch.tutteli.atrium.assertions.IndentAssertionGroupType -import ch.tutteli.atrium.reporting.AssertionFormatterController -import ch.tutteli.atrium.reporting.ObjectFormatter -import ch.tutteli.atrium.reporting.translating.Translator -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include -import kotlin.reflect.KClass - -//TODO remove with 1.0.0 -- no need to migrate to spek2 -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). Will be removed with 1.0.0") -class TextIndentAssertionGroupFormatterSpec : Spek({ - - include(AtriumsTextIndentAssertionGroupFormatterSpec) - include(AtriumsEmptyNameAndSubjectAssertionGroupFormatterSpec) - include(AtriumsSingleAssertionGroupTypeFormatterSpec) - include(AtriumsAssertionFormatterSpec) - -}) { - object AtriumsTextIndentAssertionGroupFormatterSpec : - ch.tutteli.atrium.specs.reporting.TextIndentAssertionGroupFormatterSpec( - ::TextIndentAssertionGroupFormatter, "[Atrium's IndentGroup...Spec] " - ) - - object AtriumsEmptyNameAndSubjectAssertionGroupFormatterSpec : - ch.tutteli.atrium.specs.reporting.EmptyNameAndSubjectAssertionGroupFormatterSpec( - factory(), - IndentAssertionGroupType::class, - DefaultIndentAssertionGroupType, - object : IndentAssertionGroupType {}, - "[Atrium's EmptyNameAndSubject...Spec] " - ) - - object AtriumsSingleAssertionGroupTypeFormatterSpec : - ch.tutteli.atrium.specs.reporting.SingleAssertionGroupTypeFormatterSpec( - factoryWithBulletPoints(), - IndentAssertionGroupType::class, - DefaultIndentAssertionGroupType, - object : IndentAssertionGroupType {}, - "[Atrium's SingleAssertionGroupType...Spec] " - ) - - object AtriumsAssertionFormatterSpec : ch.tutteli.atrium.specs.reporting.AssertionFormatterSpec( - factoryWithBulletPoints(), "[Atrium's AssertionFormatterSpec] " - ) - - companion object { - private fun factory() = { assertionFormatterController: AssertionFormatterController -> - TextIndentAssertionGroupFormatter( - mapOf( - IndentAssertionGroupType::class to "**" - ), assertionFormatterController - ) - } - - private fun factoryWithBulletPoints() = - { _: Map, String>, assertionFormatterController: AssertionFormatterController, _: ObjectFormatter, _: Translator -> - TextIndentAssertionGroupFormatter( - mapOf( - IndentAssertionGroupType::class to "**" - ), assertionFormatterController - ) - } - } -} diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextListAssertionGroupFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextListAssertionGroupFormatterSpec.kt index bee1f4cae..5cca595e2 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextListAssertionGroupFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextListAssertionGroupFormatterSpec.kt @@ -6,11 +6,9 @@ import ch.tutteli.atrium.assertions.ListAssertionGroupType import ch.tutteli.atrium.reporting.AssertionFormatterController import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to common module class TextListAssertionGroupFormatterSpec : Spek({ include(AtriumsTextListAssertionFormatterSpec) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt index 481c3062c..e5588d584 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting -//TODO #116 migrate spek1 to spek2 - move to common module object TextMethodCallFormatterSpec : ch.tutteli.atrium.specs.reporting.TextMethodCallFormatterSpec( { TextMethodCallFormatter } ) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextNextLineAssertionPairFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextNextLineAssertionPairFormatterSpec.kt index 9718e74be..fc48688c0 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextNextLineAssertionPairFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextNextLineAssertionPairFormatterSpec.kt @@ -7,17 +7,15 @@ import ch.tutteli.atrium.domain.builders.AssertImpl import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator -import ch.tutteli.atrium.specs.describeFun +import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.specs.reporting.AssertionFormatterSpecBase import ch.tutteli.atrium.specs.reporting.ToStringObjectFormatter -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to common module class TextNextLineAssertionPairFormatterSpec : AssertionFormatterSpecBase({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = describeFun("", funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = describeFunTemplate("", funName, body = body) val testee = TextNextLineAssertionPairFormatter( ToStringObjectFormatter, diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextSummaryAssertionGroupFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextSummaryAssertionGroupFormatterSpec.kt index 5bd4bbf47..0286f2c48 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextSummaryAssertionGroupFormatterSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextSummaryAssertionGroupFormatterSpec.kt @@ -8,11 +8,9 @@ import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.reporting.ToStringObjectFormatter -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to common module class TextSummaryAssertionGroupFormatterSpec : Spek({ include(AtriumsTextSummaryAssertionGroupFormatterSpec) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt index cc9c5c9b8..b0f6197e7 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting.translating -//TODO #116 migrate spek1 to spek2 - move to common module class LocaleOrderDeciderSpec : ch.tutteli.atrium.specs.reporting.translating.LocaleOrderDeciderSpec( ::CoroutineBasedLocaleOrderDecider ) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/ResourceBundleBasedTranslatorSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/ResourceBundleBasedTranslatorSpec.kt index 7852d2cdc..44f01e773 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/ResourceBundleBasedTranslatorSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/ResourceBundleBasedTranslatorSpec.kt @@ -1,8 +1,7 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting.translating import ch.tutteli.atrium.domain.builders.reporting.ReporterBuilder -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek //cannot be easily migrated to specs-common/spek2 as it depends on JVM resources => need to find a solution first object ResourceBundleBasedTranslatorSpec : Spek({ diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt index 607b2a839..484c08459 100644 --- a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt +++ b/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt @@ -1,10 +1,8 @@ package ch.tutteli.atrium.core.robstoll.lib.reporting.translating import ch.tutteli.atrium.core.coreFactory -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek -//TODO #116 migrate spek1 to spek2 - move to common module object TranslationSupplierBasedTranslatorSpec : Spek({ include(AtriumsTranslationSupplierBasedTranslatorSpec) include(AtriumsTranslatorErrorCaseSpec) diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeAssertionGroupSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeAssertionGroupSpec.kt index f8170c4f6..f38d14642 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeAssertionGroupSpec.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeAssertionGroupSpec.kt @@ -5,10 +5,8 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.domain.builders.AssertImpl import ch.tutteli.atrium.domain.robstoll.lib.assertions.LazyThreadUnsafeAssertionGroup -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.dsl.on +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe object LazyThreadUnsafeAssertionGroupSpec : Spek({ @@ -26,15 +24,19 @@ object LazyThreadUnsafeAssertionGroupSpec : Spek({ .withAssertion(assertion) .build() } - test("does not evaluate anything") { + it("does not evaluate anything") { expect(callingCount).toBe(0) } - test("adding it to a list does not evaluate anything") { + it("adding it to a list does not evaluate anything") { listOf(testee) expect(callingCount).toBe(0) } - on("invoking ${testee::holds.name}") { - val resultHolds = testee.holds() + context("invoking ${testee::holds.name}") { + var resultHolds = true + + it("execute it") { + resultHolds = testee.holds() + } it("evaluates it") { expect(callingCount).toBe(1) @@ -45,9 +47,12 @@ object LazyThreadUnsafeAssertionGroupSpec : Spek({ } } - on("invoking ${testee::holds.name} and then ${testee::assertions.name}") { - val resultHolds = testee.holds() - val resultAssertions = testee.assertions + context("invoking ${testee::holds.name} and then ${testee::assertions.name}") { + var resultHolds = true + + it("execute it") { + resultHolds = testee.holds() + } it("evaluates it only once") { expect(callingCount).toBe(1) @@ -58,7 +63,7 @@ object LazyThreadUnsafeAssertionGroupSpec : Spek({ } it("returns the ${AssertionGroup::assertions.name} of the underlying ${AssertionGroup::class.simpleName}") { - expect(resultAssertions).containsExactly(assertion) + expect(testee.assertions).containsExactly(assertion) } } } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt similarity index 71% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt index 8e038733e..aee74db1c 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/checking/ThrowingAssertionCheckerSpec.kt @@ -9,30 +9,28 @@ import ch.tutteli.atrium.checking.AssertionChecker import ch.tutteli.atrium.core.coreFactory import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun -import com.nhaarman.mockitokotlin2.any -import com.nhaarman.mockitokotlin2.mock -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import io.mockk.* +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class ThrowingAssertionCheckerSpec( testeeFactory: (Reporter) -> AssertionChecker, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val assertionVerb = AssertionVerb.VERB val reporterResponse = "hello" - //TODO #116 use mockk instead of mockito-kotlin - val reporter = mock { - on { format(any(), @Suppress("RemoveExplicitTypeArguments") any()) }.thenAnswer { - (it.arguments[1] as StringBuilder).append(reporterResponse) + val strbldSlot = slot() + + val reporter = mockk { + every { format(any(), @Suppress("RemoveExplicitTypeArguments") capture(strbldSlot)) } answers { + (strbldSlot.captured).append(reporterResponse) } - on { atriumErrorAdjuster }.thenReturn(coreFactory.newNoOpAtriumErrorAdjuster()) + every { atriumErrorAdjuster } returns (coreFactory.newNoOpAtriumErrorAdjuster()) } val testee = testeeFactory(reporter) val assertionWhichHolds = object : Assertion { diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt similarity index 100% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/ObjectFormatterSpec.kt diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt similarity index 96% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt index f8b4024dc..166fc2814 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/OnlyFailureReporterSpec.kt @@ -14,7 +14,6 @@ import ch.tutteli.atrium.reporting.AtriumErrorAdjuster import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE import io.mockk.* @@ -84,7 +83,7 @@ abstract class OnlyFailureReporterSpec( assertionFormatterFacade, coreFactory.newNoOpAtriumErrorAdjuster() ) - it("delegates to ${assertionFormatterFacade::class.java.simpleName}") { + it("delegates to ${assertionFormatterFacade::class.simpleName}") { testeeWithMockedFacade.format(basicAssertion, sb) verify { assertionFormatterFacade.format(eq(basicAssertion), eq(sb), any()) } } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt similarity index 90% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt index 234de912b..d4c761017 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextMethodCallFormatterSpec.kt @@ -3,21 +3,18 @@ package ch.tutteli.atrium.specs.reporting import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.reporting.MethodCallFormatter -import ch.tutteli.atrium.specs.describeFun -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common @Suppress("UNUSED_PARAMETER") abstract class TextMethodCallFormatterSpec( testeeFactory: () -> MethodCallFormatter, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val testee = testeeFactory() diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/SpecBodyExtensions.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/SpecBodyExtensions.kt deleted file mode 100644 index 0843ba3e5..000000000 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/SpecBodyExtensions.kt +++ /dev/null @@ -1,26 +0,0 @@ -//TODO remove file as soon as all specs have been transformed to spek2 -package ch.tutteli.atrium.specs - -import ch.tutteli.kbox.joinToString -import org.jetbrains.spek.api.dsl.SpecBody - -//TODO #116 remove once there aren't any spek1 specs anymore -fun SpecBody.describeFun( - describePrefix: String, - funNames: Array, - funNamePrefix: String = "`", - funNameSuffix: String = "`", - body: SpecBody.() -> Unit -) = prefixedDescribe(describePrefix, " fun ", giveWrappedNames(funNames, funNamePrefix, funNameSuffix), body) - -private fun giveWrappedNames(names: Array, prefix: String, postfix: String): String { - return names.joinToString(", ", " and ") { it, sb -> - sb.append(prefix).append(it).append(postfix) - } -} - -fun SpecBody.prefixedDescribe(prefix: String, description: String, body: SpecBody.() -> Unit) = - prefixedDescribe(prefix, "", description, body) - -fun SpecBody.prefixedDescribe(prefix: String, suffix: String, description: String, body: SpecBody.() -> Unit) = - group("${prefix}describe$suffix $description", body = body) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt index a097925eb..7865b9531 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterControllerSpec.kt @@ -14,21 +14,18 @@ import ch.tutteli.atrium.reporting.RawString import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun +import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.translations.DescriptionComparableAssertion.* -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class AssertionFormatterControllerSpec( testeeFactory: () -> AssertionFormatterController, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val testee = testeeFactory() val arrow = " >>" diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpec.kt index e991b9c1c..54002d400 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpec.kt @@ -16,23 +16,21 @@ import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator -import ch.tutteli.atrium.specs.describeFun -import com.nhaarman.mockitokotlin2.mock -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import io.mockk.*; +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class AssertionFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController, ObjectFormatter, Translator) -> AssertionFormatter, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) - val controller = mock() + val controller = mockk() val testee = testeeFactory( mapOf(), controller, ToStringObjectFormatter, UsingDefaultTranslator() diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpecBase.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpecBase.kt index cf657a707..a50575f98 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpecBase.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/AssertionFormatterSpecBase.kt @@ -5,14 +5,12 @@ import ch.tutteli.atrium.core.coreFactory import ch.tutteli.atrium.reporting.* import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.Spec -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek +import org.spekframework.spek2.dsl.Root import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common -abstract class AssertionFormatterSpecBase(spec: Spec.() -> Unit) : Spek({ - include(wrap(spec)) +abstract class AssertionFormatterSpecBase(spec: Root.() -> Unit) : Spek({ + include(object: Spek(spec) {}) afterEachTest { sb = StringBuilder() diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt index c75641ec1..179850f65 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt @@ -11,14 +11,11 @@ import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController import ch.tutteli.atrium.reporting.AssertionFormatterParameterObject import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable -import ch.tutteli.atrium.specs.describeFun -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class EmptyNameAndSubjectAssertionGroupFormatterSpec( testeeFactory: (AssertionFormatterController) -> AssertionFormatter, assertionGroupClass: KClass, @@ -27,8 +24,8 @@ abstract class EmptyNameAndSubjectAssertionGroupFormatterSpec Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val testee = testeeFactory(coreFactory.newAssertionFormatterController()) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/SingleAssertionGroupTypeFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/SingleAssertionGroupTypeFormatterSpec.kt index 9ecfa7f3f..620373d84 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/SingleAssertionGroupTypeFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/SingleAssertionGroupTypeFormatterSpec.kt @@ -18,13 +18,11 @@ import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator -import ch.tutteli.atrium.specs.describeFun -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class SingleAssertionGroupTypeFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController, ObjectFormatter, Translator) -> AssertionFormatter, supportedAssertionGroupTypeClass: KClass, @@ -33,8 +31,8 @@ abstract class SingleAssertionGroupTypeFormatterSpec describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val testee = testeeFactory( mapOf(), coreFactory.newAssertionFormatterController(), diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt index 4fdce7ca5..98a4cb814 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryAssertionGroupFormatterSpec.kt @@ -7,7 +7,6 @@ import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextExplanatoryAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, describePrefix: String = "[Atrium] " @@ -16,5 +15,4 @@ abstract class TextExplanatoryAssertionGroupFormatterSpec( ExplanatoryAssertionGroupType::class, object : ExplanatoryAssertionGroupType {}, { ExpectImpl.builder.explanatoryGroup.withDefaultType.withAssertions(it).build() }, - describePrefix -) + describePrefix) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryBasedAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryBasedAssertionGroupFormatterSpec.kt index af50de140..ed0fb433e 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryBasedAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextExplanatoryBasedAssertionGroupFormatterSpec.kt @@ -6,11 +6,9 @@ import ch.tutteli.atrium.assertions.BulletPointIdentifier import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.include +import org.spekframework.spek2.Spek import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextExplanatoryBasedAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, assertionGroupTypeClass: KClass, diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt index 431be308b..7ffeefb0e 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt @@ -12,22 +12,19 @@ import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator -import ch.tutteli.atrium.specs.describeFun +import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.translations.DescriptionAnyAssertion.IS_SAME import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextFallbackAssertionFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController, ObjectFormatter, Translator) -> AssertionFormatter, describePrefix: String = "[Atrium] " ) : AssertionFormatterSpecBase({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val testee = testeeFactory( bulletPoints, coreFactory.newAssertionFormatterController(), @@ -39,7 +36,7 @@ abstract class TextFallbackAssertionFormatterSpec( } describeFun(testee::canFormat.name) { - group("check that it always returns true even for...") { + context("check that it always returns true even for...") { it("... an anonymous class of ${Assertion::class.simpleName}") { testee.canFormat(unsupportedAssertion) } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFeatureAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFeatureAssertionGroupFormatterSpec.kt index 9df729d82..77f9e0e5c 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFeatureAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFeatureAssertionGroupFormatterSpec.kt @@ -15,21 +15,18 @@ import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun +import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.specs.reporting.translating.TranslatorIntSpec -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextFeatureAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController, ObjectFormatter, Translator) -> AssertionFormatter, describePrefix: String = "[Atrium] " ) : AssertionFormatterSpecBase({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val assertions = listOf( ExpectImpl.builder.descriptive.holding.withDescriptionAndRepresentation(AssertionVerb.ASSERT, 1).build(), diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt index b4f867bbe..662ada2e1 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentAssertionGroupFormatterSpec.kt @@ -1,5 +1,3 @@ -@file:Suppress("DEPRECATION" /* TODO remove with 1.0.0 */) - package ch.tutteli.atrium.specs.reporting import ch.tutteli.atrium.assertions.BulletPointIdentifier @@ -10,8 +8,6 @@ import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController import kotlin.reflect.KClass -//TODO remove with 1.0.0 - no need to migrate to spek2 -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). Will be removed with 1.0.0") abstract class TextIndentAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, describePrefix: String = "[Atrium] " diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt index d7f847f85..81e39a9e5 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextIndentBasedAssertionGroupFormatterSpec.kt @@ -9,14 +9,11 @@ import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO remove with 1.0.0 - no need to migrate to spek2 -@Deprecated("So far indentation was achieved by grouping (which is the solution to go). Will be removed with 1.0.0") abstract class TextIndentBasedAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, assertionGroupTypeClass: KClass, @@ -25,8 +22,8 @@ abstract class TextIndentBasedAssertionGroupFormatterSpec Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val indentBulletPoint = " +" val indentIndentBulletPoint = " ".repeat(indentBulletPoint.length + 1) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListAssertionGroupFormatterSpec.kt index 0fbd564e6..48ba39e16 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListAssertionGroupFormatterSpec.kt @@ -9,7 +9,6 @@ import ch.tutteli.atrium.reporting.ObjectFormatter import ch.tutteli.atrium.reporting.translating.Translator import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextListAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController, ObjectFormatter, Translator) -> AssertionFormatter, describePrefix: String = "[Atrium] " diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListBasedAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListBasedAssertionGroupFormatterSpec.kt index 851933268..58158457e 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListBasedAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextListBasedAssertionGroupFormatterSpec.kt @@ -12,14 +12,11 @@ import ch.tutteli.atrium.reporting.translating.Translator import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.reporting.translating.UsingDefaultTranslator import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun +import ch.tutteli.atrium.specs.describeFunTemplate import ch.tutteli.atrium.specs.reporting.translating.TranslatorIntSpec -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextListBasedAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController, ObjectFormatter, Translator) -> AssertionFormatter, assertionGroupClass: Class, @@ -28,8 +25,8 @@ abstract class TextListBasedAssertionGroupFormatterSpec( describePrefix: String = "[Atrium] " ) : AssertionFormatterSpecBase({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val assertions = listOf( ExpectImpl.builder.descriptive.holding.withDescriptionAndRepresentation(AssertionVerb.ASSERT, 1).build(), diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextSummaryAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextSummaryAssertionGroupFormatterSpec.kt index 1294a0208..40eb27774 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextSummaryAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextSummaryAssertionGroupFormatterSpec.kt @@ -10,20 +10,18 @@ import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController import ch.tutteli.atrium.reporting.translating.Untranslatable import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.describeFun -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextSummaryAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, describePrefix: String = "[Atrium] " ) : AssertionFormatterSpecBase({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) val successBulletPoint = "(/)" val indentSuccessBulletPoint = " ".repeat(successBulletPoint.length + 1) @@ -220,7 +218,7 @@ abstract class TextSummaryAssertionGroupFormatterSpec( } } context("${AssertionGroup::class.simpleName} of ${DefaultSummaryAssertionGroupType::class.simpleName} and group holds") { - test("The group is not formatted since it is filtered out") { + it("The group is not formatted since it is filtered out") { val assertions = listOf( ExpectImpl.builder.descriptive.holding.withDescriptionAndRepresentation( AssertionVerb.ASSERT, diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextWarningAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextWarningAssertionGroupFormatterSpec.kt index a63d8fd56..d8bb41d45 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextWarningAssertionGroupFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextWarningAssertionGroupFormatterSpec.kt @@ -7,7 +7,6 @@ import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController import kotlin.reflect.KClass -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TextWarningAssertionGroupFormatterSpec( testeeFactory: (Map, String>, AssertionFormatterController) -> AssertionFormatter, describePrefix: String = "[Atrium] " diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt index ea7f2ef47..c7c1cfb0a 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt @@ -4,22 +4,18 @@ import ch.tutteli.atrium.api.fluent.en_GB.containsExactly import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.reporting.translating.Locale import ch.tutteli.atrium.reporting.translating.LocaleOrderDecider -import ch.tutteli.atrium.specs.prefixedDescribe +import ch.tutteli.atrium.specs.prefixedDescribeTemplate import ch.tutteli.kbox.joinToString -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class LocaleOrderDeciderSpec( testeeFactory: () -> LocaleOrderDecider, describePrefix: String = "[Atrium] " ) : Spek({ - fun prefixedDescribe(description: String, body: SpecBody.() -> Unit) = - prefixedDescribe(describePrefix, description, body) + fun prefixedDescribe(description: String, body: Suite.() -> Unit) = + prefixedDescribeTemplate(describePrefix, description, body) val testee = testeeFactory() diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt index 191e58a5e..4bf15b0f6 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt @@ -4,30 +4,27 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.core.coreFactory import ch.tutteli.atrium.reporting.translating.* -import ch.tutteli.atrium.specs.describeFun -import com.nhaarman.mockitokotlin2.doReturn -import com.nhaarman.mockitokotlin2.mock -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import io.mockk.* +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite +import org.spekframework.spek2.style.specification.describe -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TranslationSupplierBasedTranslatorSpec( testeeFactory: (translationSupplier: TranslationSupplier, localeOrderDecider: LocaleOrderDecider, locale: Locale, fallbackLocals: List) -> Translator, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) fun testeeFactory(translationSupplier: TranslationSupplier, locale: Locale, vararg fallbackLocals: Locale) = testeeFactory(translationSupplier, coreFactory.newLocaleOrderDecider(), locale, fallbackLocals.toList()) - fun mockTranslationProvider(locale: Locale, translatable: Translatable, translation: String): TranslationSupplier { - return mock { - on { get(translatable, locale) }.doReturn(translation) + fun mockTranslationProvider(locale: Locale, translatable: Translatable, translation: String?): TranslationSupplier { + return mockk { + every { get(any(), any()) } returns null + every { get(translatable, locale) } returns translation } } @@ -46,7 +43,7 @@ abstract class TranslationSupplierBasedTranslatorSpec( } @Suppress("unused") - fun SpecBody.checkUsesDefaultOfTranslatable(testee: Translator) { + fun Suite.checkUsesDefaultOfTranslatable(testee: Translator) { it("uses ${Translatable::class.simpleName}'s ${Translatable::getDefault.name}") { val result = testee.translate(translatableHello) expect(result).toBe(translatableHello.value) @@ -54,19 +51,19 @@ abstract class TranslationSupplierBasedTranslatorSpec( } @Suppress("unused") - fun SpecBody.checkTranslationSuccessfulForDesiredTranslatable( + fun Suite.checkTranslationSuccessfulForDesiredTranslatable( testee: Translator, translation: String, locale: Locale ) { - context("but for the wrong ${Translatable::class.simpleName}") { + describe("but for the wrong ${Translatable::class.simpleName}") { it("uses ${Translatable::class.simpleName}'s ${Translatable::getDefault.name}") { val result = testee.translate(translatableTest) expect(result).toBe(translatableTest.value) } } - context("for the desired ${Translatable::class.simpleName}") { + describe("for the desired ${Translatable::class.simpleName}") { it("uses the translation of Locale $locale") { val result = testee.translate(translatableHello) expect(result).toBe(translation) @@ -91,7 +88,9 @@ abstract class TranslationSupplierBasedTranslatorSpec( describe("translating a ${Translatable::class.simpleName} to $greatBritain without fallbacks") { context("no translations provided at all") { - val testee = testeeFactory(mock(), greatBritain) + val testee = testeeFactory(mockk { + every { get(any(), any()) } returns null + }, greatBritain) checkUsesDefaultOfTranslatable(testee) } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt index 140c243e2..cd7f3c33f 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt @@ -5,21 +5,17 @@ import ch.tutteli.atrium.api.fluent.en_GB.toThrow import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.reporting.translating.Locale import ch.tutteli.atrium.reporting.translating.Translator -import ch.tutteli.atrium.specs.describeFun -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it +import ch.tutteli.atrium.specs.describeFunTemplate +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.Suite -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TranslatorErrorCaseSpec( testeeFactory: (locale: Locale, fallbackLocals: List) -> Translator, describePrefix: String = "[Atrium] " ) : Spek({ - fun describeFun(vararg funName: String, body: SpecBody.() -> Unit) = - describeFun(describePrefix, funName, body = body) + fun describeFun(vararg funName: String, body: Suite.() -> Unit) = + describeFunTemplate(describePrefix, funName, body = body) fun testeeFactory(locale: Locale, vararg fallbackLocals: Locale) = testeeFactory(locale, fallbackLocals.toList()) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt index 118f2b416..9092e15db 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorIntSpec.kt @@ -8,16 +8,13 @@ import ch.tutteli.atrium.reporting.Reporter import ch.tutteli.atrium.reporting.translating.Locale import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable import ch.tutteli.atrium.reporting.translating.TranslatableWithArgs -import ch.tutteli.atrium.specs.AssertionVerb -import ch.tutteli.atrium.specs.prefixedDescribe +import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.translations.DescriptionAnyAssertion import ch.tutteli.atrium.translations.DescriptionBasic import ch.tutteli.atrium.translations.DescriptionComparableAssertion -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.SpecBody -import org.jetbrains.spek.api.dsl.context -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe +import org.spekframework.spek2.style.specification.Suite import java.text.SimpleDateFormat /** @@ -97,7 +94,6 @@ import java.text.SimpleDateFormat * ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_NOT_SAME=IS_NOT_SAME zh * ch.tutteli.atrium.translations.DescriptionAnyAssertion-IS_SAME=IS_SAME zh */ -//TODO #116 migrate spek1 to spek2 - move to specs-common abstract class TranslatorIntSpec( reporterFactory: (Locale, Array) -> Reporter, //TODO Remove as soon as https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8193496 is fixed in JDK8 @@ -105,9 +101,8 @@ abstract class TranslatorIntSpec( describePrefix: String = "[Atrium] " ) : Spek({ - fun prefixedDescribe(description: String, body: SpecBody.() -> Unit) { - prefixedDescribe(describePrefix, description, body) - } + fun prefixedDescribe(description: String, body: Suite.() -> Unit) = + prefixedDescribeTemplate(describePrefix, description, body) val reporterDeChFallbackFr = reporterFactory(Locale("de", "CH"), arrayOf(Locale("fr"))) fun assertWithDeCh_Fr(subject: T) = @@ -138,7 +133,7 @@ abstract class TranslatorIntSpec( context("properties file for $descriptionAnyAssertion is provided for 'de_CH'") { describe("translation for $descriptionAnyAssertion.$toBe is provided for 'de_CH'") { - test("a failing assertion contains 'ist' instead of 'to be' in the error message") { + it("a failing assertion contains 'ist' instead of 'to be' in the error message") { expect { assertWithDeCh_Fr(1).toBe(2) }.toThrow { messageContains("ist: 2") } @@ -147,7 +142,7 @@ abstract class TranslatorIntSpec( describe("translation for $descriptionAnyAssertion.$notToBe is provided for 'de'") { val text = "ist nicht" - test("a failing assertion contains '$text' instead of 'not to be' in the error message") { + it("a failing assertion contains '$text' instead of 'not to be' in the error message") { expect { assertWithDeCh_Fr(1).notToBe(1) }.toThrow { messageContains("$text: 1") } @@ -156,7 +151,7 @@ abstract class TranslatorIntSpec( describe("translation for $descriptionAnyAssertion.$isNotSame is provided 'fr'") { val text = "n'est pas la même instance que" - test("a failing assertion contains '$text' instead of 'assert' in the error message") { + it("a failing assertion contains '$text' instead of 'assert' in the error message") { expect { assertWithDeCh_Fr(1).isNotSameAs(1) }.toThrow { messageContains("$text: 1") } @@ -167,7 +162,7 @@ abstract class TranslatorIntSpec( context("properties file for ${AssertionVerb::class.simpleName} is not provided for 'de_CH' nor one of its parents") { describe("translation for ${AssertionVerb::class.simpleName}.${AssertionVerb.ASSERT} is provided for 'fr'") { val text = "il applique que" - test("a failing assertion contains '$text' instead of 'assert' in the error message") { + it("a failing assertion contains '$text' instead of 'assert' in the error message") { expect { assertWithDeCh_Fr(1).toBe(2) }.toThrow { messageContains("$text: 1") } @@ -284,14 +279,14 @@ abstract class TranslatorIntSpec( prefixedDescribe("primary locale is 'zh_$country' and no fallback defined") { if (withSpecialCases) { describe("translation for $descriptionAnyAssertion.$toBe is provided for 'zh_$country' and for ${zhWithScript}_$country") { - test("a failing assertion contains '$toBe ${zhWithScript}_$country' instead of 'to be' in the error message") { + it("a failing assertion contains '$toBe ${zhWithScript}_$country' instead of 'to be' in the error message") { expect { assert.toBe(2) }.toThrow { messageContains("$toBe ${zhWithScript}_$country: 2") } } } describe("translation for $descriptionAnyAssertion.$notToBe is provided for 'zh_$country' and for $zhWithScript") { - test("a failing assertion contains '$notToBe $zhWithScript' instead of 'to be' in the error message") { + it("a failing assertion contains '$notToBe $zhWithScript' instead of 'to be' in the error message") { expect { assert.notToBe(1) }.toThrow { messageContains("$notToBe $zhWithScript: 1") } @@ -299,14 +294,14 @@ abstract class TranslatorIntSpec( } } describe("translation for $descriptionAnyAssertion.$isNotSame is provided for 'zh_$country' and zh") { - test("a failing assertion contains '$isNotSame zh_$country' instead of 'to be' in the error message") { + it("a failing assertion contains '$isNotSame zh_$country' instead of 'to be' in the error message") { expect { assert.isNotSameAs(1) }.toThrow { messageContains("$isNotSame zh_$country: 1") } } } describe("translation for $descriptionAnyAssertion.$isSame is not provided for 'zh_$country' but for zh") { - test("a failing assertion contains '$isSame zh' instead of 'to be' in the error message") { + it("a failing assertion contains '$isSame zh' instead of 'to be' in the error message") { expect { assert.isSameAs(2) }.toThrow { messageContains("$isSame zh: 2") } From 4d38b8ef1df5124f12804c20a5a371d2df22c554 Mon Sep 17 00:00:00 2001 From: assaflei Date: Tue, 31 Mar 2020 23:33:45 +0300 Subject: [PATCH 114/142] migrated 3 last classes to spek2 --- .../LazyThreadUnsafeBasicAssertionSpec.kt | 28 +++++++++++-------- .../CharSequenceContainsIndexSearcherSpec.kt | 8 +++--- .../CharSequenceContainsRegexSearcherSpec.kt | 10 +++---- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeBasicAssertionSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeBasicAssertionSpec.kt index 859b9f220..3bfe78a14 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeBasicAssertionSpec.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeBasicAssertionSpec.kt @@ -4,10 +4,8 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.domain.builders.AssertImpl import ch.tutteli.atrium.domain.robstoll.lib.assertions.LazyThreadUnsafeBasicAssertion -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.describe -import org.jetbrains.spek.api.dsl.it -import org.jetbrains.spek.api.dsl.on +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe object LazyThreadUnsafeBasicAssertionSpec : Spek({ @@ -17,15 +15,18 @@ object LazyThreadUnsafeBasicAssertionSpec : Spek({ ++callingCount AssertImpl.builder.descriptive.failing.withDescriptionAndRepresentation("a", 2).build() } - test("does not evaluate anything") { + it("does not evaluate anything") { expect(callingCount).toBe(0) } - test("adding it to a list does not evaluate anything") { + it("adding it to a list does not evaluate anything") { listOf(testee) expect(callingCount).toBe(0) } - on("invoking ${testee::holds.name}") { - val resultHolds = testee.holds() + context("invoking ${testee::holds.name}") { + var resultHolds = true + it("execute it") { + resultHolds = testee.holds() + } it("evaluates it") { expect(callingCount).toBe(1) @@ -36,9 +37,12 @@ object LazyThreadUnsafeBasicAssertionSpec : Spek({ } } - on("invoking ${testee::holds.name} and then ${testee::representation.name}") { - val resultHolds = testee.holds() - val resultExpected = testee.representation + context("invoking ${testee::holds.name} and then ${testee::representation.name}") { + var resultHolds = true + + it("execute it") { + resultHolds = testee.holds() + } it("evaluates it only once") { expect(callingCount).toBe(1) @@ -49,7 +53,7 @@ object LazyThreadUnsafeBasicAssertionSpec : Spek({ } it("returns ${DescriptiveAssertion::representation.name} of the underlying ${DescriptiveAssertion::class.simpleName}") { - expect(resultExpected).toBe(2) + expect(testee.representation).toBe(2) } } } diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt index 2f659f031..f1e77adb0 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt @@ -4,13 +4,13 @@ import ch.tutteli.atrium.api.fluent.en_GB.contains import ch.tutteli.atrium.api.fluent.en_GB.exactly import ch.tutteli.atrium.api.fluent.en_GB.value import ch.tutteli.atrium.api.verbs.internal.expect -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.context +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe object CharSequenceContainsIndexSearcherSpec : Spek({ - context("text 'aaaa'") { - test("search for 'aa' finds 3 hits since we want non disjoint matches") { + describe("text 'aaaa'") { + it("search for 'aa' finds 3 hits since we want non disjoint matches") { expect("aaaa").contains.exactly(3).value("aa") } } diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt index f4931d388..45b1d2e5c 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt @@ -4,16 +4,16 @@ import ch.tutteli.atrium.api.fluent.en_GB.contains import ch.tutteli.atrium.api.fluent.en_GB.exactly import ch.tutteli.atrium.api.fluent.en_GB.regex import ch.tutteli.atrium.api.verbs.internal.expect -import org.jetbrains.spek.api.Spek -import org.jetbrains.spek.api.dsl.context +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe object CharSequenceContainsRegexSearcherSpec : Spek({ - context("text 'aaaa'") { - test("search for 'aa' finds 3 hits since we want non disjoint matches") { + describe("text 'aaaa'") { + it("search for 'aa' finds 3 hits since we want non disjoint matches") { expect("aaaa").contains.exactly(3).regex("aa") } - test("search for 'aa?' finds 4 hits since we want non disjoint matches") { + it("search for 'aa?' finds 4 hits since we want non disjoint matches") { expect("aaaa").contains.exactly(4).regex("aa?") } } From 27082c246a9adbff0b59ee75e0c26acff997d158 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Tue, 31 Mar 2020 23:27:52 +0200 Subject: [PATCH 115/142] use class.fullName instead of class.java.name This way it is not platform specific and can be moved to common --- .../specs/reporting/TextFallbackAssertionFormatterSpec.kt | 5 +++-- .../translating/TranslationSupplierBasedTranslatorSpec.kt | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt index 7ffeefb0e..2e0419ed3 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/TextFallbackAssertionFormatterSpec.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.toBe import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.assertions.* import ch.tutteli.atrium.core.coreFactory +import ch.tutteli.atrium.core.polyfills.fullName import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.reporting.AssertionFormatter import ch.tutteli.atrium.reporting.AssertionFormatterController @@ -59,7 +60,7 @@ abstract class TextFallbackAssertionFormatterSpec( testee.formatNonGroup(unsupportedAssertion, parameterObject) expect(sb) { contains("false") - contains("Unsupported type ${unsupportedAssertion::class.java.name}") + contains("Unsupported type ${unsupportedAssertion::class.fullName}") } } } @@ -150,7 +151,7 @@ abstract class TextFallbackAssertionFormatterSpec( "$bulletPoint inner group: subject of inner group$separator" + "$indentBulletPoint$bulletPoint ${IS_SAME.getDefault()}: b$separator" + "$indentBulletPoint$bulletPoint ${TO_BE.getDefault()}: d", - "$bulletPoint Unsupported type ${unsupportedAssertion::class.java.name}" + "$bulletPoint Unsupported type ${unsupportedAssertion::class.fullName}" ) } } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt index 4bf15b0f6..e56a86cfd 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt @@ -8,7 +8,6 @@ import ch.tutteli.atrium.specs.describeFunTemplate import io.mockk.* import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.Suite -import org.spekframework.spek2.style.specification.describe abstract class TranslationSupplierBasedTranslatorSpec( testeeFactory: (translationSupplier: TranslationSupplier, localeOrderDecider: LocaleOrderDecider, locale: Locale, fallbackLocals: List) -> Translator, From a4bfc9589a7d42245f983dc631ecdae72cbce6b7 Mon Sep 17 00:00:00 2001 From: Ivan Fedorov <37301285+isfedorov@users.noreply.github.com> Date: Wed, 1 Apr 2020 17:34:06 +0300 Subject: [PATCH 116/142] add optionalAssertions for the new infix API (#412) --- .../en_GB/jdk8/OptionalAssertionsSpec.kt | 8 +++ .../atrium/api/infix/en_GB/keywords.kt | 6 ++ .../creating/optional/PresentWithCreator.kt | 15 +++++ .../infix/en_GB/jdk8/optionalAssertions.kt | 57 +++++++++++++++++++ .../en_GB/jdk8/OptionalAssertionsSpec.kt | 45 +++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/OptionalAssertionsSpec.kt b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/OptionalAssertionsSpec.kt index 9fd4fa990..88777edb8 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/OptionalAssertionsSpec.kt +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/jdk8/OptionalAssertionsSpec.kt @@ -20,5 +20,13 @@ class OptionalAssertionsSpec : OptionalAssertionsSpec( o1 = o1.isEmpty() o1b = o1b.isEmpty() star = star.isEmpty() + o1.isPresent() + o1b.isPresent() + // following is not supported on purpose as we don't know what type the element is in this case + // star.isPresent() + o1.isPresent {} + o1b.isPresent {} + // following is not supported on purpose as we don't know what type the element is in this case + // star.isPresent {} } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index a3ea9697b..d79f93c29 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -22,6 +22,12 @@ internal const val ERR_KEYWORD_GIVEN_COLLECTION_ASSUMED = */ object Empty : Keyword +/** + * Represents a helper construct which allows to express presence. + * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + */ +object Present : Keyword + /** * Represents a helper construct which allows to express blankness. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt new file mode 100644 index 000000000..a496f75cb --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt @@ -0,0 +1,15 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) +package ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.optional + +import ch.tutteli.atrium.creating.Expect +import java.util.Optional + +/** + * Parameter object which represents a present [Optional] with an element type [E] combined + * with an [assertionCreator] which defines assertions for the element. + * + * Use the function `present { ... }` to create this representation. + * + * @since 0.11.0 + */ +data class PresentWithCreator(val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt new file mode 100644 index 000000000..48ccce2ac --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt @@ -0,0 +1,57 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.api.infix.en_GB.Empty +import ch.tutteli.atrium.api.infix.en_GB.Present +import ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.optional.PresentWithCreator +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.optional +import java.util.* + +/** + * Expects that the subject of the assertion (an [Optional]) is empty (not present). + * + * Shortcut for more or less something like `feature(Optional::isEmpty) { toBe(true) }` + * depends on the underlying implementation though. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: Empty) = + addAssertion(ExpectImpl.optional.isEmpty(this)) + +/** + * Expects that the subject of the assertion (an [Optional]) is present + * and returns an [Expect] for the inner type [E]. + * + * Shortcut for more or less something like `feature(Optional::get)` but with error handling; yet it + * depends on the underlying implementation though. + * + * @return The newly created [Expect] for the inner type [E]. + * @throws AssertionError Might throw an [AssertionError] if the given assertion is not a success. + * + * @since 0.11.0 + */ +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") present: Present) = + ExpectImpl.optional.isPresent(this).getExpectOfFeature() + +/** + * Expects that the subject of the assertion (an [Optional]) is present and + * that it holds all assertions the given [PresentWithCreator.assertionCreator] creates. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the given assertions are not success. + * + * @since 0.11.0 + */ +infix fun > Expect.toBe(present: PresentWithCreator): Expect = + ExpectImpl.optional.isPresent(this).addToInitial(present.assertionCreator) + +/** + * Helper function to create a [PresentWithCreator] based on the given [assertionCreator]. + */ +fun present(assertionCreator: Expect.() -> Unit) = PresentWithCreator(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt new file mode 100644 index 000000000..1864c2312 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt @@ -0,0 +1,45 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.api.infix.en_GB.Empty +import ch.tutteli.atrium.api.infix.en_GB.Present +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.feature0 +import ch.tutteli.atrium.specs.fun0 +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.integration.OptionalAssertionsSpec +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import java.util.* + +class OptionalAssertionsSpec : OptionalAssertionsSpec( + fun0(Companion::toBeEmpty), + feature0(Companion::toBePresentFeature), + fun1(Companion::toBePresent) +) { + companion object : WithAsciiReporter() { + private fun toBeEmpty(expect: Expect>) = expect toBe Empty + private fun toBePresent(expect: Expect>, assertionCreator: Expect.() -> Unit) = + expect toBe present(assertionCreator) + private fun toBePresentFeature(expect: Expect>) = expect toBe Present + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var o1: Expect> = notImplemented() + var o1b: Expect> = notImplemented() + + var star: Expect> = notImplemented() + + o1 = o1 toBe Empty + o1b = o1b toBe Empty + star = star toBe Empty + o1 toBe Present + o1b toBe Present + // following is not supported on purpose as we don't know what type the element is in this case + //star toBe Present + o1 toBe present {} + o1b toBe present {} + // following is not supported on purpose as we don't know what type the element is in this case + //star toBe present {} + } +} From 377522f84930f4782af2567969669232bdfd6d2d Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 1 Apr 2020 21:07:26 +0200 Subject: [PATCH 117/142] use underline instead of hyphens this way the text added by the user is not transformed into a title --- .github/PULL_REQUEST_TEMPLATE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 571dedf98..44bb0e02f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,3 @@ - ----- +______________________________________ I confirm that I have read the [Contributor Agreements v1.0](https://github.com/robstoll/atrium/blob/master/.github/Contributor%20Agreements%20v1.0.txt), agree to be bound on them and confirm that my contribution is compliant. From 0c560b35b51dc5c22a9ba0416bbdb4e9a08a5e08 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 2 Apr 2020 14:18:17 +0200 Subject: [PATCH 118/142] add a newline to the pull-request template --- .github/PULL_REQUEST_TEMPLATE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 44bb0e02f..90050329f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,4 @@ + ______________________________________ I confirm that I have read the [Contributor Agreements v1.0](https://github.com/robstoll/atrium/blob/master/.github/Contributor%20Agreements%20v1.0.txt), agree to be bound on them and confirm that my contribution is compliant. From 772424f81f1ff08cda318af9bd25d567f56d0111 Mon Sep 17 00:00:00 2001 From: Ivan Fedorov <37301285+isfedorov@users.noreply.github.com> Date: Thu, 2 Apr 2020 21:42:51 +0300 Subject: [PATCH 119/142] add arrayAssertions for the new infix API (#418) --- .../api/fluent/en_GB/arrayAssertions.kt | 38 +++ .../atrium/api/infix/en_GB/arrayAssertions.kt | 285 ++++++++++++++++++ .../infix/en_GB/ArrayAsListAssertionsSpec.kt | 84 ++++++ 3 files changed, 407 insertions(+) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ArrayAsListAssertionsSpec.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt index 4c9dd8a89..c0d54fc3c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/arrayAssertions.kt @@ -11,6 +11,8 @@ import kotlin.jvm.JvmName * Use `feature(Array::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ fun Expect>.asList(): Expect> = ExpectImpl.changeSubject(this).unreported { it.asList() } @@ -23,6 +25,8 @@ fun Expect>.asList(): Expect> = * Use `feature(Array::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = apply { asList().addAssertionsCreatedBy(assertionCreator) } @@ -35,6 +39,8 @@ fun Expect>.asList(assertionCreator: Expect>.() -> Unit): E * Use `feature(Array::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("asListEOut") fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = @@ -47,6 +53,8 @@ fun Expect>.asList(assertionCreator: Expect>.() -> Unit * Use `feature(ByteArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("byteArrAsList") fun Expect.asList(): Expect> = @@ -60,6 +68,8 @@ fun Expect.asList(): Expect> = * Use `feature(ByteArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("byteArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -73,6 +83,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit): E * Use `feature(CharArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("charArrAsList") fun Expect.asList(): Expect> = @@ -86,6 +98,8 @@ fun Expect.asList(): Expect> = * Use `feature(CharArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("charArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -99,6 +113,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit): E * Use `feature(ShortArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("shortArrAsList") fun Expect.asList(): Expect> = @@ -112,6 +128,8 @@ fun Expect.asList(): Expect> = * Use `feature(ShortArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("shortArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -125,6 +143,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit): * Use `feature(IntArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("intArrAsList") fun Expect.asList(): Expect> = ExpectImpl.changeSubject(this).unreported { it.asList() } @@ -137,6 +157,8 @@ fun Expect.asList(): Expect> = ExpectImpl.changeSubject(this * Use `feature(IntArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("intArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -150,6 +172,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit): Exp * Use `feature(LongArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("longArrAsList") fun Expect.asList(): Expect> = @@ -163,6 +187,8 @@ fun Expect.asList(): Expect> = * Use `feature(LongArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("longArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -176,6 +202,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit): E * Use `feature(FloatArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("floatArrAsList") fun Expect.asList(): Expect> = @@ -189,6 +217,8 @@ fun Expect.asList(): Expect> = * Use `feature(FloatArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("floatArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -202,6 +232,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit): * Use `feature(DoubleArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("doubleArrAsList") fun Expect.asList(): Expect> = @@ -215,6 +247,8 @@ fun Expect.asList(): Expect> = * Use `feature(DoubleArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("doubleArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = @@ -228,6 +262,8 @@ fun Expect.asList(assertionCreator: Expect>.() -> Unit * Use `feature(BooleanArray::asList)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("boolArrAsList") fun Expect.asList(): Expect> = @@ -241,6 +277,8 @@ fun Expect.asList(): Expect> = * Use `feature(BooleanArray::asList, assertionCreator)` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. + * + * @since 0.9.0 */ @JvmName("boolArrAsList") fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt new file mode 100644 index 000000000..c7754e484 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/arrayAssertions.kt @@ -0,0 +1,285 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import kotlin.jvm.JvmName + +/** + * Turns `Expect>` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +infix fun Expect>.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +infix fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("asListEOut") +infix fun Expect>.asList(assertionCreator: Expect>.() -> Unit): Expect> = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("byteArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("byteArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("charArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("charArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("shortArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("shortArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("intArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("intArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("longArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("longArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("floatArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("floatArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("doubleArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("doubleArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } + + +/** + * Turns `Expect` into `Expect>`. + * + * The transformation as such is not reflected in reporting. + * Use `feature { f(it::asList) }` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("boolArrAsList") +infix fun Expect.asList(@Suppress("UNUSED_PARAMETER") o: o): Expect> = + ExpectImpl.changeSubject(this).unreported { it.asList() } + +/** + * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for + * the subject as [List]. + * + * The transformation as such is not reflected in reporting. + * Use `feature of({ f(it::asList) }, assertionCreator)` if you want to show the transformation in reporting. + * + * @return The newly created [Expect] for the transformed subject. + * + * @since 0.11.0 + */ +@JvmName("boolArrAsList") +infix fun Expect.asList(assertionCreator: Expect>.() -> Unit): Expect = + apply { asList(o).addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ArrayAsListAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ArrayAsListAssertionsSpec.kt new file mode 100644 index 000000000..a01f1d6e2 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ArrayAsListAssertionsSpec.kt @@ -0,0 +1,84 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.notImplemented + +class ArrayAsListAssertionsSpec : ch.tutteli.atrium.specs.integration.ArrayAsListAssertionsSpec( + "asList", + Companion::arrayInt, + Companion::byteArray, + Companion::charArray, + Companion::shortArray, + Companion::intArray, + Companion::longArray, + Companion::floatArray, + Companion::doubleArray, + Companion::booleanArray, + + Companion::arrayIntWithCreator, + Companion::byteArrayWithCreator, + Companion::charArrayWithCreator, + Companion::shortArrayWithCreator, + Companion::intArrayWithCreator, + Companion::longArrayWithCreator, + Companion::floatArrayWithCreator, + Companion::doubleArrayWithCreator, + Companion::booleanArrayWithCreator +) { + + companion object { + fun arrayInt(expect: Expect>) = expect asList o + fun byteArray(expect: Expect) = expect asList o + fun charArray(expect: Expect) = expect asList o + fun shortArray(expect: Expect) = expect asList o + fun intArray(expect: Expect) = expect asList o + fun longArray(expect: Expect) = expect asList o + fun floatArray(expect: Expect) = expect asList o + fun doubleArray(expect: Expect) = expect asList o + fun booleanArray(expect: Expect) = expect asList o + + fun arrayIntWithCreator(expect: Expect>, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun byteArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun charArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun shortArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun intArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun longArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun floatArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun doubleArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + fun booleanArrayWithCreator(expect: Expect, assertionCreator: Expect>.() -> Unit) = + expect asList { assertionCreator() } + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a2: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + var a2b: Expect> = notImplemented() + + var star: Expect> = notImplemented() + + a1 asList o + a2 asList o + + a1 = a1 asList { } + a2 = a2 asList { } + + a1b asList o + a2b asList o + + a1b = a1b asList { } + a2b = a2b asList { } + + star asList o + star = star asList { } + } +} From 420389a6eb6cba60f77898bc73d34d496ec23b22 Mon Sep 17 00:00:00 2001 From: Ivan Fedorov Date: Fri, 3 Apr 2020 22:01:34 +0300 Subject: [PATCH 120/142] add bigDecimalAssertions for infix API (issue #233) --- .../api/infix/en_GB/bigDecimalAssertions.kt | 153 ++++++++++++++++++ .../infix/en_GB/BigDecimalAssertionsSpec.kt | 51 ++++++ 2 files changed, 204 insertions(+) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/BigDecimalAssertionsSpec.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt new file mode 100644 index 000000000..decd75a04 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt @@ -0,0 +1,153 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.bigDecimal +import ch.tutteli.atrium.domain.builders.creating.PleaseUseReplacementException +import java.math.BigDecimal + +/** + * Deprecated as it would compare the subject against [expected] including scale + * -- many developers are not aware of that. + * + * Use [isNumericallyEqualTo] if you expect that the following assertion holds: + * ``` + * expect(BigDecimal("10").toBe(BigDecimal("10.0")) + * ``` + * However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use [isEqualIncludingScale]. + */ +@Deprecated( + "Use `isNumericallyEqualTo` if you expect that the following assertion holds:\n" + + "`expect(BigDecimal(\"10\")).toBe(BigDecimal(\"10.0\"))`\n" + + "However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use `isEqualIncludingScale`.", + ReplaceWith("isNumericallyEqualTo(expected) or isEqualIncludingScale(expected)") +) +@Suppress("UNUSED_PARAMETER", "unused") +infix fun Expect.toBe(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 `isEqualIncludingScale`." +) + +@Suppress("UNUSED_PARAMETER", "unused") +@JvmName("toBeNullable") +@Deprecated( + "Use `isNumericallyEqualTo` if you expect that the following assertion holds:\n" + + "`expect(BigDecimal(\"10\")).toBe(BigDecimal(\"10.0\"))`\n" + + "However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use `isEqualIncludingScale`.", + ReplaceWith("isNumericallyEqualTo(expected) or isEqualIncludingScale(expected)") +) +infix fun Expect.toBe(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 `isEqualIncludingScale`." +) + +/** + * Expects that the subject of the assertion (a [BigDecimal]) is `null`. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +@JvmName("toBeNull") +infix fun Expect.toBe(expected: Nothing?): Expect = + addAssertion(ExpectImpl.any.toBe(this, expected)) + +/** + * Deprecated as it would compare the subject against [expected] including scale + * -- many developers are not aware of that. + * + * Use [isNotNumericallyEqualTo] 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 [isNotEqualIncludingScale]. + */ +@Deprecated( + "Use `isNotNumericallyEqualTo` 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 `isNotEqualIncludingScale`.", + ReplaceWith("isNotNumericallyEqualTo(expected) or isNotEqualIncludingScale(expected)") +) +@Suppress("UNUSED_PARAMETER", "unused") +infix fun Expect.notToBe(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 `isNotEqualIncludingScale`." +) + +/** + * Expects that the subject of the assertion (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 [isEqualIncludingScale] because + * [isEqualIncludingScale] compares [BigDecimal.scale]. + * Following the two functions compared: + * - `expect(BigDecimal("10")).isEqualIncludingScale(BigDecimal("10.0"))` does not hold. + * - `expect(BigDecimal("10")).isNumericallyEqualTo(BigDecimal("10.0"))` holds. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun Expect.isNumericallyEqualTo(expected: T) = + addAssertion(ExpectImpl.bigDecimal.isNumericallyEqualTo(this, expected)) + +/** + * Expects that the subject of the assertion (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 [isNotEqualIncludingScale] because + * [isNotEqualIncludingScale] compares [BigDecimal.scale]. + * Following the two functions compared: + * - `expect(BigDecimal("10")).isNotEqualIncludingScale(BigDecimal("10.0"))` holds. + * - `expect(BigDecimal("10")).isNotNumericallyEqualTo(BigDecimal("10.0"))` does not hold. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun Expect.isNotNumericallyEqualTo(expected: T) = + addAssertion(ExpectImpl.bigDecimal.isNotNumericallyEqualTo(this, expected)) + + +/** + * Expects that the subject of the assertion (a [BigDecimal]) is equal to [expected] including [BigDecimal.scale]. + * + * Most of the time you want to use [isNumericallyEqualTo] which does not compare [BigDecimal.scale] + * in contrast to this function. + * Following the two functions compared: + * - `expect(BigDecimal("10")).isEqualIncludingScale(BigDecimal("10.0"))` does not hold. + * - `expect(BigDecimal("10")).isNumericallyEqualTo(BigDecimal("10.0"))` holds. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun Expect.isEqualIncludingScale(expected: T) = + addAssertion(ExpectImpl.bigDecimal.isEqualIncludingScale(this, expected, this::isNumericallyEqualTo.name)) + +/** + * Expects that the subject of the assertion (a [BigDecimal]) is not equal to [expected] including [BigDecimal.scale]. + * + * Most of the time you want to use [isNotNumericallyEqualTo] which does not compare [BigDecimal.scale] + * in contrast to this function. + * Following the two functions compared: + * - `expect(BigDecimal("10")).isNotEqualIncludingScale(BigDecimal("10.0"))` holds. + * - `expect(BigDecimal("10")).isNotNumericallyEqualTo(BigDecimal("10.0"))` does not hold. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun Expect.isNotEqualIncludingScale(expected: T) = + addAssertion(ExpectImpl.bigDecimal.isNotEqualIncludingScale(this, expected)) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/BigDecimalAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/BigDecimalAssertionsSpec.kt new file mode 100644 index 000000000..1f4be3d7d --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/BigDecimalAssertionsSpec.kt @@ -0,0 +1,51 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.verbs.internal.expect +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.integration.BigDecimalAssertionsSpec +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe +import java.math.BigDecimal + +class BigDecimalAssertionsSpec : Spek({ + include(object : BigDecimalAssertionsSpec( + fun1(Companion::toBeBigDecimal), + fun1(Companion::toBeNullable), + fun1(Companion::toBeNull), + Expect::toBe, + fun1(Companion::notToBe), + Expect::notToBe, + fun1(Companion::isNumericallyEqualTo), + fun1(Companion::isNotNumericallyEqualTo), + fun1(Companion::isEqualIncludingScale), + fun1(Companion::isNotEqualIncludingScale) + ) {}) + + describe("fun toBe for BigDecimal? and subject is null") { + it("chooses the correct overload if `null` is passed, does not throw") { + expect(null as BigDecimal?) toBe null + } + } +}) { + companion object { + @Suppress("DEPRECATION") + fun toBeBigDecimal(expect: Expect, a: BigDecimal): Nothing = expect toBe a + + @Suppress("DEPRECATION") + fun toBeNullable(expect: Expect, a: BigDecimal?): Nothing = expect toBe a + + fun toBeNull(expect: Expect, nothing: Nothing?) = expect toBe nothing + + @Suppress("DEPRECATION") + fun notToBe(expect: Expect, a: BigDecimal): Nothing = expect notToBe a + + fun isNumericallyEqualTo(expect: Expect, a: BigDecimal) = expect isNumericallyEqualTo a + + fun isNotNumericallyEqualTo(expect: Expect, a: BigDecimal) = expect isNotNumericallyEqualTo a + + fun isEqualIncludingScale(expect: Expect, a: BigDecimal) = expect isEqualIncludingScale a + + fun isNotEqualIncludingScale(expect: Expect, a: BigDecimal) = expect isNotEqualIncludingScale a + } +} From d22596c7fde8a816fcd68777035acdbf53cbbe2f Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 1 Apr 2020 23:34:15 +0200 Subject: [PATCH 121/142] add iterable to the new infix API this commit includes: - turning the extension val `contains` into a fun `contains o` likewise `containsNot o` - remove the pseudo-keyword `not` as in `contains not`, i.e. turn `expect("h") contains not` into `expect("h") containsNot o` - improve ambiguity tests for Iterable...Spec --- .../iterableContainsInAnyOrderCreators.kt | 12 +- .../iterableContainsInAnyOrderOnlyCreators.kt | 12 +- .../iterableContainsInOrderOnlyCreators.kt | 12 +- ...rableContainsInOrderOnlyGroupedCreators.kt | 6 +- .../en_GB/iterableContainsSearchBehaviours.kt | 14 +- .../en_GB/CharSequenceContainsSpecBase.kt | 4 +- .../fluent/en_GB/IterableAllAssertionsSpec.kt | 6 +- .../fluent/en_GB/IterableAnyAssertionsSpec.kt | 33 +- .../fluent/en_GB/IterableAssertionsSpec.kt | 7 +- ...sInAnyOrderAtLeast1ValuesAssertionsSpec.kt | 2 +- .../fluent/en_GB/IterableContainsSpecBase.kt | 196 +++++++++-- .../en_GB/IterableFeatureAssertionsSpec.kt | 2 +- .../en_GB/IterableNoneAssertionsSpec.kt | 6 +- .../impl/AtLeastCheckerOptionImpl.kt | 3 +- .../impl/AtMostCheckerOptionImpl.kt | 3 +- .../impl/ButAtMostCheckerOptionImpl.kt | 3 +- .../impl/ExactlyCheckerOptionImpl.kt | 3 +- .../impl/NotOrAtMostCheckerOptionImpl.kt | 3 +- .../impl/nameContainsNotFun.kt | 7 +- .../contains/builders/AtLeastCheckerOption.kt | 14 + .../contains/builders/AtMostCheckerOption.kt | 14 + .../builders/ButAtMostCheckerOption.kt | 14 + .../contains/builders/ExactlyCheckerOption.kt | 14 + .../contains/builders/NotCheckerOption.kt | 13 + .../builders/NotOrAtMostCheckerOption.kt | 14 + .../builders/impl/AtLeastCheckerOptionImpl.kt | 30 ++ .../builders/impl/AtMostCheckerOptionImpl.kt | 34 ++ .../impl/ButAtMostCheckerOptionImpl.kt | 40 +++ .../builders/impl/ExactlyCheckerOptionImpl.kt | 30 ++ .../builders/impl/NotCheckerOptionImpl.kt | 22 ++ .../impl/NotOrAtMostCheckerOptionImpl.kt | 30 ++ .../builders/impl/nameContainsNotFun.kt | 23 ++ .../api/infix/en_GB/iterableAssertions.kt | 290 ++++++++++++++++ .../infix/en_GB/iterableContainsCheckers.kt | 90 +++++ .../iterableContainsInAnyOrderCreators.kt | 102 ++++++ .../iterableContainsInAnyOrderOnlyCreators.kt | 121 +++++++ .../iterableContainsInOrderOnlyCreators.kt | 112 ++++++ ...rableContainsInOrderOnlyGroupedCreators.kt | 52 +++ .../en_GB/iterableContainsSearchBehaviours.kt | 60 ++++ .../atrium/api/infix/en_GB/keywords.kt | 4 +- .../api/infix/en_GB/parameterObjects.kt | 64 +++- .../api/infix/en_GB/sequenceAssertions.kt | 1 + .../en_GB/CharSequenceContainsSpecBase.kt | 17 +- .../infix/en_GB/IterableAnyAssertionsSpec.kt | 111 ++++++ .../api/infix/en_GB/IterableAssertionsSpec.kt | 39 +++ ...nyOrderAtLeast1ElementsOfAssertionsSpec.kt | 46 +++ ...InAnyOrderAtLeast1EntriesAssertionsSpec.kt | 75 ++++ ...sInAnyOrderAtLeast1ValuesAssertionsSpec.kt | 77 +++++ ...nsInAnyOrderAtLeastValuesAssertionsSpec.kt | 55 +++ ...insInAnyOrderAtMostValuesAssertionsSpec.kt | 33 ++ ...nsInAnyOrderExactlyValuesAssertionsSpec.kt | 32 ++ ...AnyOrderNotOrAtMostValuesAssertionsSpec.kt | 32 ++ ...sInAnyOrderOnlyElementsOfAssertionsSpec.kt | 44 +++ ...ainsInAnyOrderOnlyEntriesAssertionsSpec.kt | 36 ++ ...tainsInAnyOrderOnlyValuesAssertionsSpec.kt | 36 ++ ...tainsInOrderOnlyElementsOfAssertionSpec.kt | 36 ++ ...ontainsInOrderOnlyEntriesAssertionsSpec.kt | 82 +++++ ...InOrderOnlyGroupedEntriesAssertionsSpec.kt | 34 ++ ...sInOrderOnlyGroupedValuesAssertionsSpec.kt | 59 ++++ ...ContainsInOrderOnlyValuesAssertionsSpec.kt | 77 +++++ ...terableContainsNotEntriesAssertionsSpec.kt | 35 ++ ...IterableContainsNotValuesAssertionsSpec.kt | 59 ++++ .../infix/en_GB/IterableContainsSpecBase.kt | 324 ++++++++++++++++++ .../en_GB/IterableFeatureAssertionsSpec.kt | 36 ++ .../infix/en_GB/IterableNoneAssertionsSpec.kt | 60 ++++ .../domain/builders/utils/VarArgHelper.kt | 1 + 66 files changed, 2854 insertions(+), 104 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtLeastCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtMostCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ButAtMostCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ExactlyCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotOrAtMostCheckerOption.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtLeastCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtMostCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ButAtMostCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ExactlyCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotOrAtMostCheckerOptionImpl.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsCheckers.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsSearchBehaviours.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfAssertionSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableFeatureAssertionsSpec.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt index 4169c4434..64a4fe83b 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt @@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion import ch.tutteli.atrium.domain.builders.utils.toVarArg -import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.CheckerOption import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour import ch.tutteli.kbox.glue @@ -19,7 +19,7 @@ import ch.tutteli.kbox.glue * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -fun > IterableContains.CheckerOption.value(expected: E): Expect = +fun > CheckerOption.value(expected: E): Expect = values(expected) /** @@ -42,7 +42,7 @@ fun > IterableContains.CheckerOption> IterableContains.CheckerOption.values( +fun > CheckerOption.values( expected: E, vararg otherExpected: E ): Expect = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrder(this, expected glue otherExpected)) @@ -61,7 +61,7 @@ fun > IterableContains.CheckerOption> IterableContains.CheckerOption.entry( +fun > CheckerOption.entry( assertionCreatorOrNull: (Expect.() -> Unit)? ): Expect = entries(assertionCreatorOrNull) @@ -80,7 +80,7 @@ fun > IterableContains.CheckerOption> IterableContains.CheckerOption.entries( +fun > CheckerOption.entries( assertionCreatorOrNull: (Expect.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? ): Expect = addAssertion( @@ -105,7 +105,7 @@ fun > IterableContains.CheckerOption> IterableContains.CheckerOption.elementsOf( +inline fun > CheckerOption.elementsOf( expectedIterable: Iterable ): Expect { val (first, rest) = toVarArg(expectedIterable) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt index 3efb58d6a..bb8ffb7ac 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion import ch.tutteli.atrium.domain.builders.utils.toVarArg -import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour import ch.tutteli.kbox.glue @@ -23,7 +23,7 @@ import ch.tutteli.kbox.glue * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -fun > IterableContains.Builder.value(expected: E): Expect = +fun > Builder.value(expected: E): Expect = values(expected) /** @@ -42,7 +42,7 @@ fun > IterableContains.Builder> IterableContains.Builder.values( +fun > Builder.values( expected: E, vararg otherExpected: E ): Expect = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrderOnly(this, expected glue otherExpected)) @@ -65,7 +65,7 @@ fun > IterableContains.Builder> IterableContains.Builder.entry( +fun > Builder.entry( assertionCreatorOrNull: (Expect.() -> Unit)? ): Expect = entries(assertionCreatorOrNull) @@ -97,7 +97,7 @@ fun > IterableContains.Builder> IterableContains.Builder.entries( +fun > Builder.entries( assertionCreatorOrNull: (Expect.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? ): Expect = addAssertion( @@ -126,7 +126,7 @@ fun > IterableContains.Builder> IterableContains.Builder.elementsOf( +inline fun > Builder.elementsOf( expectedIterable: Iterable ): Expect { val (first, rest) = toVarArg(expectedIterable) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt index dda601b0d..8f798b164 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion import ch.tutteli.atrium.domain.builders.utils.toVarArg -import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour import ch.tutteli.kbox.glue @@ -23,7 +23,7 @@ import ch.tutteli.kbox.glue * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -fun > IterableContains.Builder.value(expected: E): Expect = +fun > Builder.value(expected: E): Expect = values(expected) /** @@ -41,7 +41,7 @@ fun > IterableContains.Builder> IterableContains.Builder.values( +fun > Builder.values( expected: E, vararg otherExpected: E ): Expect = addAssertion(ExpectImpl.iterable.contains.valuesInOrderOnly(this, expected glue otherExpected)) @@ -64,7 +64,7 @@ fun > IterableContains.Builder> IterableContains.Builder.entry( +fun > Builder.entry( assertionCreatorOrNull: (Expect.() -> Unit)? ): Expect = entries(assertionCreatorOrNull) @@ -87,7 +87,7 @@ fun > IterableContains.Builder> IterableContains.Builder.entries( +fun > Builder.entries( assertionCreatorOrNull: (Expect.() -> Unit)?, vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? ): Expect = addAssertion( @@ -116,7 +116,7 @@ fun > IterableContains.Builder> IterableContains.Builder.elementsOf( +inline fun > Builder.elementsOf( expectedIterable: Iterable ): Expect { val (first, rest) = toVarArg(expectedIterable) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt index 95eb8bf0c..0d50be5f0 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt @@ -5,7 +5,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion import ch.tutteli.atrium.domain.builders.utils.Group import ch.tutteli.atrium.domain.builders.utils.groupsToList -import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlyGroupedWithinSearchBehaviour import kotlin.jvm.JvmName @@ -22,7 +22,7 @@ import kotlin.jvm.JvmName * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -fun > IterableContains.Builder.inAnyOrder( +fun > Builder.inAnyOrder( firstGroup: Group, secondGroup: Group, vararg otherExpectedGroups: Group @@ -52,7 +52,7 @@ fun > IterableContains.Builder> IterableContains.Builder.inAnyOrder( +fun > Builder.inAnyOrder( firstGroup: Group<(Expect.() -> Unit)?>, secondGroup: Group<(Expect.() -> Unit)?>, vararg otherExpectedGroups: Group<(Expect.() -> Unit)?> diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsSearchBehaviours.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsSearchBehaviours.kt index 514be712d..5989f127f 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsSearchBehaviours.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsSearchBehaviours.kt @@ -1,7 +1,7 @@ package ch.tutteli.atrium.api.fluent.en_GB import ch.tutteli.atrium.domain.builders.ExpectImpl -import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.* import kotlin.jvm.JvmName @@ -11,7 +11,7 @@ import kotlin.jvm.JvmName * * @return The newly created builder. */ -val > IterableContains.Builder.inAnyOrder +val > Builder.inAnyOrder get() = ExpectImpl.iterable.contains.searchBehaviours.inAnyOrder(this) /** @@ -20,7 +20,7 @@ val > IterableContains.Builder.inA * * @return The newly created builder. */ -val > IterableContains.Builder.only +val > Builder.only @JvmName("butOnly") get() = ExpectImpl.iterable.contains.searchBehaviours.inAnyOrderOnly(this) @@ -31,7 +31,7 @@ val > IterableContains.Builder> IterableContains.Builder.inOrder +val > Builder.inOrder get() = ExpectImpl.iterable.contains.searchBehaviours.inOrder(this) /** @@ -40,7 +40,7 @@ val > IterableContains.Builder.inO * * @return The newly created builder. */ -val > IterableContains.Builder.only +val > Builder.only @JvmName("andOnly") get() = ExpectImpl.iterable.contains.searchBehaviours.inOrderOnly(this) @@ -50,7 +50,7 @@ val > IterableContains.Builder. * * @return The newly created builder. */ -val > IterableContains.Builder.grouped +val > Builder.grouped get() = ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGrouped(this) /** @@ -58,5 +58,5 @@ val > IterableContains.Builder> IterableContains.Builder.within +val > Builder.within get() = ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGroupedWithin(this) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt index 63a753e78..aa4886855 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt @@ -53,7 +53,7 @@ abstract class CharSequenceContainsSpecBase { a1.contains.ignoringCase.values("a", 'b') a1.contains.ignoringCase.regex("a") a1.contains.ignoringCase.regex("a", "bl") - //TODO add (also to infix API) -// a1.contains.ignoringCase.elementsOf(listOf(1, 2))("a", "bl") + //TODO #422 uncomment + //a1.contains.ignoringCase.elementsOf(listOf("a", 2)) } } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt index 46c1c7620..813e6cbf3 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllAssertionsSpec.kt @@ -12,10 +12,10 @@ object IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableA ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() - var star: Expect> = notImplemented() + var star: Expect> = notImplemented() a1 = a1.all {} diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt index c37352480..160715c85 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyAssertionsSpec.kt @@ -7,7 +7,6 @@ import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.withNullableSuffix import org.spekframework.spek2.Spek import kotlin.reflect.KFunction2 -import kotlin.reflect.KFunction3 class IterableAnyAssertionsSpec : Spek({ include(PredicateSpec) @@ -45,47 +44,47 @@ class IterableAnyAssertionsSpec : Spek({ companion object : IterableContainsSpecBase() { fun getContainsPair() = - "$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsInAnyOrderEntries + "$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsInAnyOrderEntry - private fun containsInAnyOrderEntries(expect: Expect>, a: Expect.() -> Unit) = + private fun containsInAnyOrderEntry(expect: Expect>, a: Expect.() -> Unit) = expect.contains.inAnyOrder.atLeast(1).entry(a) fun getContainsNullablePair() = - "$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsNullableEntries + "$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsNullableEntry - private fun containsNullableEntries(expect: Expect>, a: (Expect.() -> Unit)?) = + private fun containsNullableEntry(expect: Expect>, a: (Expect.() -> Unit)?) = expect.contains.inAnyOrder.atLeast(1).entry(a) - private val containsShortcutFun: KFunction3>, Expect.() -> Unit, Array.() -> Unit>, Expect>> = + private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = Expect>::contains - fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntriesShortcut + fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntryShortcut - private fun containsInAnyOrderEntriesShortcut(expect: Expect>, a: Expect.() -> Unit) = + private fun containsInAnyOrderEntryShortcut(expect: Expect>, a: Expect.() -> Unit) = expect.contains(a) private val containsShortcutNullableFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = Expect>::contains fun getContainsNullableShortcutPair() = - containsShortcutNullableFun.name to Companion::containsNullableEntriesShortcut + containsShortcutNullableFun.name to Companion::containsNullableEntryShortcut - private fun containsNullableEntriesShortcut( + private fun containsNullableEntryShortcut( expect: Expect>, a: (Expect.() -> Unit)? ) = expect.contains(a) private fun getContainsSequencePair() = - "asSequence().${Sequence<*>::asIterable.name}().${containsShortcutFun.name}" to Companion::containsInAnyOrderEntriesSequence + "asSequence().${Sequence<*>::asIterable.name}().${containsShortcutFun.name}" to Companion::containsInAnyOrderEntrySequence - private fun containsInAnyOrderEntriesSequence(expect: Expect>, a: Expect.() -> Unit) = + private fun containsInAnyOrderEntrySequence(expect: Expect>, a: Expect.() -> Unit) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable().contains(a) fun getContainsNullableSequencePair() = - "asSequence().${Sequence<*>::asIterable.name}().${containsShortcutNullableFun.name}" to Companion::containsNullableEntriesSequence + "asSequence().${Sequence<*>::asIterable.name}().${containsShortcutNullableFun.name}" to Companion::containsNullableEntrySequence - private fun containsNullableEntriesSequence( + private fun containsNullableEntrySequence( expect: Expect>, a: (Expect.() -> Unit)? ) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable().contains(a) @@ -93,10 +92,10 @@ class IterableAnyAssertionsSpec : Spek({ @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() - var star: Expect> = notImplemented() + var star: Expect> = notImplemented() a1 = a1.any {} a1 = a1.contains {} diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAssertionsSpec.kt index c01de5b2a..b53bea38e 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAssertionsSpec.kt @@ -11,10 +11,9 @@ object IterableAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAsse @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() - - var star: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + var star: Expect> = notImplemented() a1 = a1.hasNext() a1 = a1.hasNotNext() diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt index 501480e1c..f0f3b5fd9 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt @@ -59,7 +59,7 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ else expect.contains(a, *aX) - private val containsNullableFun: KFunction3>, Double, Array, Expect>> = + private val containsNullableFun: KFunction3>, Double?, Array, Expect>> = Expect>::contains fun getContainsNullableShortcutPair() = containsNullableFun.name to Companion::containsNullableValuesShortcut diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsSpecBase.kt index 2bd64bb35..393cc923b 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsSpecBase.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsSpecBase.kt @@ -43,30 +43,69 @@ abstract class IterableContainsSpecBase { @Suppress("unused") private fun ambiguityTest() { val list: Expect> = notImplemented() - val nullableList: Expect> = notImplemented() + val nullableList: Expect> = notImplemented() val subList: Expect> = notImplemented() + val star: Expect> = notImplemented() list.contains(1) list.contains(1f) - list.contains(1, 2) list.contains(1, 2f) list.contains {} list.contains({}, {}) + list.containsNot(1) + list.containsNot(1f) + list.containsNot(1, 2f) + list.containsNot.entry {} + list.containsNot.entries({}, {}) + subList.contains(1) subList.contains(1f) - subList.contains(1, 2) subList.contains(1, 2f) subList.contains {} subList.contains({}, {}) + subList.containsNot(1) + subList.containsNot(1f) + subList.containsNot(1, 2f) + subList.containsNot.entry {} + subList.containsNot.entries({}, {}) + nullableList.contains(1) nullableList.contains(1f) - nullableList.contains(1, 2) nullableList.contains(1, 2f) nullableList.contains {} + nullableList.contains({}, {}) + nullableList.containsNot(1) + nullableList.containsNot(1f) + nullableList.containsNot(1, 2f) + nullableList.containsNot.entry {} + nullableList.containsNot.entries({}, {}) nullableList.contains(null) nullableList.contains({}, null) - nullableList.contains({}, {}) nullableList.contains(null, {}) + nullableList.contains(null, null) + nullableList.containsNot(null) + nullableList.containsNot.entries({}, null) + nullableList.containsNot.entries(null, {}) + nullableList.containsNot.entries(null, null) + + star.contains(1) + star.contains(1f) + star.contains(1, 2f) + star.contains {} + star.contains({}, {}) + star.containsNot(1) + star.containsNot(1f) + star.containsNot(1, 2f) + star.containsNot.entry {} + star.containsNot.entries({}, {}) + star.contains(null) + star.contains({}, null) + star.contains(null, {}) + star.contains(null, null) + star.containsNot(null) + star.containsNot.entries({}, null) + star.containsNot.entries(null, {}) + star.containsNot.entries(null, null) list.containsExactly(1) list.containsExactly(1, 2f) @@ -85,67 +124,162 @@ abstract class IterableContainsSpecBase { nullableList.containsExactly(null, {}) list.contains.inAnyOrder.atLeast(1).value(1) - list.contains.inAnyOrder.atLeast(1).value(null) + list.contains.inAnyOrder.atLeast(1).values(2, 1) list.contains.inAnyOrder.atLeast(1).entry {} - list.contains.inAnyOrder.atLeast(1).entry(null) + list.contains.inAnyOrder.atLeast(1).entries({}, {}) + list.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2)) subList.contains.inAnyOrder.atLeast(1).value(1) - subList.contains.inAnyOrder.atLeast(1).value(null) + subList.contains.inAnyOrder.atLeast(1).values(2, 1) subList.contains.inAnyOrder.atLeast(1).entry {} - subList.contains.inAnyOrder.atLeast(1).entry(null) + subList.contains.inAnyOrder.atLeast(1).entries({}, {}) + subList.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2)) + nullableList.contains.inAnyOrder.atLeast(1).value(1) + nullableList.contains.inAnyOrder.atLeast(1).values(2, 1) + nullableList.contains.inAnyOrder.atLeast(1).entry {} + nullableList.contains.inAnyOrder.atLeast(1).entries({}, {}) + nullableList.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2)) + nullableList.contains.inAnyOrder.atLeast(1).value(null) + nullableList.contains.inAnyOrder.atLeast(1).values(null, 1) + nullableList.contains.inAnyOrder.atLeast(1).values(2, null) + nullableList.contains.inAnyOrder.atLeast(1).values(null, null) + nullableList.contains.inAnyOrder.atLeast(1).entry(null) + nullableList.contains.inAnyOrder.atLeast(1).entries(null, {}) + nullableList.contains.inAnyOrder.atLeast(1).entries({}, null) + nullableList.contains.inAnyOrder.atLeast(1).entries(null, null) + star.contains.inAnyOrder.atLeast(1).value(1) + star.contains.inAnyOrder.atLeast(1).values(2, 1) + star.contains.inAnyOrder.atLeast(1).entry {} + star.contains.inAnyOrder.atLeast(1).entries({}, {}) + star.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2)) + star.contains.inAnyOrder.atLeast(1).value(null) + star.contains.inAnyOrder.atLeast(1).values(null, 1) + star.contains.inAnyOrder.atLeast(1).values(2, null) + star.contains.inAnyOrder.atLeast(1).values(null, null) + star.contains.inAnyOrder.atLeast(1).entry(null) + star.contains.inAnyOrder.atLeast(1).entries(null, {}) + star.contains.inAnyOrder.atLeast(1).entries({}, null) + star.contains.inAnyOrder.atLeast(1).entries(null, null) list.contains.inAnyOrder.only.value(1) - list.contains.inAnyOrder.only.value(null) + list.contains.inAnyOrder.only.values(2, 1) list.contains.inAnyOrder.only.entry {} - list.contains.inAnyOrder.only.entry(null) + list.contains.inAnyOrder.only.entries({}, {}) + list.contains.inAnyOrder.only.elementsOf(listOf(1, 2)) subList.contains.inAnyOrder.only.value(1) - subList.contains.inAnyOrder.only.value(null) + subList.contains.inAnyOrder.only.values(2, 1) subList.contains.inAnyOrder.only.entry {} - subList.contains.inAnyOrder.only.entry(null) + subList.contains.inAnyOrder.only.entries({}, {}) + subList.contains.inAnyOrder.only.elementsOf(listOf(1, 2)) + nullableList.contains.inAnyOrder.only.value(1) + nullableList.contains.inAnyOrder.only.values(2, 1) + nullableList.contains.inAnyOrder.only.entry {} + nullableList.contains.inAnyOrder.only.entries({}, {}) + nullableList.contains.inAnyOrder.only.elementsOf(listOf(1, 2)) + nullableList.contains.inAnyOrder.only.value(null) + nullableList.contains.inAnyOrder.only.values(null, 1) + nullableList.contains.inAnyOrder.only.values(2, null) + nullableList.contains.inAnyOrder.only.values(null, null) + nullableList.contains.inAnyOrder.only.entry(null) + nullableList.contains.inAnyOrder.only.entries(null, {}) + nullableList.contains.inAnyOrder.only.entries({}, null) + nullableList.contains.inAnyOrder.only.entries(null, null) + star.contains.inAnyOrder.only.value(1) + star.contains.inAnyOrder.only.values(2, 1) + star.contains.inAnyOrder.only.entry {} + star.contains.inAnyOrder.only.entries({}, {}) + star.contains.inAnyOrder.only.elementsOf(listOf(1, 2)) + star.contains.inAnyOrder.only.value(null) + star.contains.inAnyOrder.only.values(null, 1) + star.contains.inAnyOrder.only.values(2, null) + star.contains.inAnyOrder.only.values(null, null) + star.contains.inAnyOrder.only.entry(null) + star.contains.inAnyOrder.only.entries(null, {}) + star.contains.inAnyOrder.only.entries({}, null) + star.contains.inAnyOrder.only.entries(null, null) list.contains.inOrder.only.value(1) - list.contains.inOrder.only.value(null) + list.contains.inOrder.only.values(2, 1) list.contains.inOrder.only.entry {} - list.contains.inOrder.only.entry(null) + list.contains.inOrder.only.entries({}, {}) + list.contains.inOrder.only.elementsOf(listOf(1, 2)) subList.contains.inOrder.only.value(1) - subList.contains.inOrder.only.value(null) + subList.contains.inOrder.only.values(2, 1) subList.contains.inOrder.only.entry {} - subList.contains.inOrder.only.entry(null) - + subList.contains.inOrder.only.entries({}, {}) + subList.contains.inOrder.only.elementsOf(listOf(1, 2)) + nullableList.contains.inOrder.only.value(1) + nullableList.contains.inOrder.only.values(2, 1) + nullableList.contains.inOrder.only.entry {} + nullableList.contains.inOrder.only.entries({}, {}) + nullableList.contains.inOrder.only.elementsOf(listOf(1, 2)) + nullableList.contains.inOrder.only.value(null) + nullableList.contains.inOrder.only.values(null, 1) + nullableList.contains.inOrder.only.values(2, null) + nullableList.contains.inOrder.only.values(null, null) + nullableList.contains.inOrder.only.entry(null) + nullableList.contains.inOrder.only.entries(null, {}) + nullableList.contains.inOrder.only.entries({}, null) + nullableList.contains.inOrder.only.entries(null, null) + star.contains.inOrder.only.value(1) + star.contains.inOrder.only.values(2, 1) + star.contains.inOrder.only.entry {} + star.contains.inOrder.only.entries({}, {}) + star.contains.inOrder.only.elementsOf(listOf(1, 2)) + star.contains.inOrder.only.value(null) + star.contains.inOrder.only.values(null, 1) + star.contains.inOrder.only.values(2, null) + star.contains.inOrder.only.values(null, null) + star.contains.inOrder.only.entry(null) + star.contains.inOrder.only.entries(null, {}) + star.contains.inOrder.only.entries({}, null) + star.contains.inOrder.only.entries(null, null) list.contains.inOrder.only.grouped.within.inAnyOrder( Value(1), - Value(null), Values(1f), - Values(null), - Values(1f, 1), - Values(1, null), - Values(null, null) + Values(1f, 1) ) subList.contains.inOrder.only.grouped.within.inAnyOrder( Value(1), - Value(null), Values(1f), + Values(1f, 1) + ) + nullableList.contains.inOrder.only.grouped.within.inAnyOrder( + Value(null), Values(null), - Values(1f, 1), + Values(null, 2), + Values(1, null), + Values(null, null) + ) + star.contains.inOrder.only.grouped.within.inAnyOrder( + Value(null), + Values(null), + Values(null, 2), Values(1, null), Values(null, null) ) list.contains.inOrder.only.grouped.within.inAnyOrder( Entry {}, - Entry(null), Entries({}), + Entries({}, {}) + ) + subList.contains.inOrder.only.grouped.within.inAnyOrder( + Entry {}, + Entries({}), + Entries({}, {}) + ) + nullableList.contains.inOrder.only.grouped.within.inAnyOrder( + Entry(null), Entries(null), - Entries({}, {}), + Entries(null, {}), Entries({}, null), Entries(null, null) ) - subList.contains.inOrder.only.grouped.within.inAnyOrder( - Entry {}, + star.contains.inOrder.only.grouped.within.inAnyOrder( Entry(null), - Entries({}), Entries(null), - Entries({}, {}), + Entries(null, {}), Entries({}, null), Entries(null, null) ) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt index c2dc89cf1..551704c45 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableFeatureAssertionsSpec.kt @@ -13,7 +13,7 @@ class IterableFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.Iterab ) { @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() + var a1: Expect> = notImplemented() //nullable not supported by min/max or rather T : Comparable does not exist for T? (one cannot implement an interface for the nullable type) //same for Iterable<*> diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt index 7c664032f..ddba85eed 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneAssertionsSpec.kt @@ -41,10 +41,10 @@ class IterableNoneAssertionsSpec : Spek({ @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() - var star: Expect> = notImplemented() + var star: Expect> = notImplemented() a1 = a1.none {} a1 = a1.containsNot.entry {} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt index d90b1662d..5e56d0909 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtLeastCheckerOptionImpl.kt @@ -2,6 +2,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builder import ch.tutteli.atrium.api.infix.en_GB.atLeast import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.AtLeastCheckerOptionBase import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains @@ -24,6 +25,6 @@ internal class AtLeastCheckerOptionImpl( times, containsBuilder, - nameContainsNotValuesFun(), + nameContainsNotValuesFun, { "`${containsBuilder::atLeast.name} $it`" } ), AtLeastCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt index 4d361dcd8..8448bceae 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/AtMostCheckerOptionImpl.kt @@ -3,6 +3,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builder import ch.tutteli.atrium.api.infix.en_GB.atLeast import ch.tutteli.atrium.api.infix.en_GB.atMost import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun import ch.tutteli.atrium.api.infix.en_GB.exactly import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.AtMostCheckerOptionBase import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains @@ -26,7 +27,7 @@ internal class AtMostCheckerOptionImpl( times, containsBuilder, - nameContainsNotValuesFun(), + nameContainsNotValuesFun, { "`${containsBuilder::atMost.name} $it`" }, { "`${containsBuilder::atLeast.name} $it`" }, { "`${containsBuilder::exactly.name} $it`" } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt index be601909c..f9a03551a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ButAtMostCheckerOptionImpl.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.api.infix.en_GB.atMost import ch.tutteli.atrium.api.infix.en_GB.butAtMost import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.ButAtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun import ch.tutteli.atrium.api.infix.en_GB.exactly import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.ButAtMostCheckerOptionBase import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains @@ -30,7 +31,7 @@ internal class ButAtMostCheckerOptionImpl "`${containsBuilder::atLeast.name} $l ${atLeastBuilder::butAtMost.name} $u`" }, { "`${containsBuilder::atMost.name} $it`" }, { "`${containsBuilder::atLeast.name} $it`" }, diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt index bcc2e9822..f5ee5d6a3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/ExactlyCheckerOptionImpl.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.ExactlyCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun import ch.tutteli.atrium.api.infix.en_GB.exactly import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.ExactlyCheckerOptionBase import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains @@ -24,6 +25,6 @@ internal class ExactlyCheckerOptionImpl( times, containsBuilder, - nameContainsNotValuesFun(), + nameContainsNotValuesFun, { "`${containsBuilder::exactly.name} $it`" } ), ExactlyCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt index bb2b455b6..4e9569c70 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/NotOrAtMostCheckerOptionImpl.kt @@ -1,6 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotOrAtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun import ch.tutteli.atrium.api.infix.en_GB.notOrAtMost import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.NotOrAtMostCheckerOptionBase import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains @@ -24,6 +25,6 @@ internal class NotOrAtMostCheckerOptionImpl( times, containsBuilder, - nameContainsNotValuesFun(), + nameContainsNotValuesFun, { "`${containsBuilder::notOrAtMost.name} $it`" } ), NotOrAtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt index d5757867f..0f790779f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt @@ -5,7 +5,8 @@ import ch.tutteli.atrium.api.infix.en_GB.containsNot import ch.tutteli.atrium.creating.Expect import kotlin.reflect.KFunction2 -internal fun nameContainsNotValuesFun(): String { - val f: KFunction2, Values, Expect> = Expect::containsNot - return "`${f.name} ${Values::class.simpleName}`" +internal object StaticName { + private val f: KFunction2, Values, Expect> = + Expect::containsNot + val nameContainsNotValuesFun = "`${f.name} ${Values::class.simpleName}`" } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtLeastCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtLeastCheckerOption.kt new file mode 100644 index 000000000..4823d8e2e --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtLeastCheckerOption.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders + +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains + +/** + * Represents the extension point for another option after a `contains at least`-check within a sophisticated + * `contains` assertion building process for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface AtLeastCheckerOption, out S : IterableContains.SearchBehaviour> + : WithTimesCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtMostCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtMostCheckerOption.kt new file mode 100644 index 000000000..988039ac8 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/AtMostCheckerOption.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders + +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains + +/** + * Represents the extension point for another option after a `contains at least once but at most`-check within + * a sophisticated `contains` assertion building process for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface AtMostCheckerOption, out S : IterableContains.SearchBehaviour> + : WithTimesCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ButAtMostCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ButAtMostCheckerOption.kt new file mode 100644 index 000000000..61af9b7ff --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ButAtMostCheckerOption.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders + +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains + +/** + * Represents the extension point for another option after a `contains at least but at most`-check within a + * sophisticated `contains` assertion building process for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface ButAtMostCheckerOption, out S : IterableContains.SearchBehaviour> + : WithTimesCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ExactlyCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ExactlyCheckerOption.kt new file mode 100644 index 000000000..0548bacc4 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/ExactlyCheckerOption.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders + +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains + +/** + * Represents the extension point for another option after a `contains exactly`-check within + * a sophisticated `contains` assertion building process for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface ExactlyCheckerOption, out S : IterableContains.SearchBehaviour> + : WithTimesCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotCheckerOption.kt new file mode 100644 index 000000000..51819520c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotCheckerOption.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders + +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains + +/** + * Represents the extension point for another option after a `contains not at all`-check within + * a sophisticated `contains` assertion building process for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface NotCheckerOption, out S : IterableContains.SearchBehaviour> + : IterableContains.CheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotOrAtMostCheckerOption.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotOrAtMostCheckerOption.kt new file mode 100644 index 000000000..fc7900a91 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/NotOrAtMostCheckerOption.kt @@ -0,0 +1,14 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders + +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains + +/** + * Represents the extension point for another option after a `contains not or at most`-check within + * a sophisticated `contains` assertion building process for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + */ +interface NotOrAtMostCheckerOption, out S : IterableContains.SearchBehaviour> + : WithTimesCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtLeastCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtLeastCheckerOptionImpl.kt new file mode 100644 index 000000000..e8d401f1e --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtLeastCheckerOptionImpl.kt @@ -0,0 +1,30 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.atLeast +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.AtLeastCheckerOptionBase +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Represents the builder of a `contains at least` check within the fluent API of a sophisticated + * `contains` assertion for [Iterable]. + * + * @param T The input type of the search. + * + * @constructor Represents the builder of a `contains at least` check within the fluent API of a sophisticated + * `contains` assertion for [Iterable]. + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * @param containsBuilder The previously used [IterableContains.Builder]. + */ +internal class AtLeastCheckerOptionImpl, out S : InAnyOrderSearchBehaviour>( + times: Int, + containsBuilder: IterableContains.Builder +) : AtLeastCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun, + { "`${containsBuilder::atLeast.name} $it`" } +), AtLeastCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtMostCheckerOptionImpl.kt new file mode 100644 index 000000000..41b681fb8 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/AtMostCheckerOptionImpl.kt @@ -0,0 +1,34 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.atLeast +import ch.tutteli.atrium.api.infix.en_GB.atMost +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun +import ch.tutteli.atrium.api.infix.en_GB.exactly +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.AtMostCheckerOptionBase +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Represents the builder of a `contains at least once but at most` check within the fluent API of a + * sophisticated `contains` assertion for [Iterable]. + * + * @param T The input type of the search. + * + * @constructor Represents the builder of a `contains at least once but at most` check within the fluent API of a + * sophisticated `contains` assertion for [Iterable]. + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * @param containsBuilder The previously used [IterableContains.Builder]. + */ +internal class AtMostCheckerOptionImpl, out S : InAnyOrderSearchBehaviour>( + times: Int, + containsBuilder: IterableContains.Builder +) : AtMostCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun, + { "`${containsBuilder::atMost.name} $it`" }, + { "`${containsBuilder::atLeast.name} $it`" }, + { "`${containsBuilder::exactly.name} $it`" } +), AtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ButAtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ButAtMostCheckerOptionImpl.kt new file mode 100644 index 000000000..6fa22c476 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ButAtMostCheckerOptionImpl.kt @@ -0,0 +1,40 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.atLeast +import ch.tutteli.atrium.api.infix.en_GB.atMost +import ch.tutteli.atrium.api.infix.en_GB.butAtMost +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.ButAtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun +import ch.tutteli.atrium.api.infix.en_GB.exactly +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.ButAtMostCheckerOptionBase +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Represents the builder of the second step of a `contains at least but at most` check within the + * fluent API of a sophisticated `contains` assertion for [Iterable]. + * + * @param T The input type of the search. + * + * @constructor Represents the builder of the second step of a `contains at least but at most` check within the + * fluent API of a sophisticated `contains` assertion for [Iterable]. + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * @param containsBuilder The previously used [IterableContains.Builder]. + */ +internal class ButAtMostCheckerOptionImpl, out S : InAnyOrderSearchBehaviour>( + times: Int, + atLeastBuilder: AtLeastCheckerOption, + containsBuilder: IterableContains.Builder +) : ButAtMostCheckerOptionBase( + times, + atLeastBuilder, + containsBuilder, + nameContainsNotValuesFun, + { l, u -> "`${containsBuilder::atLeast.name} $l ${atLeastBuilder::butAtMost.name} $u`" }, + { "`${containsBuilder::atMost.name} $it`" }, + { "`${containsBuilder::atLeast.name} $it`" }, + { "`${atLeastBuilder::butAtMost.name} $it`" }, + { "`${containsBuilder::exactly.name} $it`" } +), ButAtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ExactlyCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ExactlyCheckerOptionImpl.kt new file mode 100644 index 000000000..7db1d658c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/ExactlyCheckerOptionImpl.kt @@ -0,0 +1,30 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.ExactlyCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun +import ch.tutteli.atrium.api.infix.en_GB.exactly +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.ExactlyCheckerOptionBase +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Represents the builder of a `contains exactly` check within the fluent API of a sophisticated + * `contains` assertion for [Iterable]. + * + * @param T The input type of the search. + * + * @constructor Represents the builder of a `contains exactly` check within the fluent API of a sophisticated + * `contains` assertion for [Iterable]. + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * @param containsBuilder The previously used [IterableContains.Builder]. + */ +internal class ExactlyCheckerOptionImpl, out S : InAnyOrderSearchBehaviour>( + times: Int, + containsBuilder: IterableContains.Builder +) : ExactlyCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun, + { "`${containsBuilder::exactly.name} $it`" } +), ExactlyCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotCheckerOptionImpl.kt new file mode 100644 index 000000000..a27e95eca --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotCheckerOptionImpl.kt @@ -0,0 +1,22 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.NotCheckerOptionBase +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Represents the builder of a `contains not at all` check within the fluent API of a sophisticated + * `contains` assertion for [Iterable]. + * + * @param T The input type of the search. + * @param S The search behaviour which should be applied for the input of the search. + * + * @constructor Represents the builder of a `contains not at all` check within the fluent API of a sophisticated + * `contains not` assertion for [Iterable]. + * @param containsBuilder The previously used [IterableContains.Builder]. + */ +internal class NotCheckerOptionImpl, out S : InAnyOrderSearchBehaviour>( + containsBuilder: IterableContains.Builder +) : NotCheckerOptionBase(containsBuilder), + NotCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotOrAtMostCheckerOptionImpl.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotOrAtMostCheckerOptionImpl.kt new file mode 100644 index 000000000..14ac6cdb1 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/NotOrAtMostCheckerOptionImpl.kt @@ -0,0 +1,30 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotOrAtMostCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun +import ch.tutteli.atrium.api.infix.en_GB.notOrAtMost +import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.NotOrAtMostCheckerOptionBase +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Represents the builder of a `contains not or at most` check within the fluent API of a + * sophisticated `contains` assertion for [Iterable]. + * + * @param T The input type of the search. + * + * @constructor Represents the builder of a `contains at least once but at most` check within the fluent API of a + * sophisticated `contains` assertion for [Iterable]. + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * @param containsBuilder The previously used [IterableContains.Builder]. + */ +internal class NotOrAtMostCheckerOptionImpl, out S : InAnyOrderSearchBehaviour>( + times: Int, + containsBuilder: IterableContains.Builder +) : NotOrAtMostCheckerOptionBase( + times, + containsBuilder, + nameContainsNotValuesFun, + { "`${containsBuilder::notOrAtMost.name} $it`" } +), NotOrAtMostCheckerOption diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt new file mode 100644 index 000000000..50f3ad833 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt @@ -0,0 +1,23 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl + +import ch.tutteli.atrium.api.infix.en_GB.Values +import ch.tutteli.atrium.api.infix.en_GB.containsNot +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.o +import ch.tutteli.atrium.api.infix.en_GB.the +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NotSearchBehaviour +import kotlin.reflect.KFunction2 + +internal object StaticName { + private val f: KFunction2>, o, NotCheckerOption, NotSearchBehaviour>> = + Expect>::containsNot + private val fThe: KFunction2< + IterableContains.CheckerOption, InAnyOrderSearchBehaviour>, + Values, + Expect> + > = IterableContains.CheckerOption, InAnyOrderSearchBehaviour>::the + val nameContainsNotValuesFun = "`${f.name} ${o::class.simpleName} ${fThe.name} ${Values::class.simpleName}`" +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt index e37d1a5be..c0e5879b1 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt @@ -1,7 +1,275 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.NotCheckerOptionImpl import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NoOpSearchBehaviour +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NotSearchBehaviour + +/** + * Creates an [IterableContains.Builder] based on this [Expect] which allows to define + * more sophisticated `contains` assertions. + * + * @param o The filler object [o]. + * + * @return The newly created builder. + */ +infix fun > Expect.contains( + @Suppress("UNUSED_PARAMETER") o: o +): IterableContains.Builder = ExpectImpl.iterable.containsBuilder(this) + +/** + * Creates an [IterableContains.Builder] based on this [Expect] which allows to define + * more sophisticated `contains not` assertions. + * + * @param o The filler object [o]. + * + * @return The newly created builder. + */ +infix fun > Expect.containsNot( + @Suppress("UNUSED_PARAMETER") o: o +): NotCheckerOption = NotCheckerOptionImpl(ExpectImpl.iterable.containsNotBuilder(this)) + +/** + * Creates an [Expect] for the result of calling `min()` on the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @param o The filler object [o]. + * + * @return The newly created [Expect] for the extracted feature. + * + * @since 0.11.0 + */ +infix fun , T : Iterable> Expect.min(@Suppress("UNUSED_PARAMETER") o: o): Expect = + ExpectImpl.iterable.min(this).getExpectOfFeature() + +/** + * Expects that the result of calling `min()` on the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun , T : Iterable> Expect.min(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.iterable.min(this).addToInitial(assertionCreator) + + +/** + * Creates an [Expect] for the result of calling `max()` on the subject of the assertion, + * so that further fluent calls are assertions about it. + * + * @param o The filler object [o]. + * + * @return The newly created [Expect] for the extracted feature. + * + * @since 0.11.0 + */ +infix fun , T : Iterable> Expect.max(@Suppress("UNUSED_PARAMETER") o: o): Expect = + ExpectImpl.iterable.max(this).getExpectOfFeature() + +/** + * Expects that the result of calling `max()` on the subject of the assertion + * holds all assertions the given [assertionCreator] creates for it and + * returns an [Expect] for the current subject of the assertion. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun , T : Iterable> Expect.max(assertionCreator: Expect.() -> Unit): Expect = + ExpectImpl.iterable.max(this).addToInitial(assertionCreator) + +/** + * Expects that the subject of the assertion (an [Iterable]) contains the [expected] value. + * + * It is a shortcut for `contains o inAny order atLeast 1 value expected` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.contains(expected: E) = + it contains o inAny order atLeast 1 value expected + +/** + * Expects that the subject of the assertion (an [Iterable]) contains the expected [values]. + * + * It is a shortcut for `contains o inAny order atLeast 1 the Values(...)` + * + * Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and + * [values].[expected][Values.expected] is defined as `'a'` and + * one [values].[otherExpected][Values.otherExpected] is defined as `'a'` as well, then both match, + * even though they match the same entry. Use an option such as [atLeast], [atMost] and [exactly] to control the + * number of occurrences you expect. + * + * Meaning you might want to use: + * contains o inAny order exactly 2 value 'a'` + * instead of: + * `contains Values('a', 'a')` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.contains(values: Values): Expect = + it contains o inAny order atLeast 1 the values + +/** + * Expects that the subject of the assertion (an [Iterable]) contains an entry holding the + * assertions created by [assertionCreatorOrNull] or an entry which is `null` in case [assertionCreatorOrNull] + * is defined as `null`. + * + * It is a shortcut for `contains o inAny order atLeast 1 entry assertionCreatorOrNull` + * + * @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking + * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for + * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.contains(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + it contains o inAny order atLeast 1 entry assertionCreatorOrNull + +/** + * Makes the assertion that the [Assert.subject][SubjectProvider.subject] contains an entry holding the + * assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or an entry + * which is `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] + * is defined as `null` -- likewise an entry (can be the same) is searched for each of the + * [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls]. + * + * It is a shortcut for `contains o inAny order atLeast 1 the Entries(...)` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.contains( + entries: Entries +): Expect = it contains o inAny order atLeast 1 the entries + +/** + * Expects that the subject of the assertion (an [Iterable]) contains only + * the [expected] value. + * + * It is a shortcut for `contains o inGiven order and only value expected` + + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsExactly(expected: E): Expect = + it contains o inGiven order and only value expected + +/** + * Expects that the subject of the assertion (an [Iterable]) contains only + * the expected [values] in the defined order. + * + * It is a shortcut for `contains o inGiven order and only the Values(...)` + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsExactly(values: Values): Expect = + it contains o inGiven order and only the values + +/** + * Expects that the subject of the assertion (an [Iterable]) contains only an entry holding + * the assertions created by [assertionCreatorOrNull] or only one entry which is `null` in case [assertionCreatorOrNull] + * is defined as `null`. + * + * It is a shortcut for `contains o inGiven order and only entry assertionCreatorOrNull` + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking + * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for + * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsExactly(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + it contains o inGiven order and only entry assertionCreatorOrNull + +/** + * Expects that the subject of the assertion (an [Iterable]) contains only an entry holding + * the assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or + * `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] is defined as `null` + * and likewise an additional entry for each + * [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls] (if given) + * whereas the entries have to appear in the defined order. + * + * It is a shortcut for `contains o inGiven order and only the Entries(...)` + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsExactly(entries: Entries): Expect = + it contains o inGiven order and only the entries + +/** + * Expects that the subject of the assertion (an [Iterable]) does not contain the [expected] value. + * + * It is a shortcut for `containsNot o value expected` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsNot(expected: E): Expect = + it containsNot o value expected + +/** + * Expects that the subject of the assertion (an [Iterable]) does not contain the expected [values]. + * + * It is a shortcut for `containsNot o the Values(...)` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.containsNot(values: Values): Expect = + it containsNot o the values + + +/** + * Expects that the subject of the assertion (an [Iterable]) contains an entry holding + * the assertions created by [assertionCreatorOrNull] or an entry which is `null` in case [assertionCreatorOrNull] + * is defined as `null`. + * + * It is a shortcut for `contains o inAny order atLeast 1 entry assertionCreatorOrNull` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.any(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + it contains o inAny order atLeast 1 entry assertionCreatorOrNull + + +/** + * Expects that the subject of the assertion (an [Iterable]) does not contain a single entry + * which holds all assertions created by [assertionCreatorOrNull] or does not contain a single entry which is `null` + * in case [assertionCreatorOrNull] is defined as `null`. + * + * It is a shortcut for `containsNot o entry assertionCreatorOrNull` + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Expect.none(assertionCreatorOrNull: (Expect.() -> Unit)?) = + it containsNot o entry assertionCreatorOrNull /** * Expects that the subject of the assertion (an [Iterable]) has at least one element and @@ -13,3 +281,25 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl */ infix fun > Expect.all(assertionCreatorOrNull: (Expect.() -> Unit)?) = addAssertion(ExpectImpl.iterable.all(this, assertionCreatorOrNull)) + +/** + * Expects that the subject of the assertion (an [Iterable]) has at least one element. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.has(@Suppress("UNUSED_PARAMETER") next: next) = + addAssertion(ExpectImpl.iterable.hasNext(this)) + +/** + * Expects that the subject of the assertion (an [Iterable]) does not have next element. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.hasNot(@Suppress("UNUSED_PARAMETER") next: next) = + addAssertion(ExpectImpl.iterable.hasNotNext(this)) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsCheckers.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsCheckers.kt new file mode 100644 index 000000000..eb3f8c9a2 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsCheckers.kt @@ -0,0 +1,90 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.* +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.* +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we are looking + * for occurs `at least` number of [times] within the [Iterable]. + * + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + */ +infix fun , S : InAnyOrderSearchBehaviour> IterableContains.Builder.atLeast( + times: Int +): AtLeastCheckerOption = AtLeastCheckerOptionImpl(times, this) + +/** + * Restricts a `contains at least` assertion by specifying that the number of occurrences of the entry which we + * are looking for occurs `at most` number of [times] within the [Iterable]. + * + * The resulting restriction will be a `contains at least but at most` assertion. + * + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + * @throws IllegalArgumentException In case [times] of this `at most` restriction equals to the number of the + * `at least` restriction; use the [exactly] restriction instead. + */ +infix fun , S : InAnyOrderSearchBehaviour> AtLeastCheckerOption.butAtMost( + times: Int +): ButAtMostCheckerOption = ButAtMostCheckerOptionImpl(times, this, containsBuilder) + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we + * are looking for occurs `exactly` number of [times] within the [Iterable]. + * + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + */ +infix fun , S : InAnyOrderSearchBehaviour> IterableContains.Builder.exactly( + times: Int +): ExactlyCheckerOption = ExactlyCheckerOptionImpl(times, this) + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we + * are looking for occurs `at least` once but `at most` number of [times] within the [Iterable]. + * + * If you want to use a higher lower bound than one, then use `atLeast(2).butAtMost(3)` instead of `atMost(3)`. + * And in case you want to state that it is either not contained at all or at most a certain number of times, + * then use `notOrAstMost(2)` instead. + * + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + * @throws IllegalArgumentException In case [times] equals to one; use [exactly] instead. + */ +infix fun , S : InAnyOrderSearchBehaviour> IterableContains.Builder.atMost( + times: Int +): AtMostCheckerOption = AtMostCheckerOptionImpl(times, this) + +/** + * Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we + * are looking for occurs `not at all or at most` number of [times] within the [Iterable]. + * + * @param times The number which the check will compare against the actual number of times an expected entry is + * found in the [Iterable]. + * + * @return The newly created builder. + * @throws IllegalArgumentException In case [times] is smaller than zero. + * @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead. + */ +infix fun , S : InAnyOrderSearchBehaviour> IterableContains.Builder.notOrAtMost( + times: Int +): NotOrAtMostCheckerOption = NotOrAtMostCheckerOptionImpl(times, this) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt new file mode 100644 index 000000000..5121c2bcb --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt @@ -0,0 +1,102 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.AssertionPlant +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.CheckerOption +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [expected] + * value shall be searched within the [Iterable]. + * + * Delegates to [values]. + * + * @param expected The value which is expected to be contained within this [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > CheckerOption.value(expected: E): Expect = + this the Values(expected) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the expected [values] + * shall be searched within the [Iterable]. + * + * Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and + * [values].[expected][Values.expected] is defined as `'a'` and one + * [values].[otherExpected][Values.otherExpected] is defined as `'a'` as well, then both match, + * even though they match the same entry. Use an option such as [atLeast], [atMost] and [exactly] to control the + * number of occurrences you expect. + * + * Meaning you might want to use: + * `to contain inAny order exactly 2 value 'a'` + * instead of: + * `to contain inAny order exactly 1 the Values('a', 'a')` + * + * @param values The values which are expected to be contained within the [Iterable]. + * + * @return The [AssertionPlant] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > CheckerOption.the(values: Values): Expect = + addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrder(this, values.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where an entry shall be searched which either + * holds all assertions [assertionCreatorOrNull] creates or needs to be `null` in case [assertionCreatorOrNull] + * is defined as `null`. + * + * Delegates to [entries]. + * + * @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking + * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for + * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > CheckerOption.entry( + assertionCreatorOrNull: (Expect.() -> Unit)? +): Expect = this the Entries(assertionCreatorOrNull) + +/** + * Finishes the specification of the sophisticated `contains` assertion where an entry shall be searched which either + * holds all assertions [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] might create or + * needs to be `null` in case [entries].[assertionCreatorOrNull][Entries.otherAssertionCreatorsOrNulls] + * is defined as `null` -- likewise an entry (can be the same) is searched for each of + * the [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls]. + * + * @param entries The parameter object which contains the identification lambdas. + * + * @return The [AssertionPlant] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > CheckerOption.the( + entries: Entries +): Expect = addAssertion(ExpectImpl.iterable.contains.entriesInAnyOrder(this, entries.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable] + * shall be searched within the [Iterable]. + * + * Delegates to [values] which also means that it does not search for unique matches + * (see [values] for more information). + * + * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). + * + * @since 0.11.0 + */ +inline infix fun > CheckerOption.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return this the Values(first, *rest) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt new file mode 100644 index 000000000..8cfdfa185 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -0,0 +1,121 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the + * [expected] value. + * + * Delegates to [values]. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param expected The value which is expected to be contained within the [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.value(expected: E): Expect = + this the Values(expected) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the expected [values] + * must be contained in [Iterable] but it does not matter in which order. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param values The values which are expected to be contained within the [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.the( + values: Values +): Expect = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrderOnly(this, values.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only one + * entry which holds all assertions created by the given [assertionCreatorOrNull] or is `null` in case + * [assertionCreatorOrNull] is defined as `null`. + * + * Delegates to [entries]. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking + * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for + * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.entry( + assertionCreatorOrNull: (Expect.() -> Unit)? +): Expect = this the Entries(assertionCreatorOrNull) + +/** + * Finishes the specification of the sophisticated `contains` assertion where an entry needs to be contained in the + * [Iterable] which holds all assertions [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] + * might create or it needs to be `null` in case + * [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] is defined as `null` -- likewise an + * entry for each [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls] needs to + * be contained in the [Iterable] where it does not matter in which order the entries appear but only as many entries + * should be returned by the [Iterable] as assertion creators are defined. + * + * Notice, that a first-wins strategy applies which means your assertion creator lambdas -- which kind of serve as + * identification lambdas -- should be ordered in such a way that the most specific identification lambda appears + * first, not that a less specific lambda wins. For instance, given a `setOf(1, 2)` you should not search for + * `Entries({ isGreaterThan(0) }, { toBe(1) })` but for `Entries({ toBe(1) }, { isGreaterThan(0) })` + * otherwise `isGreaterThan(0)` matches `1` before `toBe(1)` would match it. As a consequence `toBe(1)` could + * only match the entry which is left -- in this case `2` -- and of course this would fail. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param entries The parameter object containing the identification lambdas. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ + +infix fun > Builder.the( + entries: Entries +): Expect = addAssertion(ExpectImpl.iterable.contains.entriesInAnyOrderOnly(this, entries.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where all elements in + * [expectedIterable] need to be contained in [Iterable] where it does not matter in which order but only as + * many entries should be returned by the [Iterable] as values defined. + * + * Delegates to [values]. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable] + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). + * + * @since 0.11.0 + */ +inline infix fun > Builder.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return this the Values(first, *rest) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt new file mode 100644 index 000000000..7fce5897c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -0,0 +1,112 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.AssertionPlant +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the + * [expected] value. + * + * Delegates to [values]. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param expected The value which is expected to be contained within the [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.value(expected: E): Expect = + this the Values(expected) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the + * expected [values] in the specified order. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param values The nullable values which are expected to be contained within the [Iterable]. + * + * @return The [AssertionPlant] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.the(values: Values): Expect = + addAssertion(ExpectImpl.iterable.contains.valuesInOrderOnly(this, values.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only a + * single entry which holds all assertions created by the given [assertionCreatorOrNull] or needs to be `null` + * in case [assertionCreatorOrNull] is defined as `null`. + * + * Delegates to `entries(assertionCreatorOrNull)`. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking + * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for + * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.entry( + assertionCreatorOrNull: (Expect.() -> Unit)? +): Expect = this the Entries(assertionCreatorOrNull) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only an + * entry which holds all assertions [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] + * might create or is `null` in case [entries].[assertionCreatorOrNull][Entries.otherAssertionCreatorsOrNulls] + * is defined as `null` and likewise a further entry for each + * [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls] + * (if given) whereas the entries have to appear in the specified order. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param entries The parameter object containing the identification lambdas. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.the( + entries: Entries +): Expect = addAssertion(ExpectImpl.iterable.contains.entriesInOrderOnly(this, entries.toList())) + +/** + * Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable] + * shall be searched within the [Iterable] + * (if given) in the specified order. + * + * Delegates to [values]. + * + * Note that we might change the signature of this function with the next version + * which will cause a binary backward compatibility break (see + * [#292](https://github.com/robstoll/atrium/issues/292) for more information) + * + * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). + * + * @since 0.11.0 + */ +inline infix fun > Builder.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return this the Values(first, *rest) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt new file mode 100644 index 000000000..9177bd1ff --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt @@ -0,0 +1,52 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.builders.utils.groupsToList +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlyGroupedWithinSearchBehaviour +import kotlin.jvm.JvmName + +/** + * Finishes the specification of the sophisticated `contains` assertion where the expected [Order.firstGroup] as well as + * the [Order.secondGroup] and optionally [Order.otherExpectedGroups] of values need to be + * contained in [Iterable] in the specified order whereas the values within the groups can occur in any order. + * + * @param order A parameter object containing the different groups which have to appear in order in the [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +infix fun > Builder.inAny( + order: Order> +): Expect = addAssertion( + ExpectImpl.iterable.contains.valuesInOrderOnlyGrouped( + this, + groupsToList(order.firstGroup, order.secondGroup, order.otherExpectedGroups) + ) +) + +/** + * Finishes the specification of the sophisticated `contains` assertion where the expected [Order.firstGroup] as well as + * the [Order.secondGroup] and optionally [Order.otherExpectedGroups] of identification lambdas, identifying an entry, + * need to be contained in [Iterable] in the specified order whereas the identification lambdas within the groups + * can occur in any order. + * + * An identification lambda can also be defined as `null` in which case it matches an entry which is `null` as well. + * + * @param order A parameter object containing the different groups which have to appear in order in the [Iterable]. + * + * @return The [Expect] for which the assertion was built to support a fluent API. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + */ +@JvmName("inAnyOrderEntries") +infix fun > Builder.inAny( + order: Order<(Expect.() -> Unit)?, Group<(Expect.() -> Unit)?>> +): Expect = addAssertion( + ExpectImpl.iterable.contains.entriesInOrderOnlyGrouped( + this, + groupsToList(order.firstGroup, order.secondGroup, order.otherExpectedGroups) + ) +) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsSearchBehaviours.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsSearchBehaviours.kt new file mode 100644 index 000000000..2be9da282 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsSearchBehaviours.kt @@ -0,0 +1,60 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.* + +/** + * Defines that the search behaviour "find entries `in any order` in the [Iterable]" shall be applied to this + * sophisticated `contains` in [Iterable] assertion. + * + * @return The newly created builder. + */ +infix fun > Builder.inAny(@Suppress("UNUSED_PARAMETER") order: order) = + ExpectImpl.iterable.contains.searchBehaviours.inAnyOrder(this) + +/** + * Defines that the constraint "`only` the specified entries exist in the [Iterable]" shall be applied to this + * sophisticated `contains` [Iterable] assertion. + * + * @return The newly created builder. + */ +infix fun > Builder.but(@Suppress("UNUSED_PARAMETER") only: only) = + ExpectImpl.iterable.contains.searchBehaviours.inAnyOrderOnly(this) + + +/** + * Defines that the search behaviour "find entries `in order` in the [Iterable]" shall be applied to this + * sophisticated `contains` in [Iterable] assertion. + * + * @return The newly created builder. + */ +infix fun > Builder.inGiven(@Suppress("UNUSED_PARAMETER") order: order) = + ExpectImpl.iterable.contains.searchBehaviours.inOrder(this) + +/** + * Defines that the constraint "`only` the specified entries exist in the [Iterable]" shall be applied to this + * sophisticated `contains in order` [Iterable] assertion. + * + * @return The newly created builder. + */ +infix fun > Builder.and(@Suppress("UNUSED_PARAMETER") only: only) = + ExpectImpl.iterable.contains.searchBehaviours.inOrderOnly(this) + +/** + * Defines that the [Iterable] contains `in order only` groups of entries + * whereas the order within the group is specified as next step. + * + * @return The newly created builder. + */ +infix fun > Builder.grouped(@Suppress("UNUSED_PARAMETER") entries: entries) = + ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGrouped(this) + +/** + * A filler word to emphasis that the next step defines the order within expected groups of values. + * + * @return The newly created builder. + */ +infix fun > Builder.within(@Suppress("UNUSED_PARAMETER") group: group) = + ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGroupedWithin(this) + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index d79f93c29..7bc920613 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -59,12 +59,12 @@ object entries : Keyword object group : Keyword /** - * Represents the pseudo keyword `not` as in [contains] `not`. + * Represents the pseudo keyword `next` as in [has] `next`. * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. * * @since 0.11.0 */ -object not : Keyword +object next : Keyword /** * Represents a filler, a pseudo keyword where there isn't really a good keyword. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt index 7aff937a5..fea117a1f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt @@ -1,17 +1,60 @@ -@file:Suppress("DEPRECATION" /** TODO remove suppress with 1.0.0 */) +@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) + package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.assertions.Assertion import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.Group import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries import ch.tutteli.atrium.domain.builders.utils.VarArgHelper +import ch.tutteli.kbox.glue /** * Parameter object to express `T, vararg T`. */ class All(override val expected: T, override vararg val otherExpected: T) : VarArgHelper +/** + * Parameter object to express a [Group] with a single identification lambda. + * + * In case `null` is used for the identification lambda then it is expected that the corresponding entry + * is `null` as well. + * + * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered + * to be identified if it holds all [Assertion]s the lambda creates. + * In case it is defined as `null`, then an entry is identified if it is `null` as well. + */ +class Entry( + val assertionCreatorOrNull: (Expect.() -> Unit)? +) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?> { + override fun toList(): List<(Expect.() -> Unit)?> = listOf(assertionCreatorOrNull) +} + +/** + * Parameter object to express a [Group] of identification lambdas. + * + * It is also used to express `(Expect.() -> Unit)?, vararg (Expect.() -> Unit)?` at other places the infix-api. + * + * In case `null` is used for an identification lambda then it is expected that the corresponding entry + * is `null` as well. + * + * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered + * to be identified if it holds all [Assertion]s the lambda might create. + * In case it is defined as `null`, then an entry is identified if it is `null` as well. + * @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s. + */ +class Entries( + val assertionCreatorOrNull: (Expect.() -> Unit)?, + vararg val otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? +) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?>, + VarArgHelper<(Expect.() -> Unit)?> { + override val expected get() = assertionCreatorOrNull + override val otherExpected get() = otherAssertionCreatorsOrNulls + + override fun toList(): List<(Expect.() -> Unit)?> = assertionCreatorOrNull glue otherAssertionCreatorsOrNulls +} + /** * Parameter object to express a key/value [Pair] whose value type is a nullable lambda with an * [Expect] receiver, which means one can either pass a lambda or `null`. @@ -22,6 +65,18 @@ data class KeyValue(val key: K, val valueAssertionCreatorOrNull: "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" } +//TODO #63 move to iterable and introduce function instead +/** + * Parameter object to express `Group, Group, vararg Group` in the infix-api. + * + * Notice, most probably the type parameter G will be removed in the future, will be fixed to [Group]. + */ +class Order>( + val firstGroup: G, + val secondGroup: G, + vararg val otherExpectedGroups: G +) + /** * Parameter object to express `Pair, vararg Pair`. */ @@ -38,6 +93,13 @@ class RegexPatterns(pattern: String, vararg otherPatterns: String) : VarArgHelpe override val otherExpected = otherPatterns } +/** + * Represents a [Group] with a single value. + */ +data class Value(val expected: T) : GroupWithNullableEntries, GroupWithoutNullableEntries { + override fun toList() = listOf(expected) +} + /** * Represents a [Group] of multiple values. * diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt index 63912e893..d6e811eb2 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt @@ -11,6 +11,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl.changeSubject * * @return The newly created [Expect] for the transformed subject. */ +//TODO #63 use parameter o fun > Expect.asIterable(): Expect> = changeSubject(this).unreported { it.asIterable() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index ea4aecd41..cec21ed26 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -48,7 +48,12 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { a1 contains o atLeast 2 matchFor Regex("bla") a1 contains o atLeast 2 matchFor All(Regex("bla"), Regex("b")) a1 contains o atLeast 2 elementsOf listOf(1, 2) - a1 containsNot o + + a1 containsNot o value "a" + a1 containsNot o the Values("a", 'b') + a1 containsNot o regex "a" + a1 containsNot o the RegexPatterns("a", "bl") + a1 containsNot o elementsOf listOf(1, 2) a1 contains o ignoring case atLeast 1 value "a" a1 contains o ignoring case atLeast 1 the Values("a", 'b') @@ -56,13 +61,19 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { a1 contains o ignoring case atLeast 1 the RegexPatterns("a", "bl") a1 contains o ignoring case atLeast 1 elementsOf listOf(1, 2) + a1 containsNot o ignoring case value "a" + a1 containsNot o ignoring case the Values("a", 'b') + a1 containsNot o ignoring case regex "a" + a1 containsNot o ignoring case the RegexPatterns("a", "bl") + a1 containsNot o ignoring case elementsOf listOf(1, 2) + // skip atLeast a1 contains o ignoring case value "a" a1 contains o ignoring case the Values("a", 'b') a1 contains o ignoring case regex "a" a1 contains o ignoring case the RegexPatterns("a", "bl") - //TODO add to infix as well as fluent - //a1 contains o ignoring case elementsOf listOf(1, 2) + //TODO #422 uncomment + //a1 contains o ignoring case elementsOf listOf("a", 2) a1 and { it contains o atLeast 1 value 1 } a1 and { it contains o atMost 2 the Values("a", 1) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt new file mode 100644 index 000000000..bb4803087 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt @@ -0,0 +1,111 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix +import org.spekframework.spek2.Spek +import kotlin.reflect.KFunction2 + +class IterableAnyAssertionsSpec : Spek({ + include(PredicateSpec) + include(BuilderSpec) + include(ShortcutSpec) + include(SequenceSpec) +}) { + object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( + fun1(Expect>::any), + fun1(Expect>::any).withNullableSuffix(), + "* ", + "[Atrium][Predicate] " + ) + + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( + getContainsPair(), + getContainsNullablePair().withNullableSuffix(), + "* ", + "[Atrium][Builder] " + ) + + object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( + getContainsShortcutPair(), + getContainsNullableShortcutPair().withNullableSuffix(), + "* ", + "[Atrium][Shortcut] " + ) + + object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec( + getContainsSequencePair(), + getContainsNullableSequencePair().withNullableSuffix(), + "* ", + "[Atrium][Sequence] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $atLeast 1 entry" to Companion::containsInAnyOrderEntry + + private fun containsInAnyOrderEntry(expect: Expect>, a: Expect.() -> Unit) = + expect contains o inAny order atLeast 1 entry a + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $atLeast 1 entry" to Companion::containsNullableEntry + + private fun containsNullableEntry(expect: Expect>, a: (Expect.() -> Unit)?) = + expect contains o inAny order atLeast 1 entry a + + private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = + Expect>::contains + + fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntryShortcut + + private fun containsInAnyOrderEntryShortcut(expect: Expect>, a: Expect.() -> Unit) = + expect contains a + + private val containsShortcutNullableFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = + Expect>::contains + + fun getContainsNullableShortcutPair() = + containsShortcutNullableFun.name to Companion::containsNullableEntryShortcut + + private fun containsNullableEntryShortcut( + expect: Expect>, + a: (Expect.() -> Unit)? + ) = expect contains a + + + private fun getContainsSequencePair() = + "asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutFun.name}" to Companion::containsInAnyOrderEntrySequence + + private fun containsInAnyOrderEntrySequence(expect: Expect>, a: Expect.() -> Unit) = + ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable() contains a + + fun getContainsNullableSequencePair() = + "asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutNullableFun.name}" to Companion::containsNullableEntrySequence + + private fun containsNullableEntrySequence( + expect: Expect>, + a: (Expect.() -> Unit)? + ) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable() contains a + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + + var star: Expect> = notImplemented() + + a1 = a1 any {} + a1 = a1 contains {} + + a1b = a1b any {} + a1b = a1b any null + a1b = a1b contains {} + a1b = a1b contains (null as Double?) + + star = star any {} + star = star contains {} + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAssertionsSpec.kt new file mode 100644 index 000000000..b20531ca9 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAssertionsSpec.kt @@ -0,0 +1,39 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import kotlin.reflect.KFunction2 + +class IterableAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAssertionsSpec( + getHasNextPair(), + getHasNotNextPair() +) { + companion object : WithAsciiReporter() { + private val has: KFunction2>, next, Expect>> = Expect>::has + private fun getHasNextPair() = "${has.name} ${next::class.simpleName}" to Companion::hasNext + private fun hasNext(expect: Expect>) = expect has next + + private val hasNot: KFunction2>, next, Expect>> = + Expect>::hasNot + + private fun getHasNotNextPair() = "${hasNot.name} ${next::class.simpleName}" to Companion::hasNotNext + private fun hasNotNext(expect: Expect>) = expect hasNot next + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + var star: Expect> = notImplemented() + + a1 = a1 has next + a1 = a1 hasNot next + + a1b = a1b has next + a1b = a1b hasNot next + + star = star has next + star = star hasNot next + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfAssertionsSpec.kt new file mode 100644 index 000000000..38716fd5e --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfAssertionsSpec.kt @@ -0,0 +1,46 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.verbs.internal.expect +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +class IterableContainsInAnyOrderAtLeast1ElementsOfAssertionsSpec : Spek({ + include(BuilderSpec) + + describe("elementsOf") { + it("passing an empty iterable throws an IllegalArgumentException") { + expect { + expect(listOf(1, 2)) contains o inAny order atLeast 1 elementsOf listOf() + }.toThrow() + } + } +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", + "[Atrium][Builder] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::containsValues + + private fun containsValues( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = expect contains o inAny order atLeast 1 elementsOf listOf(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::containsNullableValues + + private fun containsNullableValues( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = expect contains o inAny order atLeast 1 elementsOf listOf(a, *aX) + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt new file mode 100644 index 000000000..64c153bf9 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt @@ -0,0 +1,75 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import kotlin.reflect.KFunction2 + +class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ + include(BuilderSpec) + include(ShortcutSpec) +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", + "[Atrium][Builder] " + ) + + object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec( + getContainsShortcutPair(), + getContainsNullableShortcutPair(), + "* ", + "[Atrium][Shortcut] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsInAnyOrderEntries + + private fun containsInAnyOrderEntries( + expect: Expect>, + a: Expect.() -> Unit, + aX: Array.() -> Unit> + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a + else expect contains o inAny order atLeast 1 the Entries(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsNullableEntries + + private fun containsNullableEntries( + expect: Expect>, + a: (Expect.() -> Unit)?, + aX: Array.() -> Unit)?> + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a + else expect contains o inAny order atLeast 1 the Entries(a, *aX) + + + private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = + Expect>::contains + + fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntriesShortcut + + private fun containsInAnyOrderEntriesShortcut( + expect: Expect>, + a: Expect.() -> Unit, + aX: Array.() -> Unit> + ): Expect> = + if (aX.isEmpty()) expect contains a + else expect contains Entries(a, *aX) + + private val containsEntriesFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = + Expect>::contains + + fun getContainsNullableShortcutPair() = containsEntriesFun.name to Companion::containsNullableEntriesShortcut + + private fun containsNullableEntriesShortcut( + expect: Expect>, + a: (Expect.() -> Unit)?, + aX: Array.() -> Unit)?> + ): Expect> = + if (aX.isEmpty()) expect contains a + else expect contains Entries(a, *aX) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt new file mode 100644 index 000000000..5e4287e58 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt @@ -0,0 +1,77 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import kotlin.reflect.KFunction2 + +class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ + include(BuilderSpec) + include(ShortcutSpec) +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", + "[Atrium][Builder] " + ) + + object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec( + getContainsShortcutPair(), + getContainsNullableShortcutPair(), + "* ", + "[Atrium][Shortcut] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsValues + + private fun containsValues( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a + else expect contains o inAny order atLeast 1 the Values(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsNullableValues + + private fun containsNullableValues( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a + else expect contains o inAny order atLeast 1 the Values(a, *aX) + + + private val containsFun: KFunction2>, Double, Expect>> = + Expect>::contains + + fun getContainsShortcutPair() = containsFun.name to Companion::containsValuesShortcut + + private fun containsValuesShortcut( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains a + else expect contains Values(a, *aX) + + + private val containsNullableFun: KFunction2>, Double?, Expect>> = + Expect>::contains + + fun getContainsNullableShortcutPair() = containsNullableFun.name to Companion::containsNullableValuesShortcut + + private fun containsNullableValuesShortcut( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains a + else expect contains Values(a, *aX) + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt new file mode 100644 index 000000000..874840e28 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt @@ -0,0 +1,55 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeastValuesAssertionSpec( + getAtLeastTriple(), + getAtLeastButAtMostTriple(), + getContainsNotPair(), + getExactlyPair(), + Companion::getErrorMsgAtLeastButAtMost, + "* " + ) { + + companion object : IterableContainsSpecBase() { + + internal fun getAtLeastTriple() = + { what: String, times: String -> "$contains $what in any order $atLeast $times" } to + ("$contains $filler $inAnyOrder $atLeast" to Companion::containsAtLeast) + + private fun containsAtLeast( + expect: Expect>, + atLeast: Int, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order atLeast atLeast value a + else expect contains o inAny order atLeast atLeast the Values(a, *aX) + + + private fun getAtLeastButAtMostTriple() = + { what: String, timesAtLeast: String, timesAtMost: String -> "$contains $what $atLeast $timesAtLeast $butAtMost $timesAtMost" } to + ("$contains $filler $atLeast $butAtMost" to Companion::containsAtLeastButAtMost) + + private fun containsAtLeastButAtMost( + expect: Expect>, + atLeast: Int, + butAtMost: Int, + a: Double, + aX: Array + ) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the Values(a, *aX) + + private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$atLeast $times`" + + private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly + + private fun getErrorMsgExactly(times: Int) = + "use `$exactly $times` instead of `$atLeast $times $butAtMost $times`" + + internal fun getErrorMsgAtLeastButAtMost(timesAtLeast: Int, timesButAtMost: Int) = + "specifying `$butAtMost $timesButAtMost` does not make sense if `$atLeast $timesAtLeast` was used before" + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt new file mode 100644 index 000000000..db4a379fc --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt @@ -0,0 +1,33 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class IterableContainsInAnyOrderAtMostValuesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtMostValuesAssertionSpec( + getAtMostTriple(), + getContainsNotPair(), + getExactlyPair(), + "* " + ) { + + companion object : IterableContainsSpecBase() { + + private fun getAtMostTriple() = + { what: String, times: String -> "$contains $what $atMost $times" } to + ("$contains $filler $inAnyOrder $atMost" to Companion::containsAtMost) + + private fun containsAtMost(expect: Expect>, atMost: Int, a: Double, aX: Array) = + if(aX.isEmpty()) expect contains o inAny order atMost atMost value a + else expect contains o inAny order atMost atMost the Values(a, *aX) + + + private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$atMost $times`" + + private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly + + private fun getErrorMsgExactly(times: Int) = + "use `$exactly $times` instead of `$atMost $times`; `$atMost $times` defines implicitly `$atLeast $times` as well" + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt new file mode 100644 index 000000000..a3d46500a --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt @@ -0,0 +1,32 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class IterableContainsInAnyOrderExactlyValuesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderExactlyValuesAssertionsSpec( + getExactlyTriple(), + getContainsNotPair(), + "* " + ) { + + companion object : IterableContainsSpecBase() { + + private fun getExactlyTriple() = + { what: String, times: String -> "$contains $what $exactly $times" } to + ("$contains $filler $inAnyOrder $exactly" to Companion::containsExactly) + + private fun containsExactly( + expect: Expect>, + exactly: Int, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order exactly exactly value a + else expect contains o inAny order exactly exactly the Values(a, *aX) + + private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$exactly $times`" + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt new file mode 100644 index 000000000..7743c01c2 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt @@ -0,0 +1,32 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec( + getNotOrAtMostTriple(), + getContainsNotPair(), + "* " + ) { + + companion object : IterableContainsSpecBase() { + + private fun getNotOrAtMostTriple() = + { what: String, times: String -> "$contains $what $notOrAtMost $times" } to + ("$contains $filler $notOrAtMost" to Companion::containsNotOrAtMost) + + private fun containsNotOrAtMost( + expect: Expect>, + atMost: Int, + a: Double, + aX: Array + ) = + if (aX.isEmpty()) expect contains o inAny order notOrAtMost atMost value a + else expect contains o inAny order notOrAtMost atMost the Values(a, *aX) + + private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot + + private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$notOrAtMost $times`" + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfAssertionsSpec.kt new file mode 100644 index 000000000..44caf4220 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfAssertionsSpec.kt @@ -0,0 +1,44 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.verbs.internal.expect +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +class IterableContainsInAnyOrderOnlyElementsOfAssertionSpec : Spek({ + include(BuilderSpec) + + describe("elementsOf") { + it("passing an empty iterable throws an IllegalArgumentException") { + expect { + expect(listOf(1, 2)) contains o inAny order but only elementsOf listOf() + }.toThrow() + } + } +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderOnlyValuesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", "» " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getContainsValues + + private fun getContainsValues( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = expect contains o inAny order but only elementsOf listOf(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getContainsNullableValues + + private fun getContainsNullableValues( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = expect contains o inAny order but only elementsOf listOf(a, *aX) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt new file mode 100644 index 000000000..c583d92c9 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt @@ -0,0 +1,36 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderOnlyEntriesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", "» " + ) { + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::containsInAnyOrderOnlyEntries + + private fun containsInAnyOrderOnlyEntries( + expect: Expect>, + a: Expect.() -> Unit, + aX: Array.() -> Unit> + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order but only entry a + else expect contains o inAny order but only the Entries(a, *aX) + + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::containsInAnyOrderOnlyNullableEntries + + private fun containsInAnyOrderOnlyNullableEntries( + expect: Expect>, + a: (Expect.() -> Unit)?, + aX: Array.() -> Unit)?> + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order but only entry a + else expect contains o inAny order but only the Entries(a, *aX) + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt new file mode 100644 index 000000000..d05d76b9c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt @@ -0,0 +1,36 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect + +class IterableContainsInAnyOrderOnlyValuesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderOnlyValuesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", "(/) ", "(x) ", "(!) ", "- " + ) { + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::containsInAnyOrderOnlyValues + + private fun containsInAnyOrderOnlyValues( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order but only value a + else expect contains o inAny order but only the Values(a, *aX) + + + fun getContainsNullablePair() = + "$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::containsInAnyOrderOnlyNullableValues + + private fun containsInAnyOrderOnlyNullableValues( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inAny order but only value a + else expect contains o inAny order but only the Values(a, *aX) + + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfAssertionSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfAssertionSpec.kt new file mode 100644 index 000000000..3ce54fc7d --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfAssertionSpec.kt @@ -0,0 +1,36 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek + +class IterableContainsInOrderOnlyElementsOfAssertionSpec : Spek({ + include(BuilderSpec) +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyValuesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ", + "[Atrium][Builder] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inOrder $andOnly $inOrderElementsOf" to Companion::containsInOrderOnlyValues + + private fun containsInOrderOnlyValues( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = expect contains o inGiven order and only elementsOf listOf(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inOrder $andOnly $inOrderElementsOf" to Companion::containsInOrderOnlyNullableValues + + private fun containsInOrderOnlyNullableValues( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = expect contains o inGiven order and only elementsOf listOf(a, *aX) + } +} + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt new file mode 100644 index 000000000..04f830a82 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt @@ -0,0 +1,82 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import kotlin.reflect.KFunction2 + +class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ + + include(BuilderSpec) + include(ShortcutSpec) + +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyEntriesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", "» ", ">> ", "=> ", + "[Atrium][Builder] " + ) + + object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyEntriesAssertionsSpec( + getContainsShortcutPair(), + getContainsNullableShortcutPair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", "» ", ">> ", "=> ", + "[Atrium][Shortcut] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnly + + private fun containsInOrderOnly( + expect: Expect>, + a: Expect.() -> Unit, + aX: Array.() -> Unit> + ): Expect> = + if (aX.isEmpty()) expect contains o inGiven order and only entry a + else expect contains o inGiven order and only the Entries(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnlyNullableEntriesPair + + private fun containsInOrderOnlyNullableEntriesPair( + expect: Expect>, + a: (Expect.() -> Unit)?, + aX: Array.() -> Unit)?> + ): Expect> = + if (aX.isEmpty()) expect contains o inGiven order and only entry a + else expect contains o inGiven order and only the Entries(a, *aX) + + private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = + Expect>::containsExactly + + fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyEntriesShortcut + + private fun containsInOrderOnlyEntriesShortcut( + expect: Expect>, + a: Expect.() -> Unit, + aX: Array.() -> Unit> + ): Expect> = + if (aX.isEmpty()) expect containsExactly { a() } + else expect containsExactly Entries(a, *aX) + + private val containsNullableShortcutFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = + Expect>::containsExactly + + fun getContainsNullableShortcutPair() = + containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableEntriesShortcut + + private fun containsInOrderOnlyNullableEntriesShortcut( + expect: Expect>, + a: (Expect.() -> Unit)?, + aX: Array.() -> Unit)?> + ): Expect> = + if (aX.isEmpty()) { + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + if (a == null) expect containsExactly a as Double? + else expect containsExactly { a() } + } else { + expect containsExactly Entries(a, *aX) + } + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt new file mode 100644 index 000000000..b7ad82d1e --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt @@ -0,0 +1,34 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.Group + +class IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec( + getContainsPair(), + Companion::groupFactory, + "* ", "(/) ", "(x) ", "(!) ", "- ", "» ", ">> ", "=> ", + "[Atrium][Builder] " + ) { + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderEntries + + private fun containsInOrderOnlyGroupedInAnyOrderEntries( + expect: Expect>, + a1: Group<(Expect.() -> Unit)?>, + a2: Group<(Expect.() -> Unit)?>, + aX: Array.() -> Unit)?>> + ): Expect> = + expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX) + + private fun groupFactory(groups: Array.() -> Unit)?>) = + when (groups.size) { + 0 -> object : Group<(Expect.() -> Unit)?> { + override fun toList() = listOf.() -> Unit>() + } + 1 -> Entry(groups[0]) + else -> Entries(groups[0], *groups.drop(1).toTypedArray()) + } + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt new file mode 100644 index 000000000..747a725e8 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt @@ -0,0 +1,59 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.Group + +class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyGroupedValuesAssertionsSpec( + getContainsPair(), + Companion::groupFactory, + getContainsNullablePair(), + Companion::nullableGroupFactory, + "* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ", + "[Atrium][Builder] " + ) { + companion object : IterableContainsSpecBase() { + fun getContainsPair() = + "$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderValues + + private fun containsInOrderOnlyGroupedInAnyOrderValues( + expect: Expect>, + a1: Group, + a2: Group, + aX: Array> + ): Expect> { + return expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX) + } + + private fun groupFactory(groups: Array): Group = + when (groups.size) { + 0 -> object : Group { + override fun toList() = listOf() + } + 1 -> Value(groups[0]) + else -> Values(groups[0], *groups.drop(1).toTypedArray()) + } + + + fun getContainsNullablePair() = + "$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderNullableValues + + private fun containsInOrderOnlyGroupedInAnyOrderNullableValues( + expect: Expect>, + a1: Group, + a2: Group, + aX: Array> + ): Expect> { + return expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX) + } + + private fun nullableGroupFactory(groups: Array): Group = + when (groups.size) { + 0 -> object : Group { + override fun toList() = listOf() + } + 1 -> Value(groups[0]) + else -> Values(groups[0], *groups.drop(1).toTypedArray()) + } + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt new file mode 100644 index 000000000..f9ada8952 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt @@ -0,0 +1,77 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import kotlin.reflect.KFunction2 + +class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ + + include(BuilderSpec) + include(ShortcutSpec) + +}) { + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyValuesAssertionsSpec( + getContainsPair(), + getContainsNullablePair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ", + "[Atrium][Builder] " + ) + + object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyValuesAssertionsSpec( + getContainsShortcutPair(), + getContainsNullableShortcutPair(), + "* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ", + "[Atrium][Shortcut] " + ) + + companion object : IterableContainsSpecBase() { + fun getContainsPair() = "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyValues + + private fun containsInOrderOnlyValues( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inGiven order and only value a + else expect contains o inGiven order and only the Values(a, *aX) + + fun getContainsNullablePair() = + "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyNullableValues + + private fun containsInOrderOnlyNullableValues( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect contains o inGiven order and only value a + else expect contains o inGiven order and only the Values(a, *aX) + + private val containsShortcutFun: KFunction2>, Double, Expect>> = + Expect>::containsExactly + + fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyValuesShortcut + + private fun containsInOrderOnlyValuesShortcut( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect containsExactly a + else expect containsExactly Values(a, *aX) + + private val containsNullableShortcutFun: KFunction2>, Double?, Expect>> = + Expect>::containsExactly + + fun getContainsNullableShortcutPair() = + containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableValuesShortcut + + private fun containsInOrderOnlyNullableValuesShortcut( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect containsExactly a + else expect containsExactly Values(a, *aX) + } +} + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt new file mode 100644 index 000000000..4258956b3 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt @@ -0,0 +1,35 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.withNullableSuffix + +class IterableContainsNotEntriesAssertionsSpec : + ch.tutteli.atrium.specs.integration.IterableContainsNotEntriesAssertionsSpec( + getContainsNotPair(), + getContainsNotNullablePair().withNullableSuffix(), + "* ", "(/) ", "(x) ", "- ", "» ", ">> ", "=> ", + "[Atrium][Builder] " + ) { + companion object : IterableContainsSpecBase() { + + private fun getContainsNotPair() = containsNot to Companion::containsNotFun + + private fun containsNotFun( + expect: Expect>, + a: Expect.() -> Unit, + aX: Array.() -> Unit> + ): Expect> = + if (aX.isEmpty()) expect containsNot o entry a + else expect containsNot o the Entries(a, *aX) + + private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun + + private fun containsNotNullableFun( + expect: Expect>, + a: (Expect.() -> Unit)?, + aX: Array.() -> Unit)?> + ): Expect> = + if (aX.isEmpty()) expect containsNot o entry a + else expect containsNot o the Entries(a, *aX) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt new file mode 100644 index 000000000..c4d8c9326 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt @@ -0,0 +1,59 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import org.spekframework.spek2.Spek +import kotlin.reflect.KFunction2 + +class IterableContainsNotValuesAssertionsSpec : Spek({ + + include(BuilderSpec) + include(ShortcutSpec) + +}) { + + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsNotValuesAssertionsSpec( + getContainsNotPair(), + getContainsNotNullablePair(), + "* ", "(/) ", "(x) ", "- ", ">> ", "=> ", + "[Atrium][Builder] " + ) + + object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsNotValuesAssertionsSpec( + getContainsNotShortcutPair(), + getContainsNotNullablePair(), + "* ", "(/) ", "(x) ", "- ", ">> ", "=> ", + "[Atrium][Shortcut] " + ) + + companion object : IterableContainsSpecBase() { + + private fun getContainsNotPair() = containsNot to Companion::containsNotFun + + private fun containsNotFun( + expect: Expect>, + a: Double, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect containsNot o value a + else expect containsNot o the Values(a, *aX) + + private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun + + private fun containsNotNullableFun( + expect: Expect>, + a: Double?, + aX: Array + ): Expect> = + if (aX.isEmpty()) expect containsNot o value a + else expect containsNot o the Values(a, *aX) + + private val containsNotShortcutFun: KFunction2>, Double, Expect>> = + Expect>::containsNot + + private fun getContainsNotShortcutPair() = containsNotShortcutFun.name to Companion::containsNotShortcut + + private fun containsNotShortcut(expect: Expect>, a: Double, aX: Array) = + if (aX.isEmpty()) expect containsNot a + else expect containsNot Values(a, *aX) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt new file mode 100644 index 000000000..fcd19fb32 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt @@ -0,0 +1,324 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains +import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.* +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import kotlin.reflect.KFunction2 + +abstract class IterableContainsSpecBase : WithAsciiReporter() { + protected val Values = Values::class.simpleName + private val Entries = Entries::class.simpleName + + //@formatter:off + protected val atLeast = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::atLeast.name + protected val butAtMost = AtLeastCheckerOption<*, *, InAnyOrderSearchBehaviour>::butAtMost.name + protected val exactly = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::exactly.name + protected val atMost = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::atMost.name + protected val notOrAtMost = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::notOrAtMost.name + protected val inAnyOrder = "${IterableContains.Builder<*, Iterable<*>, NoOpSearchBehaviour>::inAny.name} ${order::class.simpleName}" + protected val butOnly = "${IterableContains.Builder, InAnyOrderSearchBehaviour>::but.name} ${only::class.simpleName}" + private val theInAnyOrderFun: KFunction2, InAnyOrderSearchBehaviour>, Values, Expect>> + = IterableContains.CheckerOption, InAnyOrderSearchBehaviour>::the + private val theInAnyOrder = theInAnyOrderFun.name + protected val inAnyOrderEntries = "$theInAnyOrder $Entries" + protected val inAnyOrderValues = "$theInAnyOrder $Values" + protected val inAnyOrderElementsOf = IterableContains.CheckerOption, InAnyOrderSearchBehaviour>::elementsOf.name + + private val theInAnyOrderOnlyFun: KFunction2, InAnyOrderOnlySearchBehaviour>, Values, Expect>> + = IterableContains.Builder, InAnyOrderOnlySearchBehaviour>::the + private val theInAnyOrderOnly = theInAnyOrderOnlyFun.name + protected val inAnyOrderOnlyValues = "$theInAnyOrderOnly $Values" + protected val inAnyOrderOnlyEntries = "$theInAnyOrderOnly $Entries" + protected val inAnyOrderOnlyElementsOf = IterableContains.Builder, InAnyOrderOnlySearchBehaviour>::elementsOf.name + + protected val inOrder = "${IterableContains.Builder<*, Iterable<*>, NoOpSearchBehaviour>::inGiven.name} ${order::class.simpleName}" + protected val andOnly = "${IterableContains.Builder, InOrderSearchBehaviour>::and.name} ${only::class.simpleName}" + private val theInOrderOnlyFun: KFunction2, InOrderOnlySearchBehaviour>, Values, Expect>> + = IterableContains.Builder, InOrderOnlySearchBehaviour>::the + private val theInOrderOnly = theInOrderOnlyFun.name + protected val inOrderOnlyValues = "$theInOrderOnly $Values" + protected val inOrderOnlyEntries = "$theInOrderOnly $Entries" + protected val inOrderElementsOf = IterableContains.Builder, InOrderOnlySearchBehaviour>::elementsOf.name + protected val grouped = "${IterableContains.Builder<*, *, InOrderOnlySearchBehaviour>::grouped.name} ${entries::class.simpleName}" + protected val within = IterableContains.Builder<*, *, InOrderOnlyGroupedSearchBehaviour>::within.name + private val withinInAnyOrderFun : KFunction2, InOrderOnlyGroupedWithinSearchBehaviour>, Order>, Expect>> + = IterableContains.Builder, InOrderOnlyGroupedWithinSearchBehaviour>::inAny + protected val withinInAnyOrder = withinInAnyOrderFun.name + //@formatter:on + + protected val filler = o::class.simpleName + private val containsProp: KFunction2>, o, IterableContains.Builder, NoOpSearchBehaviour>> = + Expect>::contains + protected val contains = containsProp.name + private val containsNotProp: KFunction2>, o, NotCheckerOption, NotSearchBehaviour>> = + Expect>::containsNot + protected val containsNot = "${containsNotProp.name} $filler $inAnyOrderValues" + + @Suppress("unused") + private fun ambiguityTest() { + val list: Expect> = notImplemented() + val nullableList: Expect> = notImplemented() + val subList: Expect> = notImplemented() + val star: Expect> = notImplemented() + + list contains 1 + list contains 1f + list contains Values(1, 2f) + list contains {} + list contains Entries({}, {}) + list containsNot 1 + list containsNot 1f + list containsNot Values(1, 2f) + list containsNot o entry {} + list containsNot o the Entries({}, {}) + + subList contains 1 + subList contains 1f + subList contains Values(1, 2f) + subList contains {} + subList contains Entries({}, {}) + subList containsNot 1 + subList containsNot 1f + subList containsNot Values(1, 2f) + subList containsNot o entry {} + subList containsNot o the Entries({}, {}) + + nullableList contains 1 + nullableList contains 1f + nullableList contains Values(1, 2f) + nullableList contains {} + nullableList contains Entries({}, {}) + nullableList containsNot 1 + nullableList containsNot 1f + nullableList containsNot Values(1, 2f) + nullableList containsNot o entry {} + nullableList containsNot o the Entries({}, {}) + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + nullableList contains null as Number? + nullableList contains Entries(null, {}) + nullableList contains Entries({}, null) + nullableList contains Entries(null, null) + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + nullableList containsNot null as Number? + nullableList containsNot o the Entries(null, {}) + nullableList containsNot o the Entries({}, null) + nullableList containsNot o the Entries(null, null) + + star contains 1 + star contains 1f + star contains Values(1, 2f) + star contains {} + star contains Entries({}, {}) + star containsNot 1 + star containsNot 1f + star containsNot Values(1, 2f) + star containsNot o entry {} + star containsNot o the Entries({}, {}) + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + star contains (null as Number?) + star contains Entries(null, {}) + star contains Entries({}, null) + star contains Entries(null, null) + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + star containsNot (null as Number?) + star containsNot o the Entries(null, {}) + star containsNot o the Entries({}, null) + star containsNot o the Entries(null, null) + + list containsExactly 1 + list containsExactly Values(1, 2f) + list containsExactly {} + list containsExactly Entries({}, {}) + + subList containsExactly 1 + subList containsExactly Values(1, 2f) + subList containsExactly {} + subList containsExactly Entries({}, {}) + + nullableList containsExactly 1 + nullableList containsExactly Values(1, 2f) + nullableList containsExactly {} + nullableList containsExactly Entries({}, {}) + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + nullableList containsExactly (null as (Expect.() -> Unit)?) + nullableList containsExactly Entries({}, null) + nullableList containsExactly Entries(null, {}) + nullableList containsExactly Entries(null, null) + + star containsExactly 1 + star containsExactly Values(1, 2f) + star containsExactly {} + star containsExactly Entries({}, {}) + //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) + star containsExactly (null as (Expect.() -> Unit)?) + star containsExactly Entries({}, null) + star containsExactly Entries(null, {}) + star containsExactly Entries(null, null) + + list contains o inAny order atLeast 1 value 1 + list contains o inAny order atLeast 1 the Values(2, 1) + list contains o inAny order atLeast 1 entry {} + list contains o inAny order atLeast 1 the Entries({}, {}) + list contains o inAny order atLeast 1 elementsOf listOf(1, 2) + subList contains o inAny order atLeast 1 value 1 + subList contains o inAny order atLeast 1 the Values(2, 1) + subList contains o inAny order atLeast 1 entry {} + subList contains o inAny order atLeast 1 the Entries({}, {}) + subList contains o inAny order atLeast 1 elementsOf listOf(1, 2) + nullableList contains o inAny order atLeast 1 value 1 + nullableList contains o inAny order atLeast 1 the Values(2, 1) + nullableList contains o inAny order atLeast 1 entry {} + nullableList contains o inAny order atLeast 1 the Entries({}, {}) + nullableList contains o inAny order atLeast 1 elementsOf listOf(1, 2) + nullableList contains o inAny order atLeast 1 value null + nullableList contains o inAny order atLeast 1 the Values(null, 1) + nullableList contains o inAny order atLeast 1 the Values(2, null) + nullableList contains o inAny order atLeast 1 the Values(null, null) + nullableList contains o inAny order atLeast 1 entry null + nullableList contains o inAny order atLeast 1 the Entries(null, {}) + nullableList contains o inAny order atLeast 1 the Entries({}, null) + nullableList contains o inAny order atLeast 1 the Entries(null, null) + star contains o inAny order atLeast 1 value 1 + star contains o inAny order atLeast 1 the Values(2, 1) + star contains o inAny order atLeast 1 entry {} + star contains o inAny order atLeast 1 the Entries({}, {}) + star contains o inAny order atLeast 1 elementsOf listOf(1, 2) + star contains o inAny order atLeast 1 value null + star contains o inAny order atLeast 1 the Values(null, 1) + star contains o inAny order atLeast 1 the Values(2, null) + star contains o inAny order atLeast 1 the Values(null, null) + star contains o inAny order atLeast 1 entry null + star contains o inAny order atLeast 1 the Entries(null, {}) + star contains o inAny order atLeast 1 the Entries({}, null) + star contains o inAny order atLeast 1 the Entries(null, null) + + list contains o inAny order but only value 1 + list contains o inAny order but only the Values(2, 1) + list contains o inAny order but only entry {} + list contains o inAny order but only the Entries({}, {}) + list contains o inAny order but only elementsOf listOf(1, 2) + subList contains o inAny order but only value 1 + subList contains o inAny order but only the Values(2, 1) + subList contains o inAny order but only entry {} + subList contains o inAny order but only the Entries({}, {}) + subList contains o inAny order but only elementsOf listOf(1, 2) + nullableList contains o inAny order but only value 1 + nullableList contains o inAny order but only the Values(2, 1) + nullableList contains o inAny order but only entry {} + nullableList contains o inAny order but only the Entries({}, {}) + nullableList contains o inAny order but only elementsOf listOf(1, 2) + nullableList contains o inAny order but only value null + nullableList contains o inAny order but only the Values(null, 1) + nullableList contains o inAny order but only the Values(2, null) + nullableList contains o inAny order but only the Values(null, null) + nullableList contains o inAny order but only entry null + nullableList contains o inAny order but only the Entries(null, {}) + nullableList contains o inAny order but only the Entries({}, null) + nullableList contains o inAny order but only the Entries(null, null) + star contains o inAny order but only value 1 + star contains o inAny order but only the Values(2, 1) + star contains o inAny order but only entry {} + star contains o inAny order but only the Entries({}, {}) + star contains o inAny order but only elementsOf listOf(1, 2) + star contains o inAny order but only value null + star contains o inAny order but only the Values(null, 1) + star contains o inAny order but only the Values(2, null) + star contains o inAny order but only the Values(null, null) + star contains o inAny order but only entry null + star contains o inAny order but only the Entries(null, {}) + star contains o inAny order but only the Entries({}, null) + star contains o inAny order but only the Entries(null, null) + + list contains o inGiven order and only value 1 + list contains o inGiven order and only the Values(2, 1) + list contains o inGiven order and only entry {} + list contains o inGiven order and only the Entries({}, {}) + list contains o inGiven order and only elementsOf listOf(1, 2) + subList contains o inGiven order and only value 1 + subList contains o inGiven order and only the Values(2, 1) + subList contains o inGiven order and only entry {} + subList contains o inGiven order and only the Entries({}, {}) + subList contains o inGiven order and only elementsOf listOf(1, 2) + nullableList contains o inGiven order and only value 1 + nullableList contains o inGiven order and only the Values(2, 1) + nullableList contains o inGiven order and only entry {} + nullableList contains o inGiven order and only the Entries({}, {}) + nullableList contains o inGiven order and only elementsOf listOf(1, 2) + nullableList contains o inGiven order and only value null + nullableList contains o inGiven order and only the Values(null, 1) + nullableList contains o inGiven order and only the Values(2, null) + nullableList contains o inGiven order and only the Values(null, null) + nullableList contains o inGiven order and only entry null + nullableList contains o inGiven order and only the Entries(null, {}) + nullableList contains o inGiven order and only the Entries({}, null) + nullableList contains o inGiven order and only the Entries(null, null) + star contains o inGiven order and only value 1 + star contains o inGiven order and only the Values(2, 1) + star contains o inGiven order and only entry {} + star contains o inGiven order and only the Entries({}, {}) + star contains o inGiven order and only elementsOf listOf(1, 2) + star contains o inGiven order and only value null + star contains o inGiven order and only the Values(null, 1) + star contains o inGiven order and only the Values(2, null) + star contains o inGiven order and only the Values(null, null) + star contains o inGiven order and only entry null + star contains o inGiven order and only the Entries(null, {}) + star contains o inGiven order and only the Entries({}, null) + star contains o inGiven order and only the Entries(null, null) + + list contains o inGiven order and only grouped entries within group inAny Order( + Value(1), + Values(1f), + Values(1f, 1) + ) + subList contains o inGiven order and only grouped entries within group inAny Order( + Value(1), + Values(1f), + Values(1f, 1) + ) + nullableList contains o inGiven order and only grouped entries within group inAny Order( + Value(null), + Values(null), + Values(null, 2), + Values(1, null), + Values(null, null) + ) + star contains o inGiven order and only grouped entries within group inAny Order( + Value(null), + Values(null), + Values(null, 2), + Values(1, null), + Values(null, null) + ) + + list contains o inGiven order and only grouped entries within group inAny Order( + Entry {}, + Entries({}), + Entries({}, {}) + ) + subList contains o inGiven order and only grouped entries within group inAny Order( + Entry {}, + Entries({}), + Entries({}, {}) + ) + nullableList contains o inGiven order and only grouped entries within group inAny Order( + Entry(null), + Entries(null), + Entries(null, {}), + Entries({}, null), + Entries(null, null) + ) + star contains o inGiven order and only grouped entries within group inAny Order( + Entry(null), + Entries(null), + Entries(null, {}), + Entries({}, null), + Entries(null, null) + ) + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableFeatureAssertionsSpec.kt new file mode 100644 index 000000000..4810a1f10 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableFeatureAssertionsSpec.kt @@ -0,0 +1,36 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.feature1 +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.name +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter + +class IterableFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableFeatureAssertionsSpec( + minFeaturePair(), + fun1, Expect.() -> Unit>(Expect>::min), + maxFeaturePair(), + fun1, Expect.() -> Unit>(Expect>::max) +) { + companion object : WithAsciiReporter() { + private fun minFeaturePair() = feature1, o, Int>(Expect>::min).name to ::minFeature + private fun minFeature(expect: Expect>) = expect min o + + private fun maxFeaturePair() = feature1, o, Int>(Expect>::min).name to ::maxFeature + private fun maxFeature(expect: Expect>) = expect max o + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + //nullable not supported by min/max or rather T : Comparable does not exist for T? (one cannot implement an interface for the nullable type) + //same for Iterable<*> + + a1 min o toBe 2 + a1 max o toBe 3 + + a1 = a1 min { } + a1 = a1 max { } + } +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt new file mode 100644 index 000000000..4362c6532 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt @@ -0,0 +1,60 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withNullableSuffix +import org.spekframework.spek2.Spek + +class IterableNoneAssertionsSpec : Spek({ + + include(PredicateSpec) + include(BuilderSpec) + +}) { + object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableNoneAssertionsSpec( + fun1(Expect>::none), + fun1(Expect>::none).withNullableSuffix(), + "* ", "(/) ", "(x) ", "- ", "» ", ">> ", "=> ", + "[Atrium][Predicate] " + ) + + object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableNoneAssertionsSpec( + getContainsNotPair(), + getContainsNotNullablePair().withNullableSuffix(), + "* ", "(/) ", "(x) ", "- ", "» ", ">> ", "=> ", + "[Atrium][Builder] " + ) + + companion object : IterableContainsSpecBase() { + + private fun getContainsNotPair() = containsNot to Companion::containsNotFun + + private fun containsNotFun(expect: Expect>, a: Expect.() -> Unit) = + expect containsNot o entry a + + private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun + + private fun containsNotNullableFun(expect: Expect>, a: (Expect.() -> Unit)?) = + expect containsNot o entry a + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + + var star: Expect> = notImplemented() + + a1 = a1.none {} + a1 = a1 containsNot o entry {} + + a1b = a1b.none {} + a1b = a1b.none(null) + a1b = a1b containsNot o entry {} + a1b = a1b containsNot o entry (null) + + star = star.none {} + star = star containsNot o entry {} + } +} diff --git a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt index 0c795e12c..8a37d7fd8 100644 --- a/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt +++ b/domain/builders/atrium-domain-builders-common/src/main/kotlin/ch/tutteli/atrium/domain/builders/utils/VarArgHelper.kt @@ -11,6 +11,7 @@ interface VarArgHelper { * The first argument in the argument list `T, vararg T` */ val expected: T + /** * The second argument in the argument list `T, vararg T` */ From 92bd97f5e583e0a60891279e97e3f7ed7db96239 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 3 Apr 2020 21:58:08 +0200 Subject: [PATCH 122/142] turn `as...` fun into infix fun with the help of `o` --- .../atrium/api/infix/en_GB/mapAssertions.kt | 7 +++-- .../api/infix/en_GB/sequenceAssertions.kt | 12 ++++---- .../infix/en_GB/IterableAnyAssertionsSpec.kt | 4 +-- .../infix/en_GB/IterableNoneAssertionsSpec.kt | 6 ++-- .../infix/en_GB/MapAsEntriesAssertionsSpec.kt | 28 +++++++++++++------ 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index 0ca4cb5f0..87b1933a3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -172,8 +172,9 @@ infix fun > Expect.values(assertionCreator: Expect> Expect.asEntries(): Expect>> = - ExpectImpl.changeSubject(this).unreported { it.entries } +infix fun > Expect.asEntries( + @Suppress("UNUSED_PARAMETER") o: o +): Expect>> = ExpectImpl.changeSubject(this).unreported { it.entries } /** * Turns `Expect>` into `Expect>>` and expects that it holds all assertions the given @@ -186,5 +187,5 @@ fun > Expect.asEntries(): Expect> */ infix fun > Expect.asEntries( assertionCreator: Expect>>.() -> Unit -): Expect = apply { asEntries().addAssertionsCreatedBy(assertionCreator) } +): Expect = apply { asEntries(o).addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt index d6e811eb2..e0bfb2a98 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/sequenceAssertions.kt @@ -7,22 +7,22 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl.changeSubject * Turns `Expect>` into `Expect>`. * * The transformation as such is not reflected in reporting. - * Use `feature(Sequence::asIterable)` if you want to show the transformation in reporting. + * Use `feature { f(it::asIterable) }` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. */ -//TODO #63 use parameter o -fun > Expect.asIterable(): Expect> = - changeSubject(this).unreported { it.asIterable() } +infix fun > Expect.asIterable( + @Suppress("UNUSED_PARAMETER") o: o +): Expect> = changeSubject(this).unreported { it.asIterable() } /** * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for * the subject as [Iterable]. * * The transformation as such is not reflected in reporting. - * Use `feature(Sequence::asIterable, assertionCreator)` if you want to show the transformation in reporting. + * Use `feature of({ f(it::asIterable) }, assertionCreator)` if you want to show the transformation in reporting. * * @return An [Expect] for the current subject of the assertion. */ infix fun > Expect.asIterable(assertionCreator: Expect>.() -> Unit): Expect = - apply { asIterable().addAssertionsCreatedBy(assertionCreator) } + apply { asIterable(o).addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt index bb4803087..03d3584ed 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyAssertionsSpec.kt @@ -79,7 +79,7 @@ class IterableAnyAssertionsSpec : Spek({ "asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutFun.name}" to Companion::containsInAnyOrderEntrySequence private fun containsInAnyOrderEntrySequence(expect: Expect>, a: Expect.() -> Unit) = - ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable() contains a + ExpectImpl.changeSubject(expect).unreported { it.asSequence() } asIterable o contains a fun getContainsNullableSequencePair() = "asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutNullableFun.name}" to Companion::containsNullableEntrySequence @@ -87,7 +87,7 @@ class IterableAnyAssertionsSpec : Spek({ private fun containsNullableEntrySequence( expect: Expect>, a: (Expect.() -> Unit)? - ) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable() contains a + ) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() } asIterable o contains a } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt index 4362c6532..887c35b60 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneAssertionsSpec.kt @@ -49,10 +49,10 @@ class IterableNoneAssertionsSpec : Spek({ a1 = a1.none {} a1 = a1 containsNot o entry {} - a1b = a1b.none {} - a1b = a1b.none(null) + a1b = a1b none {} + a1b = a1b none null a1b = a1b containsNot o entry {} - a1b = a1b containsNot o entry (null) + a1b = a1b containsNot o entry null star = star.none {} star = star containsNot o entry {} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt index 1e6bced3d..55fe45a82 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAsEntriesAssertionsSpec.kt @@ -1,14 +1,24 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.feature0 +import ch.tutteli.atrium.specs.feature1 import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter -object MapAsEntriesAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAsEntriesAssertionsSpec( - feature0, Set>>(Expect>::asEntries), +class MapAsEntriesAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAsEntriesAssertionsSpec( + asEntriesPair(), fun1, Expect>>.() -> Unit>(Expect>::asEntries) ) { + + companion object : WithAsciiReporter() { + fun asEntriesPair() = + feature1, o, Set>>(Expect>::asEntries).name to ::asEntriesFeature + + fun asEntriesFeature(expect: Expect>) = expect asEntries o + } + @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { var map: Expect> = notImplemented() @@ -21,12 +31,12 @@ object MapAsEntriesAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAsEnt var starKeyMap: Expect> = notImplemented() var starValueMap: Expect> = notImplemented() - map asEntries {} - subMap asEntries {} - nullableKeyMap asEntries {} - nullableValueMap asEntries {} - nullableKeyValueMap asEntries {} - readOnlyNullableKeyValueMap asEntries {} + map asEntries o + subMap asEntries o + nullableKeyMap asEntries o + nullableValueMap asEntries o + nullableKeyValueMap asEntries o + readOnlyNullableKeyValueMap asEntries o map = map asEntries {} subMap = subMap asEntries {} From a44b71325ef50d83ce7a85f1ea41bb2b3fc8aacd Mon Sep 17 00:00:00 2001 From: Ivan Fedorov Date: Fri, 3 Apr 2020 23:08:05 +0300 Subject: [PATCH 123/142] PR #421. Remove since tags --- .../tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt index decd75a04..c917bb4ab 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/bigDecimalAssertions.kt @@ -49,7 +49,6 @@ infix fun Expect.toBe(expected: T): Nothing = throw PleaseU * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.11.0 */ @JvmName("toBeNull") infix fun Expect.toBe(expected: Nothing?): Expect = @@ -92,7 +91,6 @@ infix fun Expect.notToBe(expected: T): Nothing = throw Pleas * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.11.0 */ infix fun Expect.isNumericallyEqualTo(expected: T) = addAssertion(ExpectImpl.bigDecimal.isNumericallyEqualTo(this, expected)) @@ -112,7 +110,6 @@ infix fun Expect.isNumericallyEqualTo(expected: T) = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.11.0 */ infix fun Expect.isNotNumericallyEqualTo(expected: T) = addAssertion(ExpectImpl.bigDecimal.isNotNumericallyEqualTo(this, expected)) @@ -130,7 +127,6 @@ infix fun Expect.isNotNumericallyEqualTo(expected: T) = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.11.0 */ infix fun Expect.isEqualIncludingScale(expected: T) = addAssertion(ExpectImpl.bigDecimal.isEqualIncludingScale(this, expected, this::isNumericallyEqualTo.name)) @@ -147,7 +143,6 @@ infix fun Expect.isEqualIncludingScale(expected: T) = * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * - * @since 0.11.0 */ infix fun Expect.isNotEqualIncludingScale(expected: T) = addAssertion(ExpectImpl.bigDecimal.isNotEqualIncludingScale(this, expected)) From 3354dcec926517ce127a3924081198d07d813acf Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 3 Apr 2020 22:13:53 +0200 Subject: [PATCH 124/142] move parameterObjects to package creating, Windows-case-file-name-issue The problem with keeping it in api.infix.en_GB is that we will generate to class files with the same name in the sense of Windows case insensitive file names. For instance - open.class - Open.class That's a bummer. However, we want to use functions instead of the data classes anyway (see #342) thus we are good to go --- .../api/infix/en_GB/charSequenceAssertions.kt | 3 + .../en_GB/charSequenceContainsCreators.kt | 3 + .../atrium/api/infix/en_GB/creating/All.kt | 9 + .../api/infix/en_GB/creating/Entries.kt | 35 ++ .../atrium/api/infix/en_GB/creating/Entry.kt | 25 ++ .../atrium/api/infix/en_GB/creating/Pairs.kt | 11 + .../atrium/api/infix/en_GB/creating/Value.kt | 14 + .../atrium/api/infix/en_GB/creating/Values.kt | 21 + .../creating/charsequence/RegexPatterns.kt | 12 + .../impl/nameContainsNotFun.kt | 2 +- .../infix/en_GB/creating/iterable/Order.kt | 15 + .../builders/impl/nameContainsNotFun.kt | 2 +- .../api/infix/en_GB/creating/map/KeyValue.kt | 13 + .../api/infix/en_GB/iterableAssertions.kt | 2 + .../iterableContainsInAnyOrderCreators.kt | 6 +- .../iterableContainsInAnyOrderOnlyCreators.kt | 6 +- .../iterableContainsInOrderOnlyCreators.kt | 6 +- ...rableContainsInOrderOnlyGroupedCreators.kt | 1 + .../atrium/api/infix/en_GB/mapAssertions.kt | 3 + .../api/infix/en_GB/parameterObjects.kt | 114 ----- .../api/infix/en_GB/throwableAssertions.kt | 1 + ...arSequenceContainsAtLeastAssertionsSpec.kt | 26 +- ...harSequenceContainsAtMostAssertionsSpec.kt | 11 +- ...quenceContainsContainsNotAssertionsSpec.kt | 21 +- ...arSequenceContainsExactlyAssertionsSpec.kt | 11 +- .../CharSequenceContainsNotAssertionsSpec.kt | 11 +- ...quenceContainsNotOrAtMostAssertionsSpec.kt | 11 +- ...CharSequenceContainsRegexAssertionsSpec.kt | 47 +- .../en_GB/CharSequenceContainsSpecBase.kt | 71 ++- ...InAnyOrderAtLeast1EntriesAssertionsSpec.kt | 14 +- ...sInAnyOrderAtLeast1ValuesAssertionsSpec.kt | 20 +- ...nsInAnyOrderAtLeastValuesAssertionsSpec.kt | 10 +- ...insInAnyOrderAtMostValuesAssertionsSpec.kt | 5 +- ...nsInAnyOrderExactlyValuesAssertionsSpec.kt | 5 +- ...AnyOrderNotOrAtMostValuesAssertionsSpec.kt | 5 +- ...ainsInAnyOrderOnlyEntriesAssertionsSpec.kt | 10 +- ...tainsInAnyOrderOnlyValuesAssertionsSpec.kt | 10 +- ...ontainsInOrderOnlyEntriesAssertionsSpec.kt | 20 +- ...InOrderOnlyGroupedEntriesAssertionsSpec.kt | 13 +- ...sInOrderOnlyGroupedValuesAssertionsSpec.kt | 24 +- ...ContainsInOrderOnlyValuesAssertionsSpec.kt | 20 +- ...terableContainsNotEntriesAssertionsSpec.kt | 10 +- ...IterableContainsNotValuesAssertionsSpec.kt | 15 +- .../infix/en_GB/IterableContainsSpecBase.kt | 407 +++++++++++++----- .../api/infix/en_GB/MapAssertionsSpec.kt | 352 ++++++++++++--- .../infix/en_GB/ThrowableAssertionsSpec.kt | 12 +- 46 files changed, 1092 insertions(+), 373 deletions(-) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt delete mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt index 59b75e47d..c4ebdf2a0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -2,6 +2,9 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.NotCheckerOptionImpl +import ch.tutteli.atrium.api.infix.en_GB.creating.All +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt index 2922782f1..b0f2bb5d3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -1,5 +1,8 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.All +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt new file mode 100644 index 000000000..1007bc9ec --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt @@ -0,0 +1,9 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.domain.builders.utils.VarArgHelper + +/** + * Parameter object to express `T, vararg T`. + */ +class All(override val expected: T, override vararg val otherExpected: T) : + VarArgHelper diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt new file mode 100644 index 000000000..589ce301c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt @@ -0,0 +1,35 @@ +@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries +import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries +import ch.tutteli.atrium.domain.builders.utils.VarArgHelper +import ch.tutteli.kbox.glue + +/** + * Parameter object to express a [Group] of identification lambdas. + * + * It is also used to express `(Expect.() -> Unit)?, vararg (Expect.() -> Unit)?` at other places the infix-api. + * + * In case `null` is used for an identification lambda then it is expected that the corresponding entry + * is `null` as well. + * + * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered + * to be identified if it holds all [Assertion]s the lambda might create. + * In case it is defined as `null`, then an entry is identified if it is `null` as well. + * @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s. + */ +class Entries( + val assertionCreatorOrNull: (Expect.() -> Unit)?, + vararg val otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? +) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, + GroupWithNullableEntries<(Expect.() -> Unit)?>, + VarArgHelper<(Expect.() -> Unit)?> { + override val expected get() = assertionCreatorOrNull + override val otherExpected get() = otherAssertionCreatorsOrNulls + + override fun toList(): List<(Expect.() -> Unit)?> = assertionCreatorOrNull glue otherAssertionCreatorsOrNulls +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt new file mode 100644 index 000000000..b2fbe423c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt @@ -0,0 +1,25 @@ +@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries +import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries + +/** + * Parameter object to express a [Group] with a single identification lambda. + * + * In case `null` is used for the identification lambda then it is expected that the corresponding entry + * is `null` as well. + * + * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered + * to be identified if it holds all [Assertion]s the lambda creates. + * In case it is defined as `null`, then an entry is identified if it is `null` as well. + */ +class Entry( + val assertionCreatorOrNull: (Expect.() -> Unit)? +) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, + GroupWithNullableEntries<(Expect.() -> Unit)?> { + override fun toList(): List<(Expect.() -> Unit)?> = listOf(assertionCreatorOrNull) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt new file mode 100644 index 000000000..8c6f14338 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt @@ -0,0 +1,11 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.domain.builders.utils.VarArgHelper + +/** + * Parameter object to express `Pair, vararg Pair`. + */ +class Pairs( + override val expected: Pair, + override vararg val otherExpected: Pair +) : VarArgHelper> diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt new file mode 100644 index 000000000..8f2a0bace --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt @@ -0,0 +1,14 @@ +@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries +import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries + +/** + * Represents a [Group] with a single value. + */ +data class Value(val expected: T) : GroupWithNullableEntries, + GroupWithoutNullableEntries { + override fun toList() = listOf(expected) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt new file mode 100644 index 000000000..399032287 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt @@ -0,0 +1,21 @@ +@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) + +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.domain.builders.utils.Group +import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries +import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries +import ch.tutteli.atrium.domain.builders.utils.VarArgHelper + +/** + * Represents a [Group] of multiple values. + * + * Note, [Values] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) + */ +//TODO remove `out` with Kotlin 1.4 (most likely with Atrium 1.0.0) +class Values( + override val expected: T, + override vararg val otherExpected: T +) : GroupWithoutNullableEntries, GroupWithNullableEntries, VarArgHelper { + override fun toList() = listOf(expected, *otherExpected) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt new file mode 100644 index 000000000..7654dbd2b --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt @@ -0,0 +1,12 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence + +import ch.tutteli.atrium.domain.builders.utils.VarArgHelper + +/** + * Parameter object to express `String, vararg String` in the infix-api. + */ +class RegexPatterns(pattern: String, vararg otherPatterns: String) : + VarArgHelper { + override val expected = pattern + override val otherExpected = otherPatterns +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt index 0f790779f..0a6dd1b2d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt @@ -1,6 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl -import ch.tutteli.atrium.api.infix.en_GB.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.containsNot import ch.tutteli.atrium.creating.Expect import kotlin.reflect.KFunction2 diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt new file mode 100644 index 000000000..0c6f8ee33 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt @@ -0,0 +1,15 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.iterable + +import ch.tutteli.atrium.domain.builders.utils.Group + +//TODO #63 introduce function in addition +/** + * Parameter object to express `Group, Group, vararg Group` in the infix-api. + * + * Notice, most probably the type parameter G will be removed in the future, will be fixed to [Group]. + */ +class Order>( + val firstGroup: G, + val secondGroup: G, + vararg val otherExpectedGroups: G +) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt index 50f3ad833..80cdb7a4a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt @@ -1,6 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl -import ch.tutteli.atrium.api.infix.en_GB.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.containsNot import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption import ch.tutteli.atrium.api.infix.en_GB.o diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt new file mode 100644 index 000000000..f3591604c --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating.map + +import ch.tutteli.atrium.creating.Expect + +/** + * Parameter object to express a key/value [Pair] whose value type is a nullable lambda with an + * [Expect] receiver, which means one can either pass a lambda or `null`. + */ +data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { + fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull + override fun toString(): String = + "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt index c0e5879b1..39543e339 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Entries import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.NotCheckerOptionImpl import ch.tutteli.atrium.creating.Expect diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt index 5121c2bcb..be66c6fa7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Entries import ch.tutteli.atrium.creating.AssertionPlant import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -61,7 +63,9 @@ infix fun > CheckerOption.th */ infix fun > CheckerOption.entry( assertionCreatorOrNull: (Expect.() -> Unit)? -): Expect = this the Entries(assertionCreatorOrNull) +): Expect = this the Entries( + assertionCreatorOrNull +) /** * Finishes the specification of the sophisticated `contains` assertion where an entry shall be searched which either diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt index 8cfdfa185..dbe494ec5 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Entries import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion @@ -62,7 +64,9 @@ infix fun > Builder.the( */ infix fun > Builder.entry( assertionCreatorOrNull: (Expect.() -> Unit)? -): Expect = this the Entries(assertionCreatorOrNull) +): Expect = this the Entries( + assertionCreatorOrNull +) /** * Finishes the specification of the sophisticated `contains` assertion where an entry needs to be contained in the diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt index 7fce5897c..3707c43ba 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Entries import ch.tutteli.atrium.creating.AssertionPlant import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -62,7 +64,9 @@ infix fun > Builder.the(val */ infix fun > Builder.entry( assertionCreatorOrNull: (Expect.() -> Unit)? -): Expect = this the Entries(assertionCreatorOrNull) +): Expect = this the Entries( + assertionCreatorOrNull +) /** * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only an diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt index 9177bd1ff..577a7fc67 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index 87b1933a3..2758f3f7f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -1,6 +1,9 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.All +import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyValue import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyWithCreator +import ch.tutteli.atrium.api.infix.en_GB.creating.Pairs import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt deleted file mode 100644 index fea117a1f..000000000 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/parameterObjects.kt +++ /dev/null @@ -1,114 +0,0 @@ -@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) - -package ch.tutteli.atrium.api.infix.en_GB - -import ch.tutteli.atrium.assertions.Assertion -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.domain.builders.utils.Group -import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries -import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries -import ch.tutteli.atrium.domain.builders.utils.VarArgHelper -import ch.tutteli.kbox.glue - -/** - * Parameter object to express `T, vararg T`. - */ -class All(override val expected: T, override vararg val otherExpected: T) : VarArgHelper - -/** - * Parameter object to express a [Group] with a single identification lambda. - * - * In case `null` is used for the identification lambda then it is expected that the corresponding entry - * is `null` as well. - * - * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered - * to be identified if it holds all [Assertion]s the lambda creates. - * In case it is defined as `null`, then an entry is identified if it is `null` as well. - */ -class Entry( - val assertionCreatorOrNull: (Expect.() -> Unit)? -) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?> { - override fun toList(): List<(Expect.() -> Unit)?> = listOf(assertionCreatorOrNull) -} - -/** - * Parameter object to express a [Group] of identification lambdas. - * - * It is also used to express `(Expect.() -> Unit)?, vararg (Expect.() -> Unit)?` at other places the infix-api. - * - * In case `null` is used for an identification lambda then it is expected that the corresponding entry - * is `null` as well. - * - * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered - * to be identified if it holds all [Assertion]s the lambda might create. - * In case it is defined as `null`, then an entry is identified if it is `null` as well. - * @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s. - */ -class Entries( - val assertionCreatorOrNull: (Expect.() -> Unit)?, - vararg val otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? -) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?>, - VarArgHelper<(Expect.() -> Unit)?> { - override val expected get() = assertionCreatorOrNull - override val otherExpected get() = otherAssertionCreatorsOrNulls - - override fun toList(): List<(Expect.() -> Unit)?> = assertionCreatorOrNull glue otherAssertionCreatorsOrNulls -} - -/** - * Parameter object to express a key/value [Pair] whose value type is a nullable lambda with an - * [Expect] receiver, which means one can either pass a lambda or `null`. - */ -data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { - fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull - override fun toString(): String = - "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" -} - -//TODO #63 move to iterable and introduce function instead -/** - * Parameter object to express `Group, Group, vararg Group` in the infix-api. - * - * Notice, most probably the type parameter G will be removed in the future, will be fixed to [Group]. - */ -class Order>( - val firstGroup: G, - val secondGroup: G, - vararg val otherExpectedGroups: G -) - -/** - * Parameter object to express `Pair, vararg Pair`. - */ -class Pairs( - override val expected: Pair, - override vararg val otherExpected: Pair -) : VarArgHelper> - -/** - * Parameter object to express `String, vararg String` in the infix-api. - */ -class RegexPatterns(pattern: String, vararg otherPatterns: String) : VarArgHelper { - override val expected = pattern - override val otherExpected = otherPatterns -} - -/** - * Represents a [Group] with a single value. - */ -data class Value(val expected: T) : GroupWithNullableEntries, GroupWithoutNullableEntries { - override fun toList() = listOf(expected) -} - -/** - * Represents a [Group] of multiple values. - * - * Note, [Values] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) - */ -//TODO remove `out` with Kotlin 1.4 (most likely with Atrium 1.0.0) -class Values( - override val expected: T, - override vararg val otherExpected: T -) : GroupWithoutNullableEntries, GroupWithNullableEntries, VarArgHelper { - override fun toList() = listOf(expected, *otherExpected) -} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt index c44a293e6..ed7c5f5ae 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index 74e664bbf..3f6247c86 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect import org.spekframework.spek2.Spek @@ -59,7 +60,10 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ): Expect = if (aX.isEmpty()) expect contains o atLeast atLeast value a - else expect contains o atLeast atLeast the Values(a, *aX) + else expect contains o atLeast atLeast the Values( + a, + *aX + ) internal fun getAtLeastElementsOfTriple() = atLeastDescr to ("$contains o $atLeast" to Companion::containsAtLeastElementsOf) @@ -88,8 +92,14 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ if (atLeast == 1) expect contains o ignoring case value a else expect contains o ignoring case atLeast atLeast value a } else { - if (atLeast == 1) expect contains o ignoring case the Values(a, *aX) - else expect contains o ignoring case atLeast atLeast the Values(a, *aX) + if (atLeast == 1) expect contains o ignoring case the Values( + a, + *aX + ) + else expect contains o ignoring case atLeast atLeast the Values( + a, + *aX + ) } private fun getAtLeastIgnoringCaseElementsOfTriple() = @@ -129,7 +139,10 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atLeast atLeast butAtMost butAtMost value a - else expect contains o atLeast atLeast butAtMost butAtMost the Values(a, *aX) + else expect contains o atLeast atLeast butAtMost butAtMost the Values( + a, + *aX + ) private val atLeastButAtMostIgnoringCaseDescr = { what: String, timesAtLeast: String, timesAtMost: String -> "$contains $ignoringCase $what $atLeast $timesAtLeast $butAtMost $timesAtMost" @@ -146,7 +159,10 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case atLeast atLeast butAtMost butAtMost value a - else expect contains o ignoring case atLeast atLeast butAtMost butAtMost the Values(a, *aX) + else expect contains o ignoring case atLeast atLeast butAtMost butAtMost the Values( + a, + *aX + ) private fun getAtLeastButAtMostIgnoringCaseElementsOfTriple() = atLeastButAtMostIgnoringCaseDescr to ("$contains o $ignoringCase $atLeast $butAtMost" to Companion::containsAtLeastButAtMostIgnoringCaseElementsOf) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt index ad05a8949..5ad778dd8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect @@ -20,7 +21,10 @@ class CharSequenceContainsAtMostAssertionsSpec : private fun containsAtMost(expect: Expect, atMost: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o atMost atMost value a - else expect contains o atMost atMost the Values(a, *aX) + else expect contains o atMost atMost the Values( + a, + *aX + ) private fun getAtMostIgnoringCaseTriple() = { what: String, times: String -> "$contains $ignoringCase $what $atMost $times" } to @@ -28,7 +32,10 @@ class CharSequenceContainsAtMostAssertionsSpec : private fun containsAtMostIgnoringCase(expect: Expect, atMost: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o ignoring case atMost atMost value a - else expect contains o ignoring case atMost atMost the Values(a, *aX) + else expect contains o ignoring case atMost atMost the Values( + a, + *aX + ) private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index a2af35ca0..f3382cb16 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented @@ -27,23 +28,35 @@ class CharSequenceContainsContainsNotAssertionsSpec : Spek({ private fun containsBuilder(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o atLeast 1 value a - else expect contains o atLeast 1 the Values(a, *aX) + else expect contains o atLeast 1 the Values( + a, + *aX + ) private fun getContainsNotPair() = "$containsNot o $atLeast 1 value/the Values" to Companion::containsNotBuilder private fun containsNotBuilder(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the Values(a, *aX) + else expect containsNot o the Values( + a, + *aX + ) private fun getContainsShortcutPair() = fun2>(Companion::contains) private fun getContainsNotShortcutPair() = fun2>(Companion::containsNot) private fun contains(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect contains a - else expect contains Values(a, *aX) + else expect contains Values( + a, + *aX + ) private fun containsNot(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot a - else expect containsNot Values(a, *aX) + else expect containsNot Values( + a, + *aX + ) } @Suppress("unused", "UNUSED_VALUE") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt index 0cdcd4ae7..ade0c8665 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect class CharSequenceContainsExactlyAssertionsSpec : @@ -18,7 +19,10 @@ class CharSequenceContainsExactlyAssertionsSpec : private fun containsExactly(expect: Expect, exactly: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o exactly exactly value a - else expect contains o exactly exactly the Values(a, *aX) + else expect contains o exactly exactly the Values( + a, + *aX + ) private fun getExactlyIgnoringCaseTriple() = { what: String, times: String -> "$contains $ignoringCase $what $exactly $times" } to @@ -32,7 +36,10 @@ class CharSequenceContainsExactlyAssertionsSpec : aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case exactly exactly value a - else expect contains o ignoring case exactly exactly the Values(a, *aX) + else expect contains o ignoring case exactly exactly the Values( + a, + *aX + ) private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot private fun getErrorMsgContainsNot(times: Int) = "use `$containsNotValues` instead of `$exactly $times`" diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt index 00562a552..42b02cdeb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsNotAssertionsSpec( @@ -16,7 +17,10 @@ class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integratio private fun containsNotFun(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the Values(a, *aX) + else expect containsNot o the Values( + a, + *aX + ) private fun getContainsNotIgnoringCaseTriple() = { what: String -> "$containsNotValues $ignoringCase $what" } to @@ -24,6 +28,9 @@ class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integratio private fun containsNotIgnoringCase(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot o ignoring case value a - else expect containsNot o ignoring case the Values(a, *aX) + else expect containsNot o ignoring case the Values( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt index 954ba37cc..85686d070 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect class CharSequenceContainsNotOrAtMostAssertionsSpec : @@ -18,7 +19,10 @@ class CharSequenceContainsNotOrAtMostAssertionsSpec : private fun containsNotOrAtMost(expect: Expect, atMost: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o notOrAtMost atMost value a - else expect contains o notOrAtMost atMost the Values(a, *aX) + else expect contains o notOrAtMost atMost the Values( + a, + *aX + ) private fun getNotOrAtMostIgnoringCaseTriple() = { what: String, times: String -> "$contains $ignoringCase $what $notOrAtMost $times" } to @@ -31,7 +35,10 @@ class CharSequenceContainsNotOrAtMostAssertionsSpec : aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case notOrAtMost atMost value a - else expect contains o ignoring case notOrAtMost atMost the Values(a, *aX) + else expect contains o ignoring case notOrAtMost atMost the Values( + a, + *aX + ) private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt index 3b4d48db5..47b91cda3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.All +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns import ch.tutteli.atrium.creating.Expect import org.spekframework.spek2.Spek @@ -48,11 +50,17 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atLeast atLeast regex a - else expect contains o atLeast atLeast the RegexPatterns(a, *aX) + else expect contains o atLeast atLeast the RegexPatterns( + a, + *aX + ) private fun containsAtLeastRegex(expect: Expect, atLeast: Int, a: String, aX: Array) = if (aX.isEmpty()) expect contains o atLeast atLeast matchFor Regex(a) - else expect contains o atLeast atLeast matchFor All(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) + else expect contains o atLeast atLeast matchFor All( + Regex(a), + *aX.map { it.toRegex() }.toTypedArray() + ) private fun getAtLeastIgnoringCaseTripleString() = { what: String, times: String -> "$contains $ignoringCase $what $atLeast $times" } to @@ -68,8 +76,14 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ if (atLeast == 1) expect contains o ignoring case regex a else expect contains o ignoring case atLeast atLeast regex a } else { - if (atLeast == 1) expect contains o ignoring case the RegexPatterns(a, *aX) - else expect contains o ignoring case atLeast atLeast the RegexPatterns(a, *aX) + if (atLeast == 1) expect contains o ignoring case the RegexPatterns( + a, + *aX + ) + else expect contains o ignoring case atLeast atLeast the RegexPatterns( + a, + *aX + ) } private fun getShortcutTripleString() = @@ -86,7 +100,10 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect containsRegex a - else expect containsRegex RegexPatterns(a, *aX) + else expect containsRegex RegexPatterns( + a, + *aX + ) private fun containsShortcutRegex( expect: Expect, @@ -94,7 +111,10 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains Regex(a) - else expect contains All(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) + else expect contains All( + Regex(a), + *aX.map { it.toRegex() }.toTypedArray() + ) private fun getAtMostTripleString() = @@ -112,7 +132,10 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atMost atMost regex a - else expect contains o atMost atMost the RegexPatterns(a, *aX) + else expect contains o atMost atMost the RegexPatterns( + a, + *aX + ) private fun getAtMostIgnoringCaseTripleString() = { what: String, times: String -> "$contains $ignoringCase $what $atMost $times" } to @@ -125,7 +148,10 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atMost atMost matchFor Regex(a) - else expect contains o atMost atMost matchFor All(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) + else expect contains o atMost atMost matchFor All( + Regex(a), + *aX.map { it.toRegex() }.toTypedArray() + ) private fun containsAtMostIgnoringCase( expect: Expect, @@ -134,6 +160,9 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case atMost atMost regex a - else expect contains o ignoring case atMost atMost the RegexPatterns(a, *aX) + else expect contains o ignoring case atMost atMost the RegexPatterns( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index cec21ed26..ccfde8573 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -2,6 +2,9 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption +import ch.tutteli.atrium.api.infix.en_GB.creating.All +import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour @@ -42,45 +45,87 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { val a1: Expect = notImplemented() a1 contains o atLeast 1 value 1 - a1 contains o atMost 2 the Values("a", 1) + a1 contains o atMost 2 the Values( + "a", + 1 + ) a1 contains o notOrAtMost 2 regex "h|b" - a1 contains o exactly 2 the RegexPatterns("h|b", "b") + a1 contains o exactly 2 the RegexPatterns( + "h|b", + "b" + ) a1 contains o atLeast 2 matchFor Regex("bla") - a1 contains o atLeast 2 matchFor All(Regex("bla"), Regex("b")) + a1 contains o atLeast 2 matchFor All( + Regex("bla"), + Regex("b") + ) a1 contains o atLeast 2 elementsOf listOf(1, 2) a1 containsNot o value "a" a1 containsNot o the Values("a", 'b') a1 containsNot o regex "a" - a1 containsNot o the RegexPatterns("a", "bl") + a1 containsNot o the RegexPatterns( + "a", + "bl" + ) a1 containsNot o elementsOf listOf(1, 2) a1 contains o ignoring case atLeast 1 value "a" - a1 contains o ignoring case atLeast 1 the Values("a", 'b') + a1 contains o ignoring case atLeast 1 the Values( + "a", + 'b' + ) a1 contains o ignoring case atLeast 1 regex "a" - a1 contains o ignoring case atLeast 1 the RegexPatterns("a", "bl") + a1 contains o ignoring case atLeast 1 the RegexPatterns( + "a", + "bl" + ) a1 contains o ignoring case atLeast 1 elementsOf listOf(1, 2) a1 containsNot o ignoring case value "a" - a1 containsNot o ignoring case the Values("a", 'b') + a1 containsNot o ignoring case the Values( + "a", + 'b' + ) a1 containsNot o ignoring case regex "a" - a1 containsNot o ignoring case the RegexPatterns("a", "bl") + a1 containsNot o ignoring case the RegexPatterns( + "a", + "bl" + ) a1 containsNot o ignoring case elementsOf listOf(1, 2) // skip atLeast a1 contains o ignoring case value "a" - a1 contains o ignoring case the Values("a", 'b') + a1 contains o ignoring case the Values( + "a", + 'b' + ) a1 contains o ignoring case regex "a" - a1 contains o ignoring case the RegexPatterns("a", "bl") + a1 contains o ignoring case the RegexPatterns( + "a", + "bl" + ) //TODO #422 uncomment //a1 contains o ignoring case elementsOf listOf("a", 2) a1 and { it contains o atLeast 1 value 1 } - a1 and { it contains o atMost 2 the Values("a", 1) } + a1 and { it contains o atMost 2 the Values( + "a", + 1 + ) + } a1 and { it contains o notOrAtMost 2 regex "h|b" } - a1 and { it contains o exactly 2 the RegexPatterns("h|b", "b") } + a1 and { it contains o exactly 2 the RegexPatterns( + "h|b", + "b" + ) + } a1 and { it contains o atLeast 2 matchFor Regex("bla") } - a1 and { it contains o atLeast 2 matchFor All(Regex("bla"), Regex("b")) } + a1 and { it contains o atLeast 2 matchFor All( + Regex("bla"), + Regex("b") + ) + } a1 and { it contains o atLeast 2 elementsOf listOf(1, 2) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt index 64c153bf9..8d706bd04 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt @@ -32,7 +32,10 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a - else expect contains o inAny order atLeast 1 the Entries(a, *aX) + else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) fun getContainsNullablePair() = "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsNullableEntries @@ -43,7 +46,10 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a - else expect contains o inAny order atLeast 1 the Entries(a, *aX) + else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = @@ -57,7 +63,7 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains Entries(a, *aX) + else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(a, *aX) private val containsEntriesFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = Expect>::contains @@ -70,6 +76,6 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains Entries(a, *aX) + else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt index 5e4287e58..28c6dc6ae 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt @@ -32,7 +32,10 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a - else expect contains o inAny order atLeast 1 the Values(a, *aX) + else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) fun getContainsNullablePair() = "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsNullableValues @@ -43,7 +46,10 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a - else expect contains o inAny order atLeast 1 the Values(a, *aX) + else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private val containsFun: KFunction2>, Double, Expect>> = @@ -57,7 +63,10 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains Values(a, *aX) + else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private val containsNullableFun: KFunction2>, Double?, Expect>> = @@ -71,7 +80,10 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains Values(a, *aX) + else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt index 874840e28..652c28703 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt @@ -25,7 +25,10 @@ class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast atLeast value a - else expect contains o inAny order atLeast atLeast the Values(a, *aX) + else expect contains o inAny order atLeast atLeast the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private fun getAtLeastButAtMostTriple() = @@ -38,7 +41,10 @@ class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec : butAtMost: Int, a: Double, aX: Array - ) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the Values(a, *aX) + ) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt index db4a379fc..34b10897c 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt @@ -18,7 +18,10 @@ class IterableContainsInAnyOrderAtMostValuesAssertionsSpec : private fun containsAtMost(expect: Expect>, atMost: Int, a: Double, aX: Array) = if(aX.isEmpty()) expect contains o inAny order atMost atMost value a - else expect contains o inAny order atMost atMost the Values(a, *aX) + else expect contains o inAny order atMost atMost the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt index a3d46500a..ec91974cf 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt @@ -22,7 +22,10 @@ class IterableContainsInAnyOrderExactlyValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order exactly exactly value a - else expect contains o inAny order exactly exactly the Values(a, *aX) + else expect contains o inAny order exactly exactly the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt index 7743c01c2..383053336 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt @@ -22,7 +22,10 @@ class IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec : aX: Array ) = if (aX.isEmpty()) expect contains o inAny order notOrAtMost atMost value a - else expect contains o inAny order notOrAtMost atMost the Values(a, *aX) + else expect contains o inAny order notOrAtMost atMost the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt index c583d92c9..11ea329aa 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt @@ -18,7 +18,10 @@ class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec : aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only entry a - else expect contains o inAny order but only the Entries(a, *aX) + else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) fun getContainsNullablePair() = @@ -30,7 +33,10 @@ class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec : aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only entry a - else expect contains o inAny order but only the Entries(a, *aX) + else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt index d05d76b9c..2587a4d12 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt @@ -18,7 +18,10 @@ class IterableContainsInAnyOrderOnlyValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only value a - else expect contains o inAny order but only the Values(a, *aX) + else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) fun getContainsNullablePair() = @@ -30,7 +33,10 @@ class IterableContainsInAnyOrderOnlyValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only value a - else expect contains o inAny order but only the Values(a, *aX) + else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt index 04f830a82..5a9b69917 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt @@ -34,7 +34,10 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only entry a - else expect contains o inGiven order and only the Entries(a, *aX) + else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) fun getContainsNullablePair() = "$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnlyNullableEntriesPair @@ -45,7 +48,10 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only entry a - else expect contains o inGiven order and only the Entries(a, *aX) + else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = Expect>::containsExactly @@ -58,7 +64,10 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect containsExactly { a() } - else expect containsExactly Entries(a, *aX) + else expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) private val containsNullableShortcutFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = Expect>::containsExactly @@ -76,7 +85,10 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ if (a == null) expect containsExactly a as Double? else expect containsExactly { a() } } else { - expect containsExactly Entries(a, *aX) + expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt index b7ad82d1e..90d17fbc8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Entry +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.Group @@ -20,7 +22,11 @@ class IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec : a2: Group<(Expect.() -> Unit)?>, aX: Array.() -> Unit)?>> ): Expect> = - expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX) + expect contains o inGiven order and only grouped entries within group inAny Order( + a1, + a2, + *aX + ) private fun groupFactory(groups: Array.() -> Unit)?>) = when (groups.size) { @@ -28,7 +34,10 @@ class IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec : override fun toList() = listOf.() -> Unit>() } 1 -> Entry(groups[0]) - else -> Entries(groups[0], *groups.drop(1).toTypedArray()) + else -> ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + groups[0], + *groups.drop(1).toTypedArray() + ) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt index 747a725e8..30d74cd99 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt @@ -1,5 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order +import ch.tutteli.atrium.api.infix.en_GB.creating.Value import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.Group @@ -22,7 +24,11 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : a2: Group, aX: Array> ): Expect> { - return expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX) + return expect contains o inGiven order and only grouped entries within group inAny Order( + a1, + a2, + *aX + ) } private fun groupFactory(groups: Array): Group = @@ -31,7 +37,10 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : override fun toList() = listOf() } 1 -> Value(groups[0]) - else -> Values(groups[0], *groups.drop(1).toTypedArray()) + else -> ch.tutteli.atrium.api.infix.en_GB.creating.Values( + groups[0], + *groups.drop(1).toTypedArray() + ) } @@ -44,7 +53,11 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : a2: Group, aX: Array> ): Expect> { - return expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX) + return expect contains o inGiven order and only grouped entries within group inAny Order( + a1, + a2, + *aX + ) } private fun nullableGroupFactory(groups: Array): Group = @@ -53,7 +66,10 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : override fun toList() = listOf() } 1 -> Value(groups[0]) - else -> Values(groups[0], *groups.drop(1).toTypedArray()) + else -> ch.tutteli.atrium.api.infix.en_GB.creating.Values( + groups[0], + *groups.drop(1).toTypedArray() + ) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt index f9ada8952..ca9d910da 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt @@ -33,7 +33,10 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only value a - else expect contains o inGiven order and only the Values(a, *aX) + else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) fun getContainsNullablePair() = "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyNullableValues @@ -44,7 +47,10 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only value a - else expect contains o inGiven order and only the Values(a, *aX) + else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private val containsShortcutFun: KFunction2>, Double, Expect>> = Expect>::containsExactly @@ -57,7 +63,10 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsExactly a - else expect containsExactly Values(a, *aX) + else expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private val containsNullableShortcutFun: KFunction2>, Double?, Expect>> = Expect>::containsExactly @@ -71,7 +80,10 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsExactly a - else expect containsExactly Values(a, *aX) + else expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt index 4258956b3..a8233c5e3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt @@ -20,7 +20,10 @@ class IterableContainsNotEntriesAssertionsSpec : aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect containsNot o entry a - else expect containsNot o the Entries(a, *aX) + else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun @@ -30,6 +33,9 @@ class IterableContainsNotEntriesAssertionsSpec : aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect containsNot o entry a - else expect containsNot o the Entries(a, *aX) + else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt index c4d8c9326..a77c304f7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt @@ -35,7 +35,10 @@ class IterableContainsNotValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the Values(a, *aX) + else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun @@ -45,7 +48,10 @@ class IterableContainsNotValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the Values(a, *aX) + else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) private val containsNotShortcutFun: KFunction2>, Double, Expect>> = Expect>::containsNot @@ -54,6 +60,9 @@ class IterableContainsNotValuesAssertionsSpec : Spek({ private fun containsNotShortcut(expect: Expect>, a: Double, aX: Array) = if (aX.isEmpty()) expect containsNot a - else expect containsNot Values(a, *aX) + else expect containsNot ch.tutteli.atrium.api.infix.en_GB.creating.Values( + a, + *aX + ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt index fcd19fb32..221e040cf 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt @@ -1,5 +1,9 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values +import ch.tutteli.atrium.api.infix.en_GB.creating.Entry +import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order +import ch.tutteli.atrium.api.infix.en_GB.creating.Value import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption import ch.tutteli.atrium.creating.Expect @@ -11,8 +15,8 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import kotlin.reflect.KFunction2 abstract class IterableContainsSpecBase : WithAsciiReporter() { - protected val Values = Values::class.simpleName - private val Entries = Entries::class.simpleName + protected val Values = ch.tutteli.atrium.api.infix.en_GB.creating.Values::class.simpleName + private val Entries = ch.tutteli.atrium.api.infix.en_GB.creating.Entries::class.simpleName //@formatter:off protected val atLeast = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::atLeast.name @@ -70,206 +74,397 @@ abstract class IterableContainsSpecBase : WithAsciiReporter() { list contains 1f list contains Values(1, 2f) list contains {} - list contains Entries({}, {}) + list contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) list containsNot 1 list containsNot 1f list containsNot Values(1, 2f) list containsNot o entry {} - list containsNot o the Entries({}, {}) + list containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) subList contains 1 subList contains 1f subList contains Values(1, 2f) subList contains {} - subList contains Entries({}, {}) + subList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) subList containsNot 1 subList containsNot 1f subList containsNot Values(1, 2f) subList containsNot o entry {} - subList containsNot o the Entries({}, {}) + subList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) nullableList contains 1 nullableList contains 1f nullableList contains Values(1, 2f) nullableList contains {} - nullableList contains Entries({}, {}) + nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) nullableList containsNot 1 nullableList containsNot 1f - nullableList containsNot Values(1, 2f) + nullableList containsNot Values( + 1, + 2f + ) nullableList containsNot o entry {} - nullableList containsNot o the Entries({}, {}) + nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) nullableList contains null as Number? - nullableList contains Entries(null, {}) - nullableList contains Entries({}, null) - nullableList contains Entries(null, null) + nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) + nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) + nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) nullableList containsNot null as Number? - nullableList containsNot o the Entries(null, {}) - nullableList containsNot o the Entries({}, null) - nullableList containsNot o the Entries(null, null) + nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) star contains 1 star contains 1f star contains Values(1, 2f) star contains {} - star contains Entries({}, {}) + star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) star containsNot 1 star containsNot 1f star containsNot Values(1, 2f) star containsNot o entry {} - star containsNot o the Entries({}, {}) + star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) star contains (null as Number?) - star contains Entries(null, {}) - star contains Entries({}, null) - star contains Entries(null, null) + star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) + star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) + star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) star containsNot (null as Number?) - star containsNot o the Entries(null, {}) - star containsNot o the Entries({}, null) - star containsNot o the Entries(null, null) + star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) + star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) + star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) list containsExactly 1 list containsExactly Values(1, 2f) list containsExactly {} - list containsExactly Entries({}, {}) + list containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) subList containsExactly 1 subList containsExactly Values(1, 2f) subList containsExactly {} - subList containsExactly Entries({}, {}) + subList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) nullableList containsExactly 1 - nullableList containsExactly Values(1, 2f) + nullableList containsExactly Values( + 1, + 2f + ) nullableList containsExactly {} - nullableList containsExactly Entries({}, {}) + nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) nullableList containsExactly (null as (Expect.() -> Unit)?) - nullableList containsExactly Entries({}, null) - nullableList containsExactly Entries(null, {}) - nullableList containsExactly Entries(null, null) + nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) star containsExactly 1 star containsExactly Values(1, 2f) star containsExactly {} - star containsExactly Entries({}, {}) + star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) star containsExactly (null as (Expect.() -> Unit)?) - star containsExactly Entries({}, null) - star containsExactly Entries(null, {}) - star containsExactly Entries(null, null) + star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) + star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) + star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) list contains o inAny order atLeast 1 value 1 - list contains o inAny order atLeast 1 the Values(2, 1) + list contains o inAny order atLeast 1 the Values( + 2, + 1 + ) list contains o inAny order atLeast 1 entry {} - list contains o inAny order atLeast 1 the Entries({}, {}) + list contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) list contains o inAny order atLeast 1 elementsOf listOf(1, 2) subList contains o inAny order atLeast 1 value 1 - subList contains o inAny order atLeast 1 the Values(2, 1) + subList contains o inAny order atLeast 1 the Values( + 2, + 1 + ) subList contains o inAny order atLeast 1 entry {} - subList contains o inAny order atLeast 1 the Entries({}, {}) + subList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) subList contains o inAny order atLeast 1 elementsOf listOf(1, 2) nullableList contains o inAny order atLeast 1 value 1 - nullableList contains o inAny order atLeast 1 the Values(2, 1) + nullableList contains o inAny order atLeast 1 the Values( + 2, + 1 + ) nullableList contains o inAny order atLeast 1 entry {} - nullableList contains o inAny order atLeast 1 the Entries({}, {}) + nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) nullableList contains o inAny order atLeast 1 elementsOf listOf(1, 2) nullableList contains o inAny order atLeast 1 value null - nullableList contains o inAny order atLeast 1 the Values(null, 1) - nullableList contains o inAny order atLeast 1 the Values(2, null) - nullableList contains o inAny order atLeast 1 the Values(null, null) + nullableList contains o inAny order atLeast 1 the Values( + null, + 1 + ) + nullableList contains o inAny order atLeast 1 the Values( + 2, + null + ) + nullableList contains o inAny order atLeast 1 the Values( + null, + null + ) nullableList contains o inAny order atLeast 1 entry null - nullableList contains o inAny order atLeast 1 the Entries(null, {}) - nullableList contains o inAny order atLeast 1 the Entries({}, null) - nullableList contains o inAny order atLeast 1 the Entries(null, null) + nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) star contains o inAny order atLeast 1 value 1 - star contains o inAny order atLeast 1 the Values(2, 1) + star contains o inAny order atLeast 1 the Values( + 2, + 1 + ) star contains o inAny order atLeast 1 entry {} - star contains o inAny order atLeast 1 the Entries({}, {}) + star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) star contains o inAny order atLeast 1 elementsOf listOf(1, 2) star contains o inAny order atLeast 1 value null - star contains o inAny order atLeast 1 the Values(null, 1) - star contains o inAny order atLeast 1 the Values(2, null) - star contains o inAny order atLeast 1 the Values(null, null) + star contains o inAny order atLeast 1 the Values( + null, + 1 + ) + star contains o inAny order atLeast 1 the Values( + 2, + null + ) + star contains o inAny order atLeast 1 the Values( + null, + null + ) star contains o inAny order atLeast 1 entry null - star contains o inAny order atLeast 1 the Entries(null, {}) - star contains o inAny order atLeast 1 the Entries({}, null) - star contains o inAny order atLeast 1 the Entries(null, null) + star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) list contains o inAny order but only value 1 - list contains o inAny order but only the Values(2, 1) + list contains o inAny order but only the Values( + 2, + 1 + ) list contains o inAny order but only entry {} - list contains o inAny order but only the Entries({}, {}) + list contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) list contains o inAny order but only elementsOf listOf(1, 2) subList contains o inAny order but only value 1 - subList contains o inAny order but only the Values(2, 1) + subList contains o inAny order but only the Values( + 2, + 1 + ) subList contains o inAny order but only entry {} - subList contains o inAny order but only the Entries({}, {}) + subList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) subList contains o inAny order but only elementsOf listOf(1, 2) nullableList contains o inAny order but only value 1 - nullableList contains o inAny order but only the Values(2, 1) + nullableList contains o inAny order but only the Values( + 2, + 1 + ) nullableList contains o inAny order but only entry {} - nullableList contains o inAny order but only the Entries({}, {}) + nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) nullableList contains o inAny order but only elementsOf listOf(1, 2) nullableList contains o inAny order but only value null - nullableList contains o inAny order but only the Values(null, 1) - nullableList contains o inAny order but only the Values(2, null) - nullableList contains o inAny order but only the Values(null, null) + nullableList contains o inAny order but only the Values( + null, + 1 + ) + nullableList contains o inAny order but only the Values( + 2, + null + ) + nullableList contains o inAny order but only the Values( + null, + null + ) nullableList contains o inAny order but only entry null - nullableList contains o inAny order but only the Entries(null, {}) - nullableList contains o inAny order but only the Entries({}, null) - nullableList contains o inAny order but only the Entries(null, null) + nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) star contains o inAny order but only value 1 - star contains o inAny order but only the Values(2, 1) + star contains o inAny order but only the Values( + 2, + 1 + ) star contains o inAny order but only entry {} - star contains o inAny order but only the Entries({}, {}) + star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) star contains o inAny order but only elementsOf listOf(1, 2) star contains o inAny order but only value null - star contains o inAny order but only the Values(null, 1) - star contains o inAny order but only the Values(2, null) - star contains o inAny order but only the Values(null, null) + star contains o inAny order but only the Values( + null, + 1 + ) + star contains o inAny order but only the Values( + 2, + null + ) + star contains o inAny order but only the Values( + null, + null + ) star contains o inAny order but only entry null - star contains o inAny order but only the Entries(null, {}) - star contains o inAny order but only the Entries({}, null) - star contains o inAny order but only the Entries(null, null) + star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) list contains o inGiven order and only value 1 - list contains o inGiven order and only the Values(2, 1) + list contains o inGiven order and only the Values( + 2, + 1 + ) list contains o inGiven order and only entry {} - list contains o inGiven order and only the Entries({}, {}) + list contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) list contains o inGiven order and only elementsOf listOf(1, 2) subList contains o inGiven order and only value 1 - subList contains o inGiven order and only the Values(2, 1) + subList contains o inGiven order and only the Values( + 2, + 1 + ) subList contains o inGiven order and only entry {} - subList contains o inGiven order and only the Entries({}, {}) + subList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) subList contains o inGiven order and only elementsOf listOf(1, 2) nullableList contains o inGiven order and only value 1 - nullableList contains o inGiven order and only the Values(2, 1) + nullableList contains o inGiven order and only the Values( + 2, + 1 + ) nullableList contains o inGiven order and only entry {} - nullableList contains o inGiven order and only the Entries({}, {}) + nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) nullableList contains o inGiven order and only elementsOf listOf(1, 2) nullableList contains o inGiven order and only value null - nullableList contains o inGiven order and only the Values(null, 1) - nullableList contains o inGiven order and only the Values(2, null) - nullableList contains o inGiven order and only the Values(null, null) + nullableList contains o inGiven order and only the Values( + null, + 1 + ) + nullableList contains o inGiven order and only the Values( + 2, + null + ) + nullableList contains o inGiven order and only the Values( + null, + null + ) nullableList contains o inGiven order and only entry null - nullableList contains o inGiven order and only the Entries(null, {}) - nullableList contains o inGiven order and only the Entries({}, null) - nullableList contains o inGiven order and only the Entries(null, null) + nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) star contains o inGiven order and only value 1 - star contains o inGiven order and only the Values(2, 1) + star contains o inGiven order and only the Values( + 2, + 1 + ) star contains o inGiven order and only entry {} - star contains o inGiven order and only the Entries({}, {}) + star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + {}) star contains o inGiven order and only elementsOf listOf(1, 2) star contains o inGiven order and only value null - star contains o inGiven order and only the Values(null, 1) - star contains o inGiven order and only the Values(2, null) - star contains o inGiven order and only the Values(null, null) + star contains o inGiven order and only the Values( + null, + 1 + ) + star contains o inGiven order and only the Values( + 2, + null + ) + star contains o inGiven order and only the Values( + null, + null + ) star contains o inGiven order and only entry null - star contains o inGiven order and only the Entries(null, {}) - star contains o inGiven order and only the Entries({}, null) - star contains o inGiven order and only the Entries(null, null) + star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + {}) + star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + {}, + null + ) + star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( + null, + null + ) list contains o inGiven order and only grouped entries within group inAny Order( Value(1), @@ -298,27 +493,27 @@ abstract class IterableContainsSpecBase : WithAsciiReporter() { list contains o inGiven order and only grouped entries within group inAny Order( Entry {}, - Entries({}), - Entries({}, {}) + ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) ) subList contains o inGiven order and only grouped entries within group inAny Order( Entry {}, - Entries({}), - Entries({}, {}) + ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) ) nullableList contains o inGiven order and only grouped entries within group inAny Order( Entry(null), - Entries(null), - Entries(null, {}), - Entries({}, null), - Entries(null, null) + ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) ) star contains o inGiven order and only grouped entries within group inAny Order( Entry(null), - Entries(null), - Entries(null, {}), - Entries({}, null), - Entries(null, null) + ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null), + ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index 1de6996c0..88a60ee72 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -1,5 +1,8 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.All +import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyValue +import ch.tutteli.atrium.api.infix.en_GB.creating.Pairs import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments import ch.tutteli.atrium.specs.* @@ -29,7 +32,10 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( return if (otherPairs.isEmpty()) { expect contains (pair.first to pair.second) } else { - expect contains Pairs(pair, *otherPairs) + expect contains Pairs( + pair, + *otherPairs + ) } } @@ -42,7 +48,10 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( return if (otherPairs.isEmpty()) { expect contains (pair.first to pair.second) } else { - expect contains Pairs(pair, *otherPairs) + expect contains Pairs( + pair, + *otherPairs + ) } } @@ -53,10 +62,21 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( otherKeyValues: Array.() -> Unit>> ): Expect> { return if (otherKeyValues.isEmpty()) { - expect contains KeyValue(keyValue.first, keyValue.second) + expect contains KeyValue( + keyValue.first, + keyValue.second + ) } else { - mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect contains All(first, *others) + mapArguments(keyValue, otherKeyValues).to { + KeyValue( + it.first, + it.second + ) + }.let { (first, others) -> + expect contains All( + first, + *others + ) } } } @@ -68,10 +88,21 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( otherKeyValues: Array.() -> Unit)?>> ): Expect> { return if (otherKeyValues.isEmpty()) { - expect contains KeyValue(keyValue.first, keyValue.second) + expect contains KeyValue( + keyValue.first, + keyValue.second + ) } else { - mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) -> - expect contains All(first, *others) + mapArguments(keyValue, otherKeyValues).to { + KeyValue( + it.first, + it.second + ) + }.let { (first, others) -> + expect contains All( + first, + *others + ) } } } @@ -109,120 +140,299 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( map contains (1 to "a") map contains Pairs(1 to "a", 2 to "b") map contains KeyValue(1) {} - map contains All(KeyValue(1) {}, KeyValue(2) {}) + map contains All( + KeyValue(1) {}, + KeyValue(2) {}) map contains Pairs(1.0 to StringBuilder("a")) - map contains Pairs(12f to "a", 2L to StringBuilder("b")) + map contains Pairs( + 12f to "a", + 2L to StringBuilder("b") + ) map contains KeyValue(1) {} - map contains All(KeyValue(1) {}, KeyValue(2) {}) + map contains All( + KeyValue(1) {}, + KeyValue(2) {}) subMap contains (1 to "a") subMap contains Pairs(1 to "a", 2 to "b") subMap contains KeyValue(1) {} - subMap contains All(KeyValue(1) {}, KeyValue(2) {}) + subMap contains All( + KeyValue(1) {}, + KeyValue(2) {}) subMap contains (1.0 to StringBuilder("a")) - subMap contains Pairs(12f to "a", 2L to StringBuilder("b")) + subMap contains Pairs( + 12f to "a", + 2L to StringBuilder("b") + ) subMap contains KeyValue(1) {} - subMap contains All(KeyValue(1) {}, KeyValue(2) {}) + subMap contains All( + KeyValue(1) {}, + KeyValue(2) {}) nullableKeyMap contains (1 to "a") - nullableKeyMap contains Pairs(1 to "a", 2 to "b") + nullableKeyMap contains Pairs( + 1 to "a", + 2 to "b" + ) nullableKeyMap contains KeyValue(1) {} - nullableKeyMap contains All(KeyValue(1) {}, KeyValue(2) {}) + nullableKeyMap contains All( + KeyValue(1) {}, + KeyValue(2) {}) nullableKeyMap contains (null to "a") - nullableKeyMap contains Pairs(null to "a", null to "b") - nullableKeyMap contains Pairs(null to "a", 2 to "b") + nullableKeyMap contains Pairs( + null to "a", + null to "b" + ) + nullableKeyMap contains Pairs( + null to "a", + 2 to "b" + ) nullableKeyMap contains (KeyValue(null) {}) - nullableKeyMap contains All(KeyValue(null) {}, KeyValue(null) {}) - nullableKeyMap contains All(KeyValue(null) {}, KeyValue(2) {}) + nullableKeyMap contains All( + KeyValue(null) {}, + KeyValue(null) {}) + nullableKeyMap contains All( + KeyValue(null) {}, + KeyValue(2) {}) nullableValueMap contains (1 to "a") - nullableValueMap contains Pairs(1 to "a", 2 to "b") + nullableValueMap contains Pairs( + 1 to "a", + 2 to "b" + ) nullableValueMap contains KeyValue(1) {} - nullableValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + nullableValueMap contains All( + KeyValue(1) {}, + KeyValue(2) {}) nullableValueMap contains (1 to null) - nullableValueMap contains Pairs(1 to null, 2 to null) - nullableValueMap contains Pairs(1 to null, 2 to "a") + nullableValueMap contains Pairs( + 1 to null, + 2 to null + ) + nullableValueMap contains Pairs( + 1 to null, + 2 to "a" + ) nullableValueMap contains (KeyValue(1, null)) - nullableValueMap contains All(KeyValue(1, null), KeyValue(2, null)) - nullableValueMap contains All(KeyValue(1, null), KeyValue(2) {}) + nullableValueMap contains All( + KeyValue( + 1, + null + ), KeyValue(2, null) + ) + nullableValueMap contains All( + KeyValue( + 1, + null + ), KeyValue(2) {}) nullableKeyValueMap contains (1 to "a") - nullableKeyValueMap contains Pairs(1 to "a", 2 to "b") + nullableKeyValueMap contains Pairs( + 1 to "a", + 2 to "b" + ) nullableKeyValueMap contains KeyValue(1) {} - nullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + nullableKeyValueMap contains All( + KeyValue( + 1 + ) {}, KeyValue(2) {}) nullableKeyValueMap contains (null to "a") - nullableKeyValueMap contains Pairs(null to "a", null to "b") - nullableKeyValueMap contains Pairs(null to "a", 2 to "b") + nullableKeyValueMap contains Pairs( + null to "a", + null to "b" + ) + nullableKeyValueMap contains Pairs( + null to "a", + 2 to "b" + ) nullableKeyValueMap contains (KeyValue(null) {}) - nullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(null) {}) - nullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(2) {}) + nullableKeyValueMap contains All( + KeyValue( + null + ) {}, KeyValue(null) {}) + nullableKeyValueMap contains All( + KeyValue( + null + ) {}, KeyValue(2) {}) nullableKeyValueMap contains (1 to null) - nullableKeyValueMap contains Pairs(1 to null, 2 to null) - nullableKeyValueMap contains Pairs(1 to null, 2 to "a") - nullableKeyValueMap contains (KeyValue(1, null)) - nullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2, null)) - nullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2) {}) + nullableKeyValueMap contains Pairs( + 1 to null, + 2 to null + ) + nullableKeyValueMap contains Pairs( + 1 to null, + 2 to "a" + ) + nullableKeyValueMap contains (KeyValue( + 1, + null + )) + nullableKeyValueMap contains All( + KeyValue( + 1, + null + ), KeyValue(2, null) + ) + nullableKeyValueMap contains All( + KeyValue( + 1, + null + ), KeyValue(2) {}) nullableKeyValueMap contains (null to null) - nullableKeyValueMap contains Pairs(null to null, null to null) - nullableKeyValueMap contains Pairs(1 to null, null to "a") - nullableKeyValueMap contains (KeyValue(null, null)) - nullableKeyValueMap contains All(KeyValue(null, null), KeyValue(null, null)) - nullableKeyValueMap contains All(KeyValue(1, null), KeyValue(null) {}) + nullableKeyValueMap contains Pairs( + null to null, + null to null + ) + nullableKeyValueMap contains Pairs( + 1 to null, + null to "a" + ) + nullableKeyValueMap contains (KeyValue( + null, + null + )) + nullableKeyValueMap contains All( + KeyValue( + null, + null + ), KeyValue(null, null) + ) + nullableKeyValueMap contains All( + KeyValue( + 1, + null + ), KeyValue(null) {}) readOnlyNullableKeyValueMap contains (1 to "a") - readOnlyNullableKeyValueMap contains Pairs(1 to "a", 2 to "b") - readOnlyNullableKeyValueMap contains KeyValue(1) {} - readOnlyNullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + readOnlyNullableKeyValueMap contains Pairs( + 1 to "a", + 2 to "b" + ) + readOnlyNullableKeyValueMap contains KeyValue( + 1 + ) {} + readOnlyNullableKeyValueMap contains All( + KeyValue(1) {}, + KeyValue(2) {}) readOnlyNullableKeyValueMap contains (null to "a") - readOnlyNullableKeyValueMap contains Pairs(null to "a", null to "b") - readOnlyNullableKeyValueMap contains Pairs(null to "a", 2 to "b") - readOnlyNullableKeyValueMap contains (KeyValue(null) {}) - readOnlyNullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(null) {}) - readOnlyNullableKeyValueMap contains All(KeyValue(null) {}, KeyValue(2) {}) + readOnlyNullableKeyValueMap contains Pairs( + null to "a", + null to "b" + ) + readOnlyNullableKeyValueMap contains Pairs( + null to "a", + 2 to "b" + ) + readOnlyNullableKeyValueMap contains (KeyValue( + null + ) {}) + readOnlyNullableKeyValueMap contains All( + KeyValue(null) {}, + KeyValue(null) {}) + readOnlyNullableKeyValueMap contains All( + KeyValue(null) {}, + KeyValue(2) {}) readOnlyNullableKeyValueMap contains (1 to null) - readOnlyNullableKeyValueMap contains Pairs(1 to null, 2 to null) - readOnlyNullableKeyValueMap contains Pairs(1 to null, 2 to "a") - readOnlyNullableKeyValueMap contains (KeyValue(1, null)) - readOnlyNullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2, null)) - readOnlyNullableKeyValueMap contains All(KeyValue(1, null), KeyValue(2) {}) + readOnlyNullableKeyValueMap contains Pairs( + 1 to null, + 2 to null + ) + readOnlyNullableKeyValueMap contains Pairs( + 1 to null, + 2 to "a" + ) + readOnlyNullableKeyValueMap contains (KeyValue( + 1, + null + )) + readOnlyNullableKeyValueMap contains All( + KeyValue(1, null), + KeyValue(2, null) + ) + readOnlyNullableKeyValueMap contains All( + KeyValue(1, null), + KeyValue(2) {}) readOnlyNullableKeyValueMap contains (null to null) - readOnlyNullableKeyValueMap contains Pairs(null to null, null to null) - readOnlyNullableKeyValueMap contains Pairs(1 to null, null to "a") - readOnlyNullableKeyValueMap contains (KeyValue(null, null)) - readOnlyNullableKeyValueMap contains All(KeyValue(null, null), KeyValue(null, null)) - readOnlyNullableKeyValueMap contains All(KeyValue(1, null), KeyValue(null) {}) + readOnlyNullableKeyValueMap contains Pairs( + null to null, + null to null + ) + readOnlyNullableKeyValueMap contains Pairs( + 1 to null, + null to "a" + ) + readOnlyNullableKeyValueMap contains (KeyValue( + null, + null + )) + readOnlyNullableKeyValueMap contains All( + KeyValue(null, null), + KeyValue(null, null) + ) + readOnlyNullableKeyValueMap contains All( + KeyValue(1, null), + KeyValue(null) {}) readOnlyNullableKeyValueMap contains (1 to "a") - readOnlyNullableKeyValueMap contains Pairs(1 to "a", 2 to "b") - readOnlyNullableKeyValueMap contains KeyValue(1) {} - readOnlyNullableKeyValueMap contains All(KeyValue(1) {}, KeyValue(2) {}) + readOnlyNullableKeyValueMap contains Pairs( + 1 to "a", + 2 to "b" + ) + readOnlyNullableKeyValueMap contains KeyValue( + 1 + ) {} + readOnlyNullableKeyValueMap contains All( + KeyValue(1) {}, + KeyValue(2) {}) starMap contains (null to "a") - starMap contains Pairs(null to "a", null to "b") + starMap contains Pairs( + null to "a", + null to "b" + ) starMap contains Pairs(null to "a", 2 to "b") starMap contains (KeyValue(null) {}) - starMap contains All(KeyValue(null) {}, KeyValue(null) {}) - starMap contains All(KeyValue(null) {}, KeyValue(2) {}) + starMap contains All( + KeyValue(null) {}, + KeyValue(null) {}) + starMap contains All( + KeyValue(null) {}, + KeyValue(2) {}) starMap contains (1 to null) starMap contains Pairs(1 to null, 2 to null) starMap contains Pairs(1 to null, 2 to "a") starMap contains (KeyValue(1, null)) - starMap contains All(KeyValue(1, null), KeyValue(2, null)) - starMap contains All(KeyValue(1, null), KeyValue(2) {}) + starMap contains All( + KeyValue(1, null), + KeyValue(2, null) + ) + starMap contains All( + KeyValue(1, null), + KeyValue(2) {}) starMap contains (null to null) - starMap contains Pairs(null to null, null to null) + starMap contains Pairs( + null to null, + null to null + ) starMap contains Pairs(1 to null, null to "a") starMap contains (KeyValue(null, null)) - starMap contains All(KeyValue(null, null), KeyValue(null, null)) - starMap contains All(KeyValue(1, null), KeyValue(null) {}) + starMap contains All( + KeyValue( + null, + null + ), KeyValue(null, null) + ) + starMap contains All( + KeyValue(1, null), + KeyValue(null) {}) map containsKey 1 map containsKey 1f diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt index 65f638b55..21328ac3e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.specs.testutils.WithAsciiReporter @@ -20,7 +21,10 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss vararg otherExpected: Any ): Expect = if (otherExpected.isEmpty()) expect messageContains expected - else expect messageContains Values(expected, *otherExpected) + else expect messageContains Values( + expected, + *otherExpected + ) @Suppress("RemoveExplicitTypeArguments") private fun causeFeature(expect: Expect): Expect = @@ -41,7 +45,11 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1 = a1 message {} a1 = a1 messageContains "a" a1 = a1 messageContains 'a' - a1 = a1 messageContains Values("a", 1, 'b') + a1 = a1 messageContains Values( + "a", + 1, + 'b' + ) a1.cause() a1.cause { message { } } From b7d0fb3b3493fa21f84b74cddfa854f06c12ebe6 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 4 Apr 2020 01:32:50 +0200 Subject: [PATCH 125/142] introduce helper functions for the parameter objects moreover: - improve KDoc use " instead of ' where we refer to a String - improve ambiguityTest in CharSequenceContainsSpecBase of fluent API - fix line-break issues (introduce by IntelliJ, refactoring code without asking) --- .../fluent/en_GB/charSequenceAssertions.kt | 22 +- .../en_GB/charSequenceContainsCreators.kt | 68 +-- ...arSequenceContainsAtLeastAssertionsSpec.kt | 4 +- .../en_GB/CharSequenceContainsSpecBase.kt | 25 + ...sInOrderOnlyGroupedValuesAssertionsSpec.kt | 8 +- .../api/infix/en_GB/charSequenceAssertions.kt | 60 ++- .../en_GB/charSequenceContainsCreators.kt | 151 +++--- .../atrium/api/infix/en_GB/creating/All.kt | 5 +- .../api/infix/en_GB/creating/Entries.kt | 4 +- .../atrium/api/infix/en_GB/creating/Entry.kt | 5 +- .../atrium/api/infix/en_GB/creating/Pairs.kt | 4 +- .../atrium/api/infix/en_GB/creating/Value.kt | 2 + .../atrium/api/infix/en_GB/creating/Values.kt | 6 +- .../creating/charsequence/RegexPatterns.kt | 4 +- .../impl/nameContainsNotFun.kt | 2 +- .../infix/en_GB/creating/iterable/Order.kt | 5 +- .../builders/impl/nameContainsNotFun.kt | 2 +- .../{KeyValue.kt => KeyWithValueCreator.kt} | 4 +- .../api/infix/en_GB/genericHelperFunctions.kt | 51 ++ .../api/infix/en_GB/iterableAssertions.kt | 45 +- .../iterableContainsInAnyOrderCreators.kt | 27 +- .../iterableContainsInAnyOrderOnlyCreators.kt | 25 +- .../iterableContainsInOrderOnlyCreators.kt | 18 +- ...rableContainsInOrderOnlyGroupedCreators.kt | 23 +- .../atrium/api/infix/en_GB/mapAssertions.kt | 43 +- .../api/infix/en_GB/throwableAssertions.kt | 7 +- ...arSequenceContainsAtLeastAssertionsSpec.kt | 30 +- ...harSequenceContainsAtMostAssertionsSpec.kt | 11 +- ...quenceContainsContainsNotAssertionsSpec.kt | 25 +- ...arSequenceContainsExactlyAssertionsSpec.kt | 11 +- .../CharSequenceContainsNotAssertionsSpec.kt | 11 +- ...quenceContainsNotOrAtMostAssertionsSpec.kt | 11 +- ...CharSequenceContainsRegexAssertionsSpec.kt | 47 +- .../en_GB/CharSequenceContainsSpecBase.kt | 90 ++-- .../en_GB/CollectionFeatureAssertionsSpec.kt | 2 +- ...InAnyOrderAtLeast1EntriesAssertionsSpec.kt | 14 +- ...sInAnyOrderAtLeast1ValuesAssertionsSpec.kt | 20 +- ...nsInAnyOrderAtLeastValuesAssertionsSpec.kt | 10 +- ...insInAnyOrderAtMostValuesAssertionsSpec.kt | 5 +- ...nsInAnyOrderExactlyValuesAssertionsSpec.kt | 5 +- ...AnyOrderNotOrAtMostValuesAssertionsSpec.kt | 5 +- ...ainsInAnyOrderOnlyEntriesAssertionsSpec.kt | 10 +- ...tainsInAnyOrderOnlyValuesAssertionsSpec.kt | 10 +- ...ontainsInOrderOnlyEntriesAssertionsSpec.kt | 20 +- ...InOrderOnlyGroupedEntriesAssertionsSpec.kt | 15 +- ...sInOrderOnlyGroupedValuesAssertionsSpec.kt | 34 +- ...ContainsInOrderOnlyValuesAssertionsSpec.kt | 23 +- ...terableContainsNotEntriesAssertionsSpec.kt | 10 +- ...IterableContainsNotValuesAssertionsSpec.kt | 15 +- .../infix/en_GB/IterableContainsSpecBase.kt | 488 ++++++------------ .../api/infix/en_GB/MapAssertionsSpec.kt | 436 ++++------------ .../en_GB/MapEntryFeatureAssertionsSpec.kt | 2 +- .../infix/en_GB/ThrowableAssertionsSpec.kt | 5 +- 53 files changed, 744 insertions(+), 1241 deletions(-) rename apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/{KeyValue.kt => KeyWithValueCreator.kt} (72%) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt index ca4754012..7f623cddb 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceAssertions.kt @@ -35,17 +35,17 @@ val Expect.containsNot: NotCheckerOption Expect.containsNot(expected: Any, vararg otherExpected * * It is a shortcut for `contains.atLeast(1).regex(pattern, *otherPatterns)`. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and [pattern] - * is defined as `'a(b)?'` and one of the [otherPatterns] is defined as `'a(b)?'` as well, then both match, even though + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and [pattern] + * is defined as `"a(b)?"` and one of the [otherPatterns] is defined as `"a(b)?"` as well, then both match, even though * they match the same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to * control the number of occurrences you expect. * @@ -102,9 +102,9 @@ fun Expect.containsRegex(pattern: String, vararg otherPatt * * It is a shortcut for `contains.atLeast(1).regex(pattern, *otherPatterns)`. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and [pattern] - * is defined as `'a(b)?'` and one of the [otherPatterns] is defined as `'a(b)?'` as well, then both match, even though + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and [pattern] + * is defined as `"a(b)?"` and one of the [otherPatterns] is defined as `"a(b)?"` as well, then both match, even though * they match the same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to * control the number of occurrences you expect. * diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt index 59814f748..3cd8f6038 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt @@ -19,7 +19,7 @@ import kotlin.jvm.JvmName * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expected The value which is expected to be contained within the input of the search. * @@ -37,16 +37,16 @@ fun CheckerOption.value(expected: Any * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and [expected] - * is defined as `'a'` and one [otherExpected] is defined as `'a'` as well, then both match, even though they match the + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and [expected] + * is defined as `"a"` and one [otherExpected] is defined as `"a"` as well, then both match, even though they match the * same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to control * the number of occurrences you expect. * * Meaning you might want to use: - * `contains.exactly(2).value('a')` + * `contains.exactly(2).value("a")` * instead of: - * `contains.atLeast(1).values('a', 'a')` + * `contains.atLeast(1).values("a", "a")` * * @param expected The value which is expected to be contained within the input of the search. * @param otherExpected Additional values which are expected to be contained within the input of the search. @@ -71,7 +71,7 @@ fun CheckerOption.values( * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expected The value which is expected to be contained within the input of the search. * @@ -91,16 +91,16 @@ fun CheckerOption.value( * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and [expected] - * is defined as `'a'` and one [otherExpected] is defined as `'a'` as well, then both match, even though they match the + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and [expected] + * is defined as `"a"` and one [otherExpected] is defined as `"a"` as well, then both match, even though they match the * same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to control * the number of occurrences you expect. * * Meaning you might want to use: - * `contains.ignoringCase.exactly(2).value('a')` + * `contains.ignoringCase.exactly(2).value("a")` * instead of: - * `contains.ignoringCase.atLeast(1).values('a', 'a')` + * `contains.ignoringCase.atLeast(1).values("a", "a")` * * @param expected The value which is expected to be contained within the input of the search. * @param otherExpected Additional values which are expected to be contained within the input of the search. @@ -126,7 +126,7 @@ fun CheckerOption.values( * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expected The value which is expected to be contained within the input of the search. * @@ -147,9 +147,9 @@ fun Builder.value(expected: A * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and [expected] - * is defined as `'a'` and one [otherExpected] is defined as `'a'` as well, then both match, even though they match the + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and [expected] + * is defined as `"a"` and one [otherExpected] is defined as `"a"` as well, then both match, even though they match the * same sequence in the input of the search. * * @param expected The value which is expected to be contained within the input of the search. @@ -169,9 +169,9 @@ fun Builder.values( * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] * as well as the [otherPatterns] are expected to have a match, using a non disjoint search. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and [pattern] - * is defined as `'a(b)?'` and one of the [otherPatterns] is defined as `'a(b)?'` as well, then both match, even though + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and [pattern] + * is defined as `"a(b)?"` and one of the [otherPatterns] is defined as `"a(b)?"` as well, then both match, even though * they match the same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to * control the number of occurrences you expect. * @@ -195,9 +195,9 @@ fun CheckerOption.regex( * Finishes the specification of the sophisticated `contains` assertion where the given [Regex] [pattern] * as well as the [otherPatterns] are expected to have a match, using a non disjoint search. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and [pattern] - * is defined as `'a(b)?'` and one of the [otherPatterns] is defined as `'a(b)?'` as well, then both match, even though + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and [pattern] + * is defined as `"a(b)?"` and one of the [otherPatterns] is defined as `"a(b)?"` as well, then both match, even though * they match the same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to * control the number of occurrences you expect. * @@ -224,16 +224,16 @@ fun CheckerOption.regex( * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] * as well as the [otherPatterns] are expected to have a match (ignoring case), using a non disjoint search. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and [pattern] - * is defined as `'a(b)?'` and one of the [otherPatterns] is defined as `'a(b)?'` as well, then both match, even though + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and [pattern] + * is defined as `"a(b)?"` and one of the [otherPatterns] is defined as `"a(b)?"` as well, then both match, even though * they match the same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] to * control the number of occurrences you expect. * * Meaning you might want to use: - * `contains.ignoringCase.exactly(2).regex('a(b)?')` + * `contains.ignoringCase.exactly(2).regex("a(b)?")` * instead of: - * `contains.ignoringCase.atLeast(1).regex('a(b)?', 'a(b)?')` + * `contains.ignoringCase.atLeast(1).regex("a(b)?", "a(b)?")` * * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. @@ -254,16 +254,16 @@ fun CheckerOption.regex( * * Delegates to `atLeast(1).regex(pattern, otherPatterns)` * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and [pattern] - * is defined as `'a(b)?'` and one of the [otherPatterns] is defined as `'a(b)?'` as well, then both match, even though + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and [pattern] + * is defined as `"a(b)?"` and one of the [otherPatterns] is defined as `"a(b)?"` as well, then both match, even though * they match the same sequence in the input of the search. Use an option such as [atLeast], [atMost] and [exactly] * to control the number of occurrences you expect. * * Meaning you might want to use: - * `contains.ignoringCase.exactly(2).regex('a(b)?')` + * `contains.ignoringCase.exactly(2).regex("a(b)?")` * instead of: - * `contains.ignoringCase.atLeast(1).regex('a(b)?', 'a(b)?')` + * `contains.ignoringCase.atLeast(1).regex("a(b)?", "a(b)?")` * * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. @@ -286,7 +286,7 @@ fun Builder.regex( * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * @@ -314,7 +314,7 @@ fun CheckerOption.elementsOf( * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index 6de3cb375..fa359652e 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -29,14 +29,14 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ ) {}) include(object : Spek({ - describe("elementsOf") { + describe("atLeast(1).elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { expect("test").contains.atLeast(1).elementsOf(emptyList()) }.toThrow { messageContains("Iterable without elements are not allowed") } } } - describe("elementsOf ignoring case") { + describe("ignoringCase.atLeast(1).elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { expect("test").contains.ignoringCase.atLeast(1).elementsOf(emptyList()) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt index aa4886855..88c6d2e45 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt @@ -42,17 +42,42 @@ abstract class CharSequenceContainsSpecBase { a1.contains.atLeast(2).regex(Regex("bla"), Regex("b")) a1.contains.atLeast(2).elementsOf(listOf("a", 2)) + a1.containsNot.value(1) + a1.containsNot.values("a", 1) + a1.containsNot.regex("h|b", "b") + a1.containsNot.regex(Regex("bla")) + a1.containsNot.regex(Regex("bla"), Regex("b")) + a1.containsNot.elementsOf(listOf("a", 2)) + a1.contains.ignoringCase.atLeast(1).value("a") a1.contains.ignoringCase.atLeast(1).values("a", 'b') a1.contains.ignoringCase.atLeast(1).regex("a") a1.contains.ignoringCase.atLeast(1).regex("a", "bl") + // not supported on purpose as one can specify an ignore case flag for Regex + // and hence these would be a second way to do the same thing + //a1.contains.ignoringCase.atLeast(1).regex(Regex("a")) + //a1.contains.ignoringCase.atLeast(1).regex(Regex("a"), Regex("bl")) a1.contains.ignoringCase.atLeast(1).elementsOf(listOf(1, 2)) + a1.containsNot.ignoringCase.value("a") + a1.containsNot.ignoringCase.values("a", 'b') + a1.containsNot.ignoringCase.regex("a") + a1.containsNot.ignoringCase.regex("a", "bl") + // not supported on purpose as one can specify an ignore case flag for Regex + // and hence these would be a second way to do the same thing + //a1.containsNot.ignoringCase.regex(Regex("a")) + //a1.containsNot.ignoringCase.regex(Regex("a"), Regex("bl")) + a1.containsNot.ignoringCase.elementsOf(listOf(1, 2)) + // skip atLeast a1.contains.ignoringCase.value("a") a1.contains.ignoringCase.values("a", 'b') a1.contains.ignoringCase.regex("a") a1.contains.ignoringCase.regex("a", "bl") + // not supported on purpose as one can specify an ignore case flag for Regex + // and hence these would be a second way to do the same thing + //a1.contains.ignoringCase.regex(Regex("a")) + //a1.contains.ignoringCase.regex(Regex("a"), Regex("bl")) //TODO #422 uncomment //a1.contains.ignoringCase.elementsOf(listOf("a", 2)) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt index 36d701663..499d250e7 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt @@ -21,9 +21,7 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : a1: Group, a2: Group, aX: Array> - ): Expect> { - return expect.contains.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX) - } + ): Expect> = expect.contains.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX) private fun groupFactory(groups: Array): Group = when (groups.size) { @@ -43,9 +41,7 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : a1: Group, a2: Group, aX: Array> - ): Expect> { - return expect.contains.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX) - } + ): Expect> = expect.contains.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX) private fun nullableGroupFactory(groups: Array): Group = when (groups.size) { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt index c4ebdf2a0..42059160b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -57,22 +57,24 @@ infix fun Expect.contains(expected: Any): Expect = * Expects that the subject of the assertion (a [CharSequence]) contains the [toString] representation of the * given [values] using a non disjoint search. * - * It is a shortcut for `contains o atLeast 1 the Values(expected, *otherExpected)`. + * It is a shortcut for `contains o atLeast 1 the values(expected, *otherExpected)`. * * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and - * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, - * even though they match the same sequence in the input of the search. Use the property `contains` to create - * a more sophisticated `contains` assertion where you can use options such as [atLeast], [atMost] and [exactly] - * to control the number of occurrences you expect. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and + * [Values] is defined as `values("a", "a")`, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `contains o exactly 2 value 'a'` + * `contains o exactly 2 value "a"` * instead of: - * `contains Values('a', 'a')` + * `contains values("a", "a")` + * + * @param values The values which are expected to be contained within the input of the search + * -- use the function `values(t, ...)` to create a [Values]. * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -100,11 +102,13 @@ infix fun Expect.containsNot(expected: Any) = * Expects that the subject of the assertion (a [CharSequence]) does not contain the [toString] representation * of the given [values]. * - * It is a shortcut for `contains not the Values(expected, *otherExpected)`. + * It is a shortcut for `contains not the values(expected, *otherExpected)`. * * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * + * @param values The values which should not be found -- use the function `values(t, ...)` to create a [Values]. + * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @@ -129,7 +133,7 @@ infix fun Expect.containsRegex(pattern: String): Expect * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given * regular expression [pattern]. * - * It is a shortcut for `contains o atLeast 1 regex pattern`. + * It is a shortcut for `contains o atLeast 1 matchFor pattern`. * * @param pattern The pattern which is expected to have a match against the input of the search. * @@ -143,20 +147,21 @@ infix fun Expect.contains(pattern: Regex): Expect = * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given * regular expression [patterns], using a non disjoint search. * - * It is a shortcut for `contains o atLeast 1 the RegexPatterns(pattern, *otherPatterns)`. + * It is a shortcut for `contains o atLeast 1 the regexPatterns(pattern, *otherPatterns)`. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and - * [RegexPatterns.expected] is defined as `'a(b)?'` and one of the [RegexPatterns.otherExpected] is defined - * as `'a(b)?'` as well, then both match, even though they match the same sequence in the input of the search. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and + * [RegexPatterns] is defined as `regexPatterns("a(b)?", "a(b)?")` as well, then both match, + * even though they match the same sequence in the input of the search. * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: * `contains o exactly 2 regex "a(b)?"` * instead of: - * `contains o atLeast 1 the RegexPatterns("a(b)?", "a(b)?")` + * `contains o atLeast 1 the regexPatterns("a(b)?", "a(b)?")` * - * @param patterns The patterns which are expected to have a match against the input of the search. + * @param patterns The patterns which are expected to have a match against the input of the search -- + * use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -164,24 +169,31 @@ infix fun Expect.contains(pattern: Regex): Expect = infix fun Expect.containsRegex(patterns: RegexPatterns): Expect = this contains o atLeast 1 the patterns +/** + * Helper function to create a [RegexPatterns] based on the given [pattern] and [otherPatterns] + * -- allows to express `String, vararg String`. + */ +fun regexPatterns(pattern: String, vararg otherPatterns: String): RegexPatterns = RegexPatterns(pattern, otherPatterns) + /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given * regular expression [patterns], using a non disjoint search. * * It is a shortcut for `contains o atLeast 1 regex All(pattern, *otherPatterns)`. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and - * [RegexPatterns.expected] is defined as `'a(b)?'` and one of the [RegexPatterns.otherExpected] is defined - * as `'a(b)?'` as well, then both match, even though they match the same sequence in the input of the search. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and + * [All] is defined as `all(Regex("a(b)?"), Regex("a(b)?"))` as well, then both match, + * even though they match the same sequence in the input of the search. * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: * `contains o exactly 2 regex "a(b)?"` * instead of: - * `contains o atLeast 1 the RegexPatterns("a(b)?", "a(b)?")` + * `contains o atLeast 1 the all(Regex("a(b)?"), Regex("a(b)?"))` * - * @param patterns The patterns which are expected to have a match against the input of the search. + * @param patterns The patterns which are expected to have a match against the input of the search -- + * use the function `all(Regex(...), ...)` to create a [All]. * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt index b0f2bb5d3..770834e91 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -17,12 +17,12 @@ import kotlin.jvm.JvmName * Finishes the specification of the sophisticated `contains` assertion where the [expected] object shall be searched, * using a non disjoint search. * - * Delegates to `the Values(expected)`. + * Delegates to `the values(expected)`. * * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expected The value which is expected to be contained within the input of the search. * @@ -31,7 +31,7 @@ import kotlin.jvm.JvmName * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ infix fun CheckerOption.value(expected: Any): Expect = - this the Values(expected) + this the values(expected) /** * Finishes the specification of the sophisticated `contains` assertion where the given [values] @@ -40,18 +40,19 @@ infix fun CheckerOption.value(expecte * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and - * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, - * even though they match the same sequence in the input of the search. Use an option such as - * [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and + * [Values] is defined as `values("a", "a")`, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `to contain exactly 2 the value 'a'` + * `contains o exactly 2 the value "a"` * instead of: - * `to contain atLeast 1 the Values('a', 'a')` + * `contains o atLeast 1 the values("a", "a")` * - * @param values The values which are expected to be contained within the input of the search. + * @param values The values which should not be found within the input of the search + * -- use the function `values(t, ...)` to create a [Values]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -65,12 +66,12 @@ infix fun CheckerOption.the(values: V * Finishes the specification of the sophisticated `contains` assertion where the [expected] value shall be searched * (ignoring case), using a non disjoint search. * - * Delegates to `the Values(expected)`. + * Delegates to `the values(expected)`. * * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expected The value which is expected to be contained within the input of the search. * @@ -80,7 +81,7 @@ infix fun CheckerOption.the(values: V */ @JvmName("valueIgnoringCase") infix fun CheckerOption.value(expected: Any): Expect = - this the Values(expected) + this the values(expected) /** * Finishes the specification of the sophisticated `contains` assertion where the [values] @@ -89,18 +90,19 @@ infix fun CheckerOption.value * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and - * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, - * even though they match the same sequence in the input of the search. Use an option such as - * [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and + * [Values] is defined as `values("a", "a")`, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `to contain ignoring case exactly 2 the value 'a'` + * `contains o ignoring case exactly 2 the value "a"` * instead of: - * `to contain ignoring case atLeast 1 the Values('a', 'a')` + * `contains o ignoring case atLeast 1 the values("a", "a")` * - * @param values The values which are expected to be contained within the input of the search. + * @param values The values which are expected to be contained within the input of the search + * -- use the function `values(t, ...)` to create a [Values]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -119,7 +121,7 @@ infix fun CheckerOption.the(v * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expected The value which is expected to be contained within the input of the search. * @@ -137,18 +139,19 @@ infix fun Builder.value(expec * * Delegates to `atLeast 1 the value` * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'a'` and - * [Values.expected] is defined as `'a'` and one [Values.otherExpected] is defined as `'a'` as well, then both match, + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"a"` and + * [Values] is defined as `values("a", "a")`, then both match, * even though they match the same sequence in the input of the search. * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `to contain ignoring case exactly 2 the value 'a'` + * `contains o ignoring case exactly 2 the value "a"` * instead of: - * `to contain ignoring case atLeast 1 the Values('a', 'a')` + * `contains o ignoring case atLeast 1 the values("a", "a")` * - * @param values The values which are expected to be contained within the input of the search. + * @param values The values which are expected to be contained within the input of the search + * -- use the function `values(t, ...)` to create a [Values]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -161,7 +164,7 @@ infix fun Builder.the(values: * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] * is expected to have a match, using a non disjoint search. * - * Delegates to `the RegexPatterns(pattern)`. + * Delegates to `the regexPatterns(pattern)`. * * @param pattern The pattern which is expected to have a match against the input of the search. * @@ -169,13 +172,13 @@ infix fun Builder.the(values: * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun CheckerOption.regex(pattern: String): Expect = - this the RegexPatterns(pattern) + this the regexPatterns(pattern) /** * Finishes the specification of the sophisticated `contains` assertion where the given [Regex] [pattern] * is expected to have a match. * - * Delegates to `All(pattern)` + * Delegates to `matchFor all(pattern)` * * @param pattern The pattern which is expected to have a match against the input of the search. * @@ -186,25 +189,25 @@ infix fun CheckerOption.regex(pattern */ infix fun CheckerOption.matchFor( pattern: Regex -): Expect = this matchFor All(pattern) +): Expect = this matchFor all(pattern) /** * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [patterns] * are expected to have a match, using a non disjoint search. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and - * [patterns].[pattern][RegexPatterns.expected] is defined as `'a(b)?'` and one of the - * [patterns].[otherPatterns][RegexPatterns.otherExpected] is defined as `'a(b)?'` as well, then both match, even though - * they match the same sequence in the input of the search. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and + * [RegexPatterns] is defined as `regexPatterns("a(b)?", "a(b)?")` as well, then both match, + * even though they match the same sequence in the input of the search. * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `to contain exactly 2 the regex 'a(b)?'` + * `contains o exactly 2 regex "a(b)?"` * instead of: - * `to contain atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')` + * `contains o atLeast 1 the regexPatterns("a(b)?", "a(b)?")` * - * @param patterns The patterns which are expected to have a match against the input of the search. + * @param patterns The patterns which are expected to have a match against the input of the search + * -- use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -216,19 +219,19 @@ infix fun CheckerOption.the(patterns: * Finishes the specification of the sophisticated `contains` assertion where the given [Regex] [patterns] * are expected to have a match, using a non disjoint search. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and the first - * pattern in [patterns] is defined as `'a(b)?'` and one of the other patterns is defined as `'a(b)?'` as well, - * then both match, even though they match the same sequence in the input of the search. - * Use an option such as [atLeast], [atMost] and [exactly] to - * control the number of occurrences you expect. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and + * [All] is defined as `all(Regex("a(b)?"), Regex("a(b)?"))` as well, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `contains o exactly 2 matchFor Regex("a(b)?")` + * `contains o exactly 2 regex "a(b)?"` * instead of: - * `contains o atLeast 1 matchFor All(Regex("a(b)?"), Regex("a(b)?")) + * `contains o atLeast 1 the all(Regex("a(b)?"), Regex("a(b)?"))` * - * @param patterns The patterns which are expected to have a match against the input of the search. + * @param patterns The patterns which are expected to have a match against the input of the search -- + * use the function `all(Regex(...), ...)` to create a [All]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -244,7 +247,7 @@ infix fun CheckerOption.matchFor(patt * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [pattern] * is expected to have a match (ignoring case), using a non disjoint search. * - * Delegates to `the RegexPatterns(pattern)`. + * Delegates to `the regexPatterns(pattern)`. * * @param pattern The patterns which is expected to have a match against the input of the search. * @@ -253,25 +256,25 @@ infix fun CheckerOption.matchFor(patt */ @JvmName("regexIgnoringCase") infix fun CheckerOption.regex(pattern: String): Expect = - this the RegexPatterns(pattern) + this the regexPatterns(pattern) /** * Finishes the specification of the sophisticated `contains` assertion where the given regular expression [patterns] * are expected to have a match (ignoring case), using a non disjoint search. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and - * [patterns].[pattern][RegexPatterns.expected] is defined as `'a(b)?'` and one of the - * [patterns].[otherPatterns][RegexPatterns.otherExpected] is defined as `'a(b)?'` as well, then both match, even though - * they match the same sequence in the input of the search. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and + * [RegexPatterns] is defined as `regexPatterns("a(b)?", "a(b)?")` as well, then both match, + * even though they match the same sequence in the input of the search. * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `to contain ignoring case exactly 2 the regex 'a(b)?'` + * `contains o ignoring case exactly 2 the regex "a(b)?"` * instead of: - * `to contain ignoring case atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')` + * `contains o ignoring case atLeast 1 the regexPatterns("a(b)?", "a(b)?")` * - * @param patterns The patterns which are expected to have a match against the input of the search. + * @param patterns The patterns which are expected to have a match against the input of the search + * -- use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -300,19 +303,19 @@ infix fun Builder.regex(patte * * Delegates to `atLeast 1 the patterns`. * - * By non disjoint is meant that `'aa'` in `'aaaa'` is found three times and not only two times. - * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `'ab'` and - * [patterns].[pattern][RegexPatterns.expected] is defined as `'a(b)?'` and one of the - * [patterns].[otherPatterns][RegexPatterns.otherExpected] is defined as `'a(b)?'` as well, then both match, even though - * they match the same sequence in the input of the search. + * By non disjoint is meant that `"aa"` in `"aaaa"` is found three times and not only two times. + * Also notice, that it does not search for unique matches. Meaning, if the input of the search is `"ab"` and + * [RegexPatterns] is defined as `regexPatterns("a(b)?", "a(b)?")` as well, then both match, + * even though they match the same sequence in the input of the search. * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: - * `to contain ignoring case exactly 2 the regex 'a(b)?'` + * `contains o ignoring case exactly 2 the regex "a(b)?"` * instead of: - * `to contain ignoring case atLeast 1 the RegexPatterns('a(b)?', 'a(b)?')` + * `contains o ignoring case atLeast 1 the RegexPatterns("a(b)?", "a(b)?")` * - * @param patterns The patterns which are expected to have a match against the input of the search. + * @param patterns The patterns which are expected to have a match against the input of the search -- + * use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -324,13 +327,13 @@ infix fun Builder.the(pattern * Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable] * shall be searched, using a non disjoint search. * - * Delegates to `the Values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray())` + * Delegates to `the values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray())` * (see [the] for more information). * * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * @@ -345,7 +348,7 @@ infix fun CheckerOption.elementsOf( expectedIterable: Iterable ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, *rest) + return this the Values(first, rest) } @@ -353,13 +356,13 @@ infix fun CheckerOption.elementsOf( * Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable] * shall be searched (ignoring case), using a non disjoint search. * - * Delegates to `the Values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray())` + * Delegates to `the values(expectedIterable.first(), *expectedIterable.drop(1).toTypedArray())` * (see [the] for more information). * * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed (this * function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * - * By non disjoint is meant that 'aa' in 'aaaa' is found three times and not only two times. + * By non disjoint is meant that "aa" in "aaaa" is found three times and not only two times. * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * @@ -375,5 +378,5 @@ infix fun CheckerOption.eleme expectedIterable: Iterable ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, *rest) + return this the Values(first, rest) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt index 1007bc9ec..1a42f62ea 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper /** * Parameter object to express `T, vararg T`. + * + * Use the function `all(t, ...)` to create this representation. */ -class All(override val expected: T, override vararg val otherExpected: T) : - VarArgHelper +class All(override val expected: T, override val otherExpected: Array) : VarArgHelper diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt index 589ce301c..0b90baa4e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt @@ -17,6 +17,8 @@ import ch.tutteli.kbox.glue * In case `null` is used for an identification lambda then it is expected that the corresponding entry * is `null` as well. * + * Use the function `entries({ ... }, ...)` to create this representation. + * * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered * to be identified if it holds all [Assertion]s the lambda might create. * In case it is defined as `null`, then an entry is identified if it is `null` as well. @@ -24,7 +26,7 @@ import ch.tutteli.kbox.glue */ class Entries( val assertionCreatorOrNull: (Expect.() -> Unit)?, - vararg val otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? + val otherAssertionCreatorsOrNulls: Array.() -> Unit)?> ) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?>, VarArgHelper<(Expect.() -> Unit)?> { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt index b2fbe423c..9b266c33f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt @@ -13,13 +13,16 @@ import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries * In case `null` is used for the identification lambda then it is expected that the corresponding entry * is `null` as well. * + * Use the function `entry { ... }` to create this representation. + * * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered * to be identified if it holds all [Assertion]s the lambda creates. * In case it is defined as `null`, then an entry is identified if it is `null` as well. */ -class Entry( +data class Entry( val assertionCreatorOrNull: (Expect.() -> Unit)? ) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?> { + override fun toList(): List<(Expect.() -> Unit)?> = listOf(assertionCreatorOrNull) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt index 8c6f14338..709319f71 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt @@ -4,8 +4,10 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper /** * Parameter object to express `Pair, vararg Pair`. + * + * Use the function `pairs(x to y, ...)` to create this representation. */ class Pairs( override val expected: Pair, - override vararg val otherExpected: Pair + override val otherExpected: Array> ) : VarArgHelper> diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt index 8f2a0bace..6fad286c1 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt @@ -7,6 +7,8 @@ import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries /** * Represents a [Group] with a single value. + * + * Use the function `value(t)` to create this representation. */ data class Value(val expected: T) : GroupWithNullableEntries, GroupWithoutNullableEntries { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt index 399032287..43b8c16ab 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt @@ -10,12 +10,14 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper /** * Represents a [Group] of multiple values. * + * Use the function `values(t, ...)` to create this representation. + * * Note, [Values] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) */ //TODO remove `out` with Kotlin 1.4 (most likely with Atrium 1.0.0) class Values( override val expected: T, - override vararg val otherExpected: T + override val otherExpected: Array ) : GroupWithoutNullableEntries, GroupWithNullableEntries, VarArgHelper { - override fun toList() = listOf(expected, *otherExpected) + override fun toList(): List = super.toList() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt index 7654dbd2b..2456dc388 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt @@ -4,8 +4,10 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper /** * Parameter object to express `String, vararg String` in the infix-api. + * + * Use the function `regexPatterns("pattern", ...)` to create this representation. */ -class RegexPatterns(pattern: String, vararg otherPatterns: String) : +class RegexPatterns(pattern: String, otherPatterns: Array) : VarArgHelper { override val expected = pattern override val otherExpected = otherPatterns diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt index 0a6dd1b2d..3f76426d6 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt @@ -8,5 +8,5 @@ import kotlin.reflect.KFunction2 internal object StaticName { private val f: KFunction2, Values, Expect> = Expect::containsNot - val nameContainsNotValuesFun = "`${f.name} ${Values::class.simpleName}`" + val nameContainsNotValuesFun = "`${f.name} values`" } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt index 0c6f8ee33..edc161327 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt @@ -2,14 +2,15 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.iterable import ch.tutteli.atrium.domain.builders.utils.Group -//TODO #63 introduce function in addition /** * Parameter object to express `Group, Group, vararg Group` in the infix-api. * + * Use the function `order(group, group, ...)` to create this representation. + * * Notice, most probably the type parameter G will be removed in the future, will be fixed to [Group]. */ class Order>( val firstGroup: G, val secondGroup: G, - vararg val otherExpectedGroups: G + val otherExpectedGroups: Array ) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt index 80cdb7a4a..7f360e1cb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt @@ -19,5 +19,5 @@ internal object StaticName { Values, Expect> > = IterableContains.CheckerOption, InAnyOrderSearchBehaviour>::the - val nameContainsNotValuesFun = "`${f.name} ${o::class.simpleName} ${fThe.name} ${Values::class.simpleName}`" + val nameContainsNotValuesFun = "`${f.name} ${o::class.simpleName} ${fThe.name} values`" } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt similarity index 72% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt index f3591604c..a38502d50 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyValue.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt @@ -5,8 +5,10 @@ import ch.tutteli.atrium.creating.Expect /** * Parameter object to express a key/value [Pair] whose value type is a nullable lambda with an * [Expect] receiver, which means one can either pass a lambda or `null`. + * + * Use the function `keyValue(x) { ... }` to create this representation. */ -data class KeyValue(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { +data class KeyWithValueCreator(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull override fun toString(): String = "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt new file mode 100644 index 000000000..8e7109216 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt @@ -0,0 +1,51 @@ +package ch.tutteli.atrium.api.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.creating.* +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect + +/** + * Helper function to create an [All] based on the given [t] and [ts] + * -- allows to express `T, vararg T`. + */ +fun all(t: T, vararg ts: T) = All(t, ts) + +/** + * Helper function to create an [Entry] based on the given [assertionCreatorOrNull]. + */ +fun entry(assertionCreatorOrNull: (Expect.() -> Unit)?): Entry = Entry(assertionCreatorOrNull) + +/** + * Helper function to create an [Entries] based on the given [assertionCreatorOrNull] + * and [otherAssertionCreatorsOrNulls] -- allows to express `{ }, vararg { }`. + * + * In case `null` is used for an identification lambda then it is expected that the corresponding entry + * is `null` as well. + * + * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered + * to be identified if it holds all [Assertion]s the lambda might create. + * In case it is defined as `null`, then an entry is identified if it is `null` as well. + * @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s. + */ +fun entries( + assertionCreatorOrNull: (Expect.() -> Unit)?, + vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)? +): Entries = Entries(assertionCreatorOrNull, otherAssertionCreatorsOrNulls) + + +/** + * Helper function to create a [Pairs] based on the given [pair] and [otherPairs] + * -- allows to express `Pair, vararg Pair`. + */ +fun pairs(pair: Pair, vararg otherPairs: Pair): Pairs = Pairs(pair, otherPairs) + +/** + * Helper function to create a [Value] based on the given [value]. + */ +fun value(value: T): Value = Value(value) + +/** + * Helper function to create a [Values] based on the given [value] and [otherValues] + * -- allows to express `T, vararg T`. + */ +fun values(value: T, vararg otherValues: T): Values = Values(value, otherValues) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt index 39543e339..43cccb29a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt @@ -1,11 +1,10 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.creating.Entries +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.NotCheckerOptionImpl import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.creating.SubjectProvider import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NoOpSearchBehaviour @@ -102,18 +101,20 @@ infix fun > Expect.contains(expected: E) = /** * Expects that the subject of the assertion (an [Iterable]) contains the expected [values]. * - * It is a shortcut for `contains o inAny order atLeast 1 the Values(...)` + * It is a shortcut for `contains o inAny order atLeast 1 the values(...)` * * Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and - * [values].[expected][Values.expected] is defined as `'a'` and - * one [values].[otherExpected][Values.otherExpected] is defined as `'a'` as well, then both match, - * even though they match the same entry. Use an option such as [atLeast], [atMost] and [exactly] to control the - * number of occurrences you expect. + * [Values] is defined as `values("a", "a")`, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: * contains o inAny order exactly 2 value 'a'` * instead of: - * `contains Values('a', 'a')` + * `contains values('a', 'a')` + * + * @param values The values which are expected to be contained within the [Iterable] + * -- use the function `values(t, ...)` to create a [Values]. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -139,20 +140,22 @@ infix fun > Expect.contains(assertionCreatorOrNull: it contains o inAny order atLeast 1 entry assertionCreatorOrNull /** - * Makes the assertion that the [Assert.subject][SubjectProvider.subject] contains an entry holding the + * Expects that the subject of the assertion (an [Iterable]) contains an entry holding the * assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or an entry * which is `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] * is defined as `null` -- likewise an entry (can be the same) is searched for each of the * [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls]. * - * It is a shortcut for `contains o inAny order atLeast 1 the Entries(...)` + * It is a shortcut for `contains o inAny order atLeast 1 the entries({ ... }, ...)` + * + * @param entries The entries which are expected to be contained within the [Iterable] + * -- use the function `entries(t, ...)` to create an [Entries]. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.contains( - entries: Entries -): Expect = it contains o inAny order atLeast 1 the entries +infix fun > Expect.contains(entries: Entries): Expect = + it contains o inAny order atLeast 1 the entries /** * Expects that the subject of the assertion (an [Iterable]) contains only @@ -176,6 +179,9 @@ infix fun > Expect.containsExactly(expected: E): Expect * which will cause a binary backward compatibility break (see * [#292](https://github.com/robstoll/atrium/issues/292) for more information) * + * @param values The values which are expected to be contained within the [Iterable] + * -- use the function `values(t, ...)` to create a [Values]. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @@ -200,8 +206,9 @@ infix fun > Expect.containsExactly(values: Values): Exp * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.containsExactly(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = - it contains o inGiven order and only entry assertionCreatorOrNull +infix fun > Expect.containsExactly( + assertionCreatorOrNull: (Expect.() -> Unit)? +): Expect = it contains o inGiven order and only entry assertionCreatorOrNull /** * Expects that the subject of the assertion (an [Iterable]) contains only an entry holding @@ -217,6 +224,9 @@ infix fun > Expect.containsExactly(assertionCreator * which will cause a binary backward compatibility break (see * [#292](https://github.com/robstoll/atrium/issues/292) for more information) * + * @param entries The entries which are expected to be contained within the [Iterable] + * -- use the function `entries(t, ...)` to create an [Entries]. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @@ -237,7 +247,10 @@ infix fun > Expect.containsNot(expected: E): Expect = /** * Expects that the subject of the assertion (an [Iterable]) does not contain the expected [values]. * - * It is a shortcut for `containsNot o the Values(...)` + * It is a shortcut for `containsNot o the values(...)` + * + * @param values The values which should not be contained within the [Iterable] + * -- use the function `values(t, ...)` to create a [Values]. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt index be66c6fa7..8209a57a4 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt @@ -14,7 +14,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAn * Finishes the specification of the sophisticated `contains` assertion where the [expected] * value shall be searched within the [Iterable]. * - * Delegates to [values]. + * Delegates to `the values(expected)`. * * @param expected The value which is expected to be contained within this [Iterable]. * @@ -22,24 +22,24 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAn * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > CheckerOption.value(expected: E): Expect = - this the Values(expected) + this the values(expected) /** * Finishes the specification of the sophisticated `contains` assertion where the expected [values] * shall be searched within the [Iterable]. * * Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and - * [values].[expected][Values.expected] is defined as `'a'` and one - * [values].[otherExpected][Values.otherExpected] is defined as `'a'` as well, then both match, - * even though they match the same entry. Use an option such as [atLeast], [atMost] and [exactly] to control the - * number of occurrences you expect. + * [Values] is defined as `values("a", "a")`, then both match, + * even though they match the same sequence in the input of the search. + * Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect. * * Meaning you might want to use: * `to contain inAny order exactly 2 value 'a'` * instead of: - * `to contain inAny order exactly 1 the Values('a', 'a')` + * `to contain inAny order exactly 1 the values('a', 'a')` * - * @param values The values which are expected to be contained within the [Iterable]. + * @param values The values which are expected to be contained within the [Iterable] + * -- use the function `values(t, ...)` to create a [Values]. * * @return The [AssertionPlant] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -52,7 +52,7 @@ infix fun > CheckerOption.th * holds all assertions [assertionCreatorOrNull] creates or needs to be `null` in case [assertionCreatorOrNull] * is defined as `null`. * - * Delegates to [entries]. + * Delegates to `the entries(assertionCreatorOrNull)` * * @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for @@ -63,9 +63,7 @@ infix fun > CheckerOption.th */ infix fun > CheckerOption.entry( assertionCreatorOrNull: (Expect.() -> Unit)? -): Expect = this the Entries( - assertionCreatorOrNull -) +): Expect = this the entries(assertionCreatorOrNull) /** * Finishes the specification of the sophisticated `contains` assertion where an entry shall be searched which either @@ -74,7 +72,8 @@ infix fun > CheckerOption> CheckerOption ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, *rest) + return this the Values(first, rest) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt index dbe494ec5..43123a8e5 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -13,7 +13,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAn * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the * [expected] value. * - * Delegates to [values]. + * Delegates to `the values(expected)`. * * Note that we might change the signature of this function with the next version * which will cause a binary backward compatibility break (see @@ -25,7 +25,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAn * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.value(expected: E): Expect = - this the Values(expected) + this the values(expected) /** * Finishes the specification of the sophisticated `contains` assertion where the expected [values] @@ -35,21 +35,21 @@ infix fun > Builder.valu * which will cause a binary backward compatibility break (see * [#292](https://github.com/robstoll/atrium/issues/292) for more information) * - * @param values The values which are expected to be contained within the [Iterable]. + * @param values The values which are expected to be contained within the [Iterable] + * -- use the function `values(t, ...)` to create a [Values]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Builder.the( - values: Values -): Expect = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrderOnly(this, values.toList())) +infix fun > Builder.the(values: Values): Expect = + addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrderOnly(this, values.toList())) /** * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only one * entry which holds all assertions created by the given [assertionCreatorOrNull] or is `null` in case * [assertionCreatorOrNull] is defined as `null`. * - * Delegates to [entries]. + * Delegates to `the entries(assertionCreatorOrNull)` * * Note that we might change the signature of this function with the next version * which will cause a binary backward compatibility break (see @@ -64,9 +64,7 @@ infix fun > Builder.the( */ infix fun > Builder.entry( assertionCreatorOrNull: (Expect.() -> Unit)? -): Expect = this the Entries( - assertionCreatorOrNull -) +): Expect = this the entries(assertionCreatorOrNull) /** * Finishes the specification of the sophisticated `contains` assertion where an entry needs to be contained in the @@ -80,7 +78,7 @@ infix fun > Builder> Builder> Builder ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, *rest) + return this the Values(first, rest) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt index 3707c43ba..9a3684872 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -14,7 +14,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOr * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the * [expected] value. * - * Delegates to [values]. + * Delegates to `the values(expected)`. * * Note that we might change the signature of this function with the next version * which will cause a binary backward compatibility break (see @@ -26,7 +26,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOr * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.value(expected: E): Expect = - this the Values(expected) + this the values(expected) /** * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the @@ -36,7 +36,8 @@ infix fun > Builder.value(e * which will cause a binary backward compatibility break (see * [#292](https://github.com/robstoll/atrium/issues/292) for more information) * - * @param values The nullable values which are expected to be contained within the [Iterable]. + * @param values The values which are expected to be contained within the [Iterable] + * -- use the function `values(t, ...)` to create a [Values]. * * @return The [AssertionPlant] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -49,7 +50,7 @@ infix fun > Builder.the(val * single entry which holds all assertions created by the given [assertionCreatorOrNull] or needs to be `null` * in case [assertionCreatorOrNull] is defined as `null`. * - * Delegates to `entries(assertionCreatorOrNull)`. + * Delegates to `the entries(assertionCreatorOrNull)`. * * Note that we might change the signature of this function with the next version * which will cause a binary backward compatibility break (see @@ -64,9 +65,7 @@ infix fun > Builder.the(val */ infix fun > Builder.entry( assertionCreatorOrNull: (Expect.() -> Unit)? -): Expect = this the Entries( - assertionCreatorOrNull -) +): Expect = this the entries(assertionCreatorOrNull) /** * Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only an @@ -80,7 +79,8 @@ infix fun > Builder * which will cause a binary backward compatibility break (see * [#292](https://github.com/robstoll/atrium/issues/292) for more information) * - * @param entries The parameter object containing the identification lambdas. + * @param entries The entries which are expected to be contained within the [Iterable] + * -- use the function `entries(t, ...)` to create an [Entries]. * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -112,5 +112,5 @@ inline infix fun > Builder ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, *rest) + return this the Values(first, rest) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt index 577a7fc67..020300e45 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt @@ -15,7 +15,9 @@ import kotlin.jvm.JvmName * the [Order.secondGroup] and optionally [Order.otherExpectedGroups] of values need to be * contained in [Iterable] in the specified order whereas the values within the groups can occur in any order. * - * @param order A parameter object containing the different groups which have to appear in order in the [Iterable]. + * @param order A parameter object containing the different groups which have to appear in order in the [Iterable] + * -- use `order(group, group, ...)` to create an [Order] where group is either `value(e)` or `values(e, ...)`; + * so a call could look as follows: `inAny order(values(1, 2), value(2), values(3, 2)) * * @return The [Expect] for which the assertion was built to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. @@ -29,6 +31,15 @@ infix fun > Builder order( + firstGroup: Group, + secondGroup: Group, + vararg otherExpectedGroups: Group +): Order> = Order(firstGroup, secondGroup, otherExpectedGroups) + /** * Finishes the specification of the sophisticated `contains` assertion where the expected [Order.firstGroup] as well as * the [Order.secondGroup] and optionally [Order.otherExpectedGroups] of identification lambdas, identifying an entry, @@ -37,7 +48,15 @@ infix fun > Builder> Expect.contains(keyValuePair: Pair) = - contains(Pairs(keyValuePair)) + it contains pairs(keyValuePair) /** * Expects the subject of the assertion (a [Map]) contains for each entry in [keyValuePairs], @@ -27,6 +27,9 @@ infix fun > Expect.contains(keyValuePair: Pair) * in [keyValuePairs] is defined as `'a' to 1` and another one is defined as `'a' to 1` as well, then both match, * even though they match the same entry. * + * @param keyValuePairs The key-value [Pairs] expected to be contained within this [Map] + * -- use the function `pairs(x to y, ...)` to create a [Pairs]. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @@ -34,31 +37,43 @@ infix fun > Expect.contains(keyValuePairs: Pairs> Expect.contains(keyValue: KeyValue): Expect = - contains(All(keyValue)) +inline infix fun > Expect.contains(keyValue: KeyWithValueCreator): Expect = + it contains all(keyValue) /** - * Expects that the subject of the assertion (a [Map]) contains for each [KeyValue] in [keyValues], - * a key as defined by [KeyValue.key] with a corresponding value which either holds all - * assertions [KeyValue]'s [KeyValue.valueAssertionCreatorOrNull] creates or needs to be `null` in case - * [KeyValue.valueAssertionCreatorOrNull] is defined as `null` + * Helper function to create a [KeyWithValueCreator] based on the given [key] and [valueAssertionCreatorOrNull] + * -- allows to express `Pair, vararg Pair`. + */ +fun keyValue(key: K, valueAssertionCreatorOrNull: (Expect.() -> Unit)?): KeyWithValueCreator = + KeyWithValueCreator(key, valueAssertionCreatorOrNull) + +/** + * Expects that the subject of the assertion (a [Map]) contains for each [KeyWithValueCreator] in [keyValues], + * a key as defined by [KeyWithValueCreator.key] with a corresponding value which either holds all + * assertions [KeyWithValueCreator]'s [KeyWithValueCreator.valueAssertionCreatorOrNull] creates or needs to be `null` in case + * [KeyWithValueCreator.valueAssertionCreatorOrNull] is defined as `null` * - * Notice, that it does not search for unique matches. Meaning, if the map is `mapOf('a' to 1)` and one [KeyValue] in + * Notice, that it does not search for unique matches. Meaning, if the map is `mapOf('a' to 1)` and one [KeyWithValueCreator] in * [keyValues] is defined as `Key('a') { isGreaterThan(0) }` and another one is defined as `Key('a') { isLessThan(2) }` * , then both match, even though they match the same entry. * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -inline infix fun > Expect.contains(keyValues: All>) = +inline infix fun > Expect.contains(keyValues: All>) = addAssertion(ExpectImpl.map.containsKeyWithValueAssertions(this, V::class, keyValues.toList().map { it.toPair() })) /** diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt index ed7c5f5ae..3ccba991a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/throwableAssertions.kt @@ -36,7 +36,7 @@ infix fun Expect.message(assertionCreator: Expect.() * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Expect.messageContains(expected: Any): Expect = - this messageContains Values(expected) + this messageContains values(expected) /** * Expects that the property [Throwable.message] of the subject of the assertion is not null and contains @@ -45,6 +45,9 @@ infix fun Expect.messageContains(expected: Any): Expect = * Notice that a runtime check applies which assures that only [CharSequence], [Number] and [Char] are passed * (this function expects `Any` for your convenience, so that you can mix [String] and [Int] for instance). * + * @param values The values which are expected to be contained within [Throwable.message] + * -- use the function `values(t, ...)` to create a [Values]. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @@ -60,7 +63,6 @@ infix fun Expect.messageContains(values: Values): Expect * * @since 0.11.0 */ -@Suppress("RemoveExplicitTypeArguments") inline fun Expect.cause(): Expect = ExpectImpl.throwable.cause(this, TExpected::class).getExpectOfFeature() @@ -77,7 +79,6 @@ inline fun Expect.cause(): Expect * * @since 0.11.0 */ -@Suppress("RemoveExplicitTypeArguments") inline infix fun Expect.cause( noinline assertionCreator: Expect.() -> Unit ): Expect = diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index 3f6247c86..ee218dd29 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.verbs.internal.expect import ch.tutteli.atrium.creating.Expect import org.spekframework.spek2.Spek @@ -30,14 +29,14 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ ) {}) include(object : Spek({ - describe("elementsOf") { + describe("atLeast 1 elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { expect("test") contains o atLeast 1 elementsOf emptyList() }.toThrow { it messageContains "Iterable without elements are not allowed" } } } - describe("elementsOf ignoring case") { + describe("ignoring case atLeast 1 elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { expect("test") contains o ignoring case atLeast 1 elementsOf emptyList() @@ -60,10 +59,7 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ): Expect = if (aX.isEmpty()) expect contains o atLeast atLeast value a - else expect contains o atLeast atLeast the Values( - a, - *aX - ) + else expect contains o atLeast atLeast the values(a, *aX) internal fun getAtLeastElementsOfTriple() = atLeastDescr to ("$contains o $atLeast" to Companion::containsAtLeastElementsOf) @@ -92,14 +88,8 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ if (atLeast == 1) expect contains o ignoring case value a else expect contains o ignoring case atLeast atLeast value a } else { - if (atLeast == 1) expect contains o ignoring case the Values( - a, - *aX - ) - else expect contains o ignoring case atLeast atLeast the Values( - a, - *aX - ) + if (atLeast == 1) expect contains o ignoring case the values(a, *aX) + else expect contains o ignoring case atLeast atLeast the values(a, *aX) } private fun getAtLeastIgnoringCaseElementsOfTriple() = @@ -139,10 +129,7 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atLeast atLeast butAtMost butAtMost value a - else expect contains o atLeast atLeast butAtMost butAtMost the Values( - a, - *aX - ) + else expect contains o atLeast atLeast butAtMost butAtMost the values(a, *aX) private val atLeastButAtMostIgnoringCaseDescr = { what: String, timesAtLeast: String, timesAtMost: String -> "$contains $ignoringCase $what $atLeast $timesAtLeast $butAtMost $timesAtMost" @@ -159,10 +146,7 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case atLeast atLeast butAtMost butAtMost value a - else expect contains o ignoring case atLeast atLeast butAtMost butAtMost the Values( - a, - *aX - ) + else expect contains o ignoring case atLeast atLeast butAtMost butAtMost the values(a, *aX) private fun getAtLeastButAtMostIgnoringCaseElementsOfTriple() = atLeastButAtMostIgnoringCaseDescr to ("$contains o $ignoringCase $atLeast $butAtMost" to Companion::containsAtLeastButAtMostIgnoringCaseElementsOf) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt index 5ad778dd8..eb0b2438b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtMostAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect @@ -21,10 +20,7 @@ class CharSequenceContainsAtMostAssertionsSpec : private fun containsAtMost(expect: Expect, atMost: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o atMost atMost value a - else expect contains o atMost atMost the Values( - a, - *aX - ) + else expect contains o atMost atMost the values(a, *aX) private fun getAtMostIgnoringCaseTriple() = { what: String, times: String -> "$contains $ignoringCase $what $atMost $times" } to @@ -32,10 +28,7 @@ class CharSequenceContainsAtMostAssertionsSpec : private fun containsAtMostIgnoringCase(expect: Expect, atMost: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o ignoring case atMost atMost value a - else expect contains o ignoring case atMost atMost the Values( - a, - *aX - ) + else expect contains o ignoring case atMost atMost the values(a, *aX) private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt index f3382cb16..a9e1261f9 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsContainsNotAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun2 import ch.tutteli.atrium.specs.notImplemented @@ -28,42 +27,30 @@ class CharSequenceContainsContainsNotAssertionsSpec : Spek({ private fun containsBuilder(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o atLeast 1 value a - else expect contains o atLeast 1 the Values( - a, - *aX - ) + else expect contains o atLeast 1 the values(a, *aX) private fun getContainsNotPair() = "$containsNot o $atLeast 1 value/the Values" to Companion::containsNotBuilder private fun containsNotBuilder(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the Values( - a, - *aX - ) + else expect containsNot o the values(a, *aX) private fun getContainsShortcutPair() = fun2>(Companion::contains) private fun getContainsNotShortcutPair() = fun2>(Companion::containsNot) private fun contains(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect contains a - else expect contains Values( - a, - *aX - ) + else expect contains values(a, *aX) private fun containsNot(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot a - else expect containsNot Values( - a, - *aX - ) + else expect containsNot values(a, *aX) } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { val a1: Expect = notImplemented() - a1 contains Values(1, "a", 'c') - a1 containsNot Values(1, "a", 'c') + a1 contains values(1, "a", 'c') + a1 containsNot values(1, "a", 'c') } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt index ade0c8665..821d38682 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsExactlyAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect class CharSequenceContainsExactlyAssertionsSpec : @@ -19,10 +18,7 @@ class CharSequenceContainsExactlyAssertionsSpec : private fun containsExactly(expect: Expect, exactly: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o exactly exactly value a - else expect contains o exactly exactly the Values( - a, - *aX - ) + else expect contains o exactly exactly the values(a, *aX) private fun getExactlyIgnoringCaseTriple() = { what: String, times: String -> "$contains $ignoringCase $what $exactly $times" } to @@ -36,10 +32,7 @@ class CharSequenceContainsExactlyAssertionsSpec : aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case exactly exactly value a - else expect contains o ignoring case exactly exactly the Values( - a, - *aX - ) + else expect contains o ignoring case exactly exactly the values(a, *aX) private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot private fun getErrorMsgContainsNot(times: Int) = "use `$containsNotValues` instead of `$exactly $times`" diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt index 42b02cdeb..3f02be243 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceContainsNotAssertionsSpec( @@ -17,10 +16,7 @@ class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integratio private fun containsNotFun(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the Values( - a, - *aX - ) + else expect containsNot o the values(a, *aX) private fun getContainsNotIgnoringCaseTriple() = { what: String -> "$containsNotValues $ignoringCase $what" } to @@ -28,9 +24,6 @@ class CharSequenceContainsNotAssertionsSpec : ch.tutteli.atrium.specs.integratio private fun containsNotIgnoringCase(expect: Expect, a: Any, aX: Array) = if (aX.isEmpty()) expect containsNot o ignoring case value a - else expect containsNot o ignoring case the Values( - a, - *aX - ) + else expect containsNot o ignoring case the values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt index 85686d070..ddbbb88d2 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsNotOrAtMostAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect class CharSequenceContainsNotOrAtMostAssertionsSpec : @@ -19,10 +18,7 @@ class CharSequenceContainsNotOrAtMostAssertionsSpec : private fun containsNotOrAtMost(expect: Expect, atMost: Int, a: Any, aX: Array) = if (aX.isEmpty()) expect contains o notOrAtMost atMost value a - else expect contains o notOrAtMost atMost the Values( - a, - *aX - ) + else expect contains o notOrAtMost atMost the values(a, *aX) private fun getNotOrAtMostIgnoringCaseTriple() = { what: String, times: String -> "$contains $ignoringCase $what $notOrAtMost $times" } to @@ -35,10 +31,7 @@ class CharSequenceContainsNotOrAtMostAssertionsSpec : aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case notOrAtMost atMost value a - else expect contains o ignoring case notOrAtMost atMost the Values( - a, - *aX - ) + else expect contains o ignoring case notOrAtMost atMost the values(a, *aX) private fun getContainsNotPair() = containsNotValues to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt index 47b91cda3..2b2075e50 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsRegexAssertionsSpec.kt @@ -1,7 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.All -import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns import ch.tutteli.atrium.creating.Expect import org.spekframework.spek2.Spek @@ -50,17 +48,11 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atLeast atLeast regex a - else expect contains o atLeast atLeast the RegexPatterns( - a, - *aX - ) + else expect contains o atLeast atLeast the regexPatterns(a, *aX) private fun containsAtLeastRegex(expect: Expect, atLeast: Int, a: String, aX: Array) = if (aX.isEmpty()) expect contains o atLeast atLeast matchFor Regex(a) - else expect contains o atLeast atLeast matchFor All( - Regex(a), - *aX.map { it.toRegex() }.toTypedArray() - ) + else expect contains o atLeast atLeast matchFor all(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) private fun getAtLeastIgnoringCaseTripleString() = { what: String, times: String -> "$contains $ignoringCase $what $atLeast $times" } to @@ -76,14 +68,8 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ if (atLeast == 1) expect contains o ignoring case regex a else expect contains o ignoring case atLeast atLeast regex a } else { - if (atLeast == 1) expect contains o ignoring case the RegexPatterns( - a, - *aX - ) - else expect contains o ignoring case atLeast atLeast the RegexPatterns( - a, - *aX - ) + if (atLeast == 1) expect contains o ignoring case the regexPatterns(a, *aX) + else expect contains o ignoring case atLeast atLeast the regexPatterns(a, *aX) } private fun getShortcutTripleString() = @@ -100,10 +86,7 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect containsRegex a - else expect containsRegex RegexPatterns( - a, - *aX - ) + else expect containsRegex regexPatterns(a, *aX) private fun containsShortcutRegex( expect: Expect, @@ -111,10 +94,7 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains Regex(a) - else expect contains All( - Regex(a), - *aX.map { it.toRegex() }.toTypedArray() - ) + else expect contains all(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) private fun getAtMostTripleString() = @@ -132,10 +112,7 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atMost atMost regex a - else expect contains o atMost atMost the RegexPatterns( - a, - *aX - ) + else expect contains o atMost atMost the regexPatterns(a, *aX) private fun getAtMostIgnoringCaseTripleString() = { what: String, times: String -> "$contains $ignoringCase $what $atMost $times" } to @@ -148,10 +125,7 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o atMost atMost matchFor Regex(a) - else expect contains o atMost atMost matchFor All( - Regex(a), - *aX.map { it.toRegex() }.toTypedArray() - ) + else expect contains o atMost atMost matchFor all(Regex(a), *aX.map { it.toRegex() }.toTypedArray()) private fun containsAtMostIgnoringCase( expect: Expect, @@ -160,9 +134,6 @@ class CharSequenceContainsRegexAssertionsSpec : Spek({ aX: Array ) = if (aX.isEmpty()) expect contains o ignoring case atMost atMost regex a - else expect contains o ignoring case atMost atMost the RegexPatterns( - a, - *aX - ) + else expect contains o ignoring case atMost atMost the regexPatterns(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index ccfde8573..c6383d442 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -1,10 +1,8 @@ package ch.tutteli.atrium.api.infix.en_GB +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption -import ch.tutteli.atrium.api.infix.en_GB.creating.All -import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour @@ -24,7 +22,7 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { protected val containsNot = containsNotProp.name private val containsNotFun: KFunction2, Any, Expect> = Expect::containsNot - protected val containsNotValues = "${containsNotFun.name} ${Values::class.simpleName}" + protected val containsNotValues = "${containsNotFun.name} values" protected val containsRegex = fun1(Expect::containsRegex).name protected val atLeast = CharSequenceContains.Builder<*, *>::atLeast.name protected val butAtMost = AtLeastCheckerOption<*, *>::butAtMost.name @@ -45,87 +43,59 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { val a1: Expect = notImplemented() a1 contains o atLeast 1 value 1 - a1 contains o atMost 2 the Values( - "a", - 1 - ) + a1 contains o atMost 2 the values("a", 1) a1 contains o notOrAtMost 2 regex "h|b" - a1 contains o exactly 2 the RegexPatterns( - "h|b", - "b" - ) + a1 contains o exactly 2 the regexPatterns("h|b", "b") a1 contains o atLeast 2 matchFor Regex("bla") - a1 contains o atLeast 2 matchFor All( - Regex("bla"), - Regex("b") - ) + a1 contains o atLeast 2 matchFor all(Regex("bla"), Regex("b")) a1 contains o atLeast 2 elementsOf listOf(1, 2) a1 containsNot o value "a" - a1 containsNot o the Values("a", 'b') + a1 containsNot o the values("a", 'b') a1 containsNot o regex "a" - a1 containsNot o the RegexPatterns( - "a", - "bl" - ) + a1 containsNot o the regexPatterns("a", "bl") + a1 containsNot o matchFor Regex("a") + a1 containsNot o matchFor all(Regex("a"), Regex("bl")) a1 containsNot o elementsOf listOf(1, 2) a1 contains o ignoring case atLeast 1 value "a" - a1 contains o ignoring case atLeast 1 the Values( - "a", - 'b' - ) + a1 contains o ignoring case atLeast 1 the values("a", 'b') a1 contains o ignoring case atLeast 1 regex "a" - a1 contains o ignoring case atLeast 1 the RegexPatterns( - "a", - "bl" - ) + a1 contains o ignoring case atLeast 1 the regexPatterns("a", "bl") + // not supported on purpose as one can specify an ignore case flag for Regex + // and hence these would be a second way to do the same thing + //a1 contains o ignoring case atLeast 1 matchFor Regex("a") + //a1 contains o ignoring case atLeast 1 matchFor all(Regex("a"), Regex("bl")) a1 contains o ignoring case atLeast 1 elementsOf listOf(1, 2) a1 containsNot o ignoring case value "a" - a1 containsNot o ignoring case the Values( - "a", - 'b' - ) + a1 containsNot o ignoring case the values("a", 'b') a1 containsNot o ignoring case regex "a" - a1 containsNot o ignoring case the RegexPatterns( - "a", - "bl" - ) + a1 containsNot o ignoring case the regexPatterns("a", "bl") + // not supported on purpose as one can specify an ignore case flag for Regex + // and hence these would be a second way to do the same thing + //a1 containsNot o ignoring case matchFor Regex("a") + //a1 containsNot o ignoring case matchFor all(Regex("a"), Regex("bl")) a1 containsNot o ignoring case elementsOf listOf(1, 2) // skip atLeast a1 contains o ignoring case value "a" - a1 contains o ignoring case the Values( - "a", - 'b' - ) + a1 contains o ignoring case the values("a", 'b') a1 contains o ignoring case regex "a" - a1 contains o ignoring case the RegexPatterns( - "a", - "bl" - ) + a1 contains o ignoring case the regexPatterns("a", "bl") + // not supported on purpose as one can specify an ignore case flag for Regex + // and hence these would be a second way to do the same thing + //a1 contains o ignoring case matchFor Regex("a") + //a1 contains o ignoring case matchFor all(Regex("a"), Regex("bl")) //TODO #422 uncomment //a1 contains o ignoring case elementsOf listOf("a", 2) a1 and { it contains o atLeast 1 value 1 } - a1 and { it contains o atMost 2 the Values( - "a", - 1 - ) - } + a1 and { it contains o atMost 2 the values("a", 1) } a1 and { it contains o notOrAtMost 2 regex "h|b" } - a1 and { it contains o exactly 2 the RegexPatterns( - "h|b", - "b" - ) - } + a1 and { it contains o exactly 2 the regexPatterns("h|b", "b") } a1 and { it contains o atLeast 2 matchFor Regex("bla") } - a1 and { it contains o atLeast 2 matchFor All( - Regex("bla"), - Regex("b") - ) - } + a1 and { it contains o atLeast 2 matchFor all(Regex("bla"), Regex("b")) } a1 and { it contains o atLeast 2 elementsOf listOf(1, 2) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt index 232baf974..343a24db3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionFeatureAssertionsSpec.kt @@ -1,10 +1,10 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CollectionFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionFeatureAssertionsSpec( property, Int>(Expect>::size), diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt index 8d706bd04..78849e7b7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec.kt @@ -32,10 +32,7 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a - else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect contains o inAny order atLeast 1 the entries(a, *aX) fun getContainsNullablePair() = "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsNullableEntries @@ -46,10 +43,7 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a - else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect contains o inAny order atLeast 1 the entries(a, *aX) private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = @@ -63,7 +57,7 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(a, *aX) + else expect contains entries(a, *aX) private val containsEntriesFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = Expect>::contains @@ -76,6 +70,6 @@ class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({ aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(a, *aX) + else expect contains entries(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt index 28c6dc6ae..76ec10a79 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec.kt @@ -32,10 +32,7 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a - else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order atLeast 1 the values(a, *aX) fun getContainsNullablePair() = "$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsNullableValues @@ -46,10 +43,7 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a - else expect contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order atLeast 1 the values(a, *aX) private val containsFun: KFunction2>, Double, Expect>> = @@ -63,10 +57,7 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains values(a, *aX) private val containsNullableFun: KFunction2>, Double?, Expect>> = @@ -80,10 +71,7 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains a - else expect contains ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt index 652c28703..0368a99b3 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeastValuesAssertionsSpec.kt @@ -25,10 +25,7 @@ class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order atLeast atLeast value a - else expect contains o inAny order atLeast atLeast the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order atLeast atLeast the values(a, *aX) private fun getAtLeastButAtMostTriple() = @@ -41,10 +38,7 @@ class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec : butAtMost: Int, a: Double, aX: Array - ) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + ) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the values(a, *aX) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt index 34b10897c..b352121a4 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtMostValuesAssertionsSpec.kt @@ -18,10 +18,7 @@ class IterableContainsInAnyOrderAtMostValuesAssertionsSpec : private fun containsAtMost(expect: Expect>, atMost: Int, a: Double, aX: Array) = if(aX.isEmpty()) expect contains o inAny order atMost atMost value a - else expect contains o inAny order atMost atMost the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order atMost atMost the values(a, *aX) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt index ec91974cf..0359da21a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderExactlyValuesAssertionsSpec.kt @@ -22,10 +22,7 @@ class IterableContainsInAnyOrderExactlyValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order exactly exactly value a - else expect contains o inAny order exactly exactly the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order exactly exactly the values(a, *aX) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt index 383053336..b604411be 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec.kt @@ -22,10 +22,7 @@ class IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec : aX: Array ) = if (aX.isEmpty()) expect contains o inAny order notOrAtMost atMost value a - else expect contains o inAny order notOrAtMost atMost the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order notOrAtMost atMost the values(a, *aX) private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt index 11ea329aa..4e38603d9 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyEntriesAssertionsSpec.kt @@ -18,10 +18,7 @@ class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec : aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only entry a - else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect contains o inAny order but only the entries(a, *aX) fun getContainsNullablePair() = @@ -33,10 +30,7 @@ class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec : aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only entry a - else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect contains o inAny order but only the entries(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt index 2587a4d12..c3c3cefef 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyValuesAssertionsSpec.kt @@ -18,10 +18,7 @@ class IterableContainsInAnyOrderOnlyValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only value a - else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order but only the values(a, *aX) fun getContainsNullablePair() = @@ -33,10 +30,7 @@ class IterableContainsInAnyOrderOnlyValuesAssertionsSpec : aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inAny order but only value a - else expect contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inAny order but only the values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt index 5a9b69917..77419490b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesAssertionsSpec.kt @@ -34,10 +34,7 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only entry a - else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect contains o inGiven order and only the entries(a, *aX) fun getContainsNullablePair() = "$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnlyNullableEntriesPair @@ -48,10 +45,7 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only entry a - else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect contains o inGiven order and only the entries(a, *aX) private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = Expect>::containsExactly @@ -64,10 +58,7 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect containsExactly { a() } - else expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect containsExactly entries(a, *aX) private val containsNullableShortcutFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = Expect>::containsExactly @@ -85,10 +76,7 @@ class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({ if (a == null) expect containsExactly a as Double? else expect containsExactly { a() } } else { - expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + expect containsExactly entries(a, *aX) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt index 90d17fbc8..902631744 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec.kt @@ -1,7 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Entry -import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.Group @@ -22,22 +20,15 @@ class IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec : a2: Group<(Expect.() -> Unit)?>, aX: Array.() -> Unit)?>> ): Expect> = - expect contains o inGiven order and only grouped entries within group inAny Order( - a1, - a2, - *aX - ) + expect contains o inGiven order and only grouped entries within group inAny order(a1, a2, *aX) private fun groupFactory(groups: Array.() -> Unit)?>) = when (groups.size) { 0 -> object : Group<(Expect.() -> Unit)?> { override fun toList() = listOf.() -> Unit>() } - 1 -> Entry(groups[0]) - else -> ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - groups[0], - *groups.drop(1).toTypedArray() - ) + 1 -> entry(groups[0]) + else -> entries(groups[0], *groups.drop(1).toTypedArray()) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt index 30d74cd99..b0ec0b05e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyGroupedValuesAssertionsSpec.kt @@ -1,7 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order -import ch.tutteli.atrium.api.infix.en_GB.creating.Value import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.Group @@ -23,24 +21,16 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : a1: Group, a2: Group, aX: Array> - ): Expect> { - return expect contains o inGiven order and only grouped entries within group inAny Order( - a1, - a2, - *aX - ) - } + ): Expect> = + expect contains o inGiven order and only grouped entries within group inAny order(a1, a2, *aX) private fun groupFactory(groups: Array): Group = when (groups.size) { 0 -> object : Group { override fun toList() = listOf() } - 1 -> Value(groups[0]) - else -> ch.tutteli.atrium.api.infix.en_GB.creating.Values( - groups[0], - *groups.drop(1).toTypedArray() - ) + 1 -> value(groups[0]) + else -> values(groups[0], *groups.drop(1).toTypedArray()) } @@ -52,24 +42,16 @@ class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec : a1: Group, a2: Group, aX: Array> - ): Expect> { - return expect contains o inGiven order and only grouped entries within group inAny Order( - a1, - a2, - *aX - ) - } + ): Expect> = + expect contains o inGiven order and only grouped entries within group inAny order(a1, a2, *aX) private fun nullableGroupFactory(groups: Array): Group = when (groups.size) { 0 -> object : Group { override fun toList() = listOf() } - 1 -> Value(groups[0]) - else -> ch.tutteli.atrium.api.infix.en_GB.creating.Values( - groups[0], - *groups.drop(1).toTypedArray() - ) + 1 -> value(groups[0]) + else -> values(groups[0], *groups.drop(1).toTypedArray()) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt index ca9d910da..08affe3d0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesAssertionsSpec.kt @@ -25,7 +25,8 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ ) companion object : IterableContainsSpecBase() { - fun getContainsPair() = "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyValues + fun getContainsPair() = + "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyValues private fun containsInOrderOnlyValues( expect: Expect>, @@ -33,10 +34,7 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only value a - else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inGiven order and only the values(a, *aX) fun getContainsNullablePair() = "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyNullableValues @@ -47,10 +45,7 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect contains o inGiven order and only value a - else expect contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect contains o inGiven order and only the values(a, *aX) private val containsShortcutFun: KFunction2>, Double, Expect>> = Expect>::containsExactly @@ -63,10 +58,7 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsExactly a - else expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect containsExactly values(a, *aX) private val containsNullableShortcutFun: KFunction2>, Double?, Expect>> = Expect>::containsExactly @@ -80,10 +72,7 @@ class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsExactly a - else expect containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect containsExactly values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt index a8233c5e3..c2c02a757 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotEntriesAssertionsSpec.kt @@ -20,10 +20,7 @@ class IterableContainsNotEntriesAssertionsSpec : aX: Array.() -> Unit> ): Expect> = if (aX.isEmpty()) expect containsNot o entry a - else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect containsNot o the entries(a, *aX) private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun @@ -33,9 +30,6 @@ class IterableContainsNotEntriesAssertionsSpec : aX: Array.() -> Unit)?> ): Expect> = if (aX.isEmpty()) expect containsNot o entry a - else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - a, - *aX - ) + else expect containsNot o the entries(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt index a77c304f7..1ac89a197 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesAssertionsSpec.kt @@ -35,10 +35,7 @@ class IterableContainsNotValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect containsNot o the values(a, *aX) private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun @@ -48,10 +45,7 @@ class IterableContainsNotValuesAssertionsSpec : Spek({ aX: Array ): Expect> = if (aX.isEmpty()) expect containsNot o value a - else expect containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect containsNot o the values(a, *aX) private val containsNotShortcutFun: KFunction2>, Double, Expect>> = Expect>::containsNot @@ -60,9 +54,6 @@ class IterableContainsNotValuesAssertionsSpec : Spek({ private fun containsNotShortcut(expect: Expect>, a: Double, aX: Array) = if (aX.isEmpty()) expect containsNot a - else expect containsNot ch.tutteli.atrium.api.infix.en_GB.creating.Values( - a, - *aX - ) + else expect containsNot values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt index 221e040cf..140e5ce4a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt @@ -1,9 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.Values -import ch.tutteli.atrium.api.infix.en_GB.creating.Entry import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order -import ch.tutteli.atrium.api.infix.en_GB.creating.Value import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption import ch.tutteli.atrium.creating.Expect @@ -15,8 +13,8 @@ import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import kotlin.reflect.KFunction2 abstract class IterableContainsSpecBase : WithAsciiReporter() { - protected val Values = ch.tutteli.atrium.api.infix.en_GB.creating.Values::class.simpleName - private val Entries = ch.tutteli.atrium.api.infix.en_GB.creating.Entries::class.simpleName + private val Values = "values" + private val Entries = "entries" //@formatter:off protected val atLeast = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::atLeast.name @@ -72,448 +70,256 @@ abstract class IterableContainsSpecBase : WithAsciiReporter() { list contains 1 list contains 1f - list contains Values(1, 2f) + list contains values(1, 2f) list contains {} - list contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + list contains entries({}, {}) list containsNot 1 list containsNot 1f - list containsNot Values(1, 2f) + list containsNot values(1, 2f) list containsNot o entry {} - list containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + list containsNot o the entries({}, {}) subList contains 1 - subList contains 1f - subList contains Values(1, 2f) + subList contains 1f; subList contains values(1, 2f) subList contains {} - subList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + subList contains entries({}, {}) subList containsNot 1 subList containsNot 1f - subList containsNot Values(1, 2f) + subList containsNot values(1, 2f) subList containsNot o entry {} - subList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + subList containsNot o the entries({}, {}) nullableList contains 1 nullableList contains 1f - nullableList contains Values(1, 2f) + nullableList contains values(1, 2f) nullableList contains {} - nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + nullableList contains entries({}, {}) nullableList containsNot 1 nullableList containsNot 1f - nullableList containsNot Values( - 1, - 2f - ) + nullableList containsNot values(1, 2f) nullableList containsNot o entry {} - nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + nullableList containsNot o the entries({}, {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) nullableList contains null as Number? - nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) - nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) - nullableList contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) + nullableList contains entries(null, {}) + nullableList contains entries({}, null) + nullableList contains entries(null, null) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) nullableList containsNot null as Number? - nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - nullableList containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + nullableList containsNot o the entries(null, {}) + nullableList containsNot o the entries({}, null) + nullableList containsNot o the entries(null, null) star contains 1 star contains 1f - star contains Values(1, 2f) + star contains values(1, 2f) star contains {} - star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + star contains entries({}, {}) star containsNot 1 star containsNot 1f - star containsNot Values(1, 2f) + star containsNot values(1, 2f) star containsNot o entry {} - star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + star containsNot o the entries({}, {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) star contains (null as Number?) - star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) - star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) - star contains ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) + star contains entries(null, {}) + star contains entries({}, null) + star contains entries(null, null) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) star containsNot (null as Number?) - star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) - star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) - star containsNot o the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + star containsNot o the entries(null, {}) + star containsNot o the entries({}, null) + star containsNot o the entries(null, null) list containsExactly 1 - list containsExactly Values(1, 2f) + list containsExactly values(1, 2f) list containsExactly {} - list containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + list containsExactly entries({}, {}) subList containsExactly 1 - subList containsExactly Values(1, 2f) + subList containsExactly values(1, 2f) subList containsExactly {} - subList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + subList containsExactly entries({}, {}) nullableList containsExactly 1 - nullableList containsExactly Values( - 1, - 2f - ) + nullableList containsExactly values(1, 2f) nullableList containsExactly {} - nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + nullableList containsExactly entries({}, {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) nullableList containsExactly (null as (Expect.() -> Unit)?) - nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - nullableList containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + nullableList containsExactly entries({}, null) + nullableList containsExactly entries(null, {}) + nullableList containsExactly entries(null, null) star containsExactly 1 - star containsExactly Values(1, 2f) + star containsExactly values(1, 2f) star containsExactly {} - star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) + star containsExactly entries({}, {}) //TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4) star containsExactly (null as (Expect.() -> Unit)?) - star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null) - star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}) - star containsExactly ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) + star containsExactly entries({}, null) + star containsExactly entries(null, {}) + star containsExactly entries(null, null) list contains o inAny order atLeast 1 value 1 - list contains o inAny order atLeast 1 the Values( - 2, - 1 - ) + list contains o inAny order atLeast 1 the values(2, 1) list contains o inAny order atLeast 1 entry {} - list contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + list contains o inAny order atLeast 1 the entries({}, {}) list contains o inAny order atLeast 1 elementsOf listOf(1, 2) subList contains o inAny order atLeast 1 value 1 - subList contains o inAny order atLeast 1 the Values( - 2, - 1 - ) + subList contains o inAny order atLeast 1 the values(2, 1) subList contains o inAny order atLeast 1 entry {} - subList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + subList contains o inAny order atLeast 1 the entries({}, {}) subList contains o inAny order atLeast 1 elementsOf listOf(1, 2) nullableList contains o inAny order atLeast 1 value 1 - nullableList contains o inAny order atLeast 1 the Values( - 2, - 1 - ) + nullableList contains o inAny order atLeast 1 the values(2, 1) nullableList contains o inAny order atLeast 1 entry {} - nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + nullableList contains o inAny order atLeast 1 the entries({}, {}) nullableList contains o inAny order atLeast 1 elementsOf listOf(1, 2) nullableList contains o inAny order atLeast 1 value null - nullableList contains o inAny order atLeast 1 the Values( - null, - 1 - ) - nullableList contains o inAny order atLeast 1 the Values( - 2, - null - ) - nullableList contains o inAny order atLeast 1 the Values( - null, - null - ) + nullableList contains o inAny order atLeast 1 the values(null, 1) + nullableList contains o inAny order atLeast 1 the values(2, null) + nullableList contains o inAny order atLeast 1 the values(null, null) nullableList contains o inAny order atLeast 1 entry null - nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - nullableList contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + nullableList contains o inAny order atLeast 1 the entries(null, {}) + nullableList contains o inAny order atLeast 1 the entries({}, null) + nullableList contains o inAny order atLeast 1 the entries(null, null) star contains o inAny order atLeast 1 value 1 - star contains o inAny order atLeast 1 the Values( - 2, - 1 - ) + star contains o inAny order atLeast 1 the values(2, 1) star contains o inAny order atLeast 1 entry {} - star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + star contains o inAny order atLeast 1 the entries({}, {}) star contains o inAny order atLeast 1 elementsOf listOf(1, 2) star contains o inAny order atLeast 1 value null - star contains o inAny order atLeast 1 the Values( - null, - 1 - ) - star contains o inAny order atLeast 1 the Values( - 2, - null - ) - star contains o inAny order atLeast 1 the Values( - null, - null - ) + star contains o inAny order atLeast 1 the values(null, 1) + star contains o inAny order atLeast 1 the values(2, null) + star contains o inAny order atLeast 1 the values(null, null) star contains o inAny order atLeast 1 entry null - star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - star contains o inAny order atLeast 1 the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + star contains o inAny order atLeast 1 the entries(null, {}) + star contains o inAny order atLeast 1 the entries({}, null) + star contains o inAny order atLeast 1 the entries(null, null) list contains o inAny order but only value 1 - list contains o inAny order but only the Values( - 2, - 1 - ) + list contains o inAny order but only the values(2, 1) list contains o inAny order but only entry {} - list contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + list contains o inAny order but only the entries({}, {}) list contains o inAny order but only elementsOf listOf(1, 2) subList contains o inAny order but only value 1 - subList contains o inAny order but only the Values( - 2, - 1 - ) + subList contains o inAny order but only the values(2, 1) subList contains o inAny order but only entry {} - subList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + subList contains o inAny order but only the entries({}, {}) subList contains o inAny order but only elementsOf listOf(1, 2) nullableList contains o inAny order but only value 1 - nullableList contains o inAny order but only the Values( - 2, - 1 - ) + nullableList contains o inAny order but only the values(2, 1) nullableList contains o inAny order but only entry {} - nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + nullableList contains o inAny order but only the entries({}, {}) nullableList contains o inAny order but only elementsOf listOf(1, 2) nullableList contains o inAny order but only value null - nullableList contains o inAny order but only the Values( - null, - 1 - ) - nullableList contains o inAny order but only the Values( - 2, - null - ) - nullableList contains o inAny order but only the Values( - null, - null - ) + nullableList contains o inAny order but only the values(null, 1) + nullableList contains o inAny order but only the values(2, null) + nullableList contains o inAny order but only the values(null, null) nullableList contains o inAny order but only entry null - nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - nullableList contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + nullableList contains o inAny order but only the entries(null, {}) + nullableList contains o inAny order but only the entries({}, null) + nullableList contains o inAny order but only the entries(null, null) star contains o inAny order but only value 1 - star contains o inAny order but only the Values( - 2, - 1 - ) + star contains o inAny order but only the values(2, 1) star contains o inAny order but only entry {} - star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + star contains o inAny order but only the entries({}, {}) star contains o inAny order but only elementsOf listOf(1, 2) star contains o inAny order but only value null - star contains o inAny order but only the Values( - null, - 1 - ) - star contains o inAny order but only the Values( - 2, - null - ) - star contains o inAny order but only the Values( - null, - null - ) + star contains o inAny order but only the values(null, 1) + star contains o inAny order but only the values(2, null) + star contains o inAny order but only the values(null, null) star contains o inAny order but only entry null - star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - star contains o inAny order but only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + star contains o inAny order but only the entries(null, {}) + star contains o inAny order but only the entries({}, null) + star contains o inAny order but only the entries(null, null) list contains o inGiven order and only value 1 - list contains o inGiven order and only the Values( - 2, - 1 - ) + list contains o inGiven order and only the values(2, 1) list contains o inGiven order and only entry {} - list contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + list contains o inGiven order and only the entries({}, {}) list contains o inGiven order and only elementsOf listOf(1, 2) subList contains o inGiven order and only value 1 - subList contains o inGiven order and only the Values( - 2, - 1 - ) + subList contains o inGiven order and only the values(2, 1) subList contains o inGiven order and only entry {} - subList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + subList contains o inGiven order and only the entries({}, {}) subList contains o inGiven order and only elementsOf listOf(1, 2) nullableList contains o inGiven order and only value 1 - nullableList contains o inGiven order and only the Values( - 2, - 1 - ) + nullableList contains o inGiven order and only the values(2, 1) nullableList contains o inGiven order and only entry {} - nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + nullableList contains o inGiven order and only the entries({}, {}) nullableList contains o inGiven order and only elementsOf listOf(1, 2) nullableList contains o inGiven order and only value null - nullableList contains o inGiven order and only the Values( - null, - 1 - ) - nullableList contains o inGiven order and only the Values( - 2, - null - ) - nullableList contains o inGiven order and only the Values( - null, - null - ) + nullableList contains o inGiven order and only the values(null, 1) + nullableList contains o inGiven order and only the values(2, null) + nullableList contains o inGiven order and only the values(null, null) nullableList contains o inGiven order and only entry null - nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null - ) - nullableList contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null - ) + nullableList contains o inGiven order and only the entries(null, {}) + nullableList contains o inGiven order and only the entries({}, null) + nullableList contains o inGiven order and only the entries(null, null) star contains o inGiven order and only value 1 - star contains o inGiven order and only the Values( - 2, - 1 - ) + star contains o inGiven order and only the values(2, 1) star contains o inGiven order and only entry {} - star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - {}) + star contains o inGiven order and only the entries({}, {}) star contains o inGiven order and only elementsOf listOf(1, 2) star contains o inGiven order and only value null - star contains o inGiven order and only the Values( - null, - 1 - ) - star contains o inGiven order and only the Values( - 2, - null - ) - star contains o inGiven order and only the Values( - null, - null - ) + star contains o inGiven order and only the values(null, 1) + star contains o inGiven order and only the values(2, null) + star contains o inGiven order and only the values(null, null) star contains o inGiven order and only entry null - star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - {}) - star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - {}, - null + star contains o inGiven order and only the entries(null, {}) + star contains o inGiven order and only the entries({}, null) + star contains o inGiven order and only the entries(null, null) + + list contains o inGiven order and only grouped entries within group inAny order( + value(1), + values(1f), + values(1f, 1) ) - star contains o inGiven order and only the ch.tutteli.atrium.api.infix.en_GB.creating.Entries( - null, - null + subList contains o inGiven order and only grouped entries within group inAny order( + value(1), + values(1f), + values(1f, 1) + ) + nullableList contains o inGiven order and only grouped entries within group inAny order( + value(null), + values(null), + values(null, 2), + values(1, null), + values(null, null) + ) + star contains o inGiven order and only grouped entries within group inAny order( + value(null), + values(null), + values(null, 2), + values(1, null), + values(null, null) ) - list contains o inGiven order and only grouped entries within group inAny Order( - Value(1), - Values(1f), - Values(1f, 1) + list contains o inGiven order and only grouped entries within group inAny order( + entry {}, + entries({}), + entries({}, {}) ) - subList contains o inGiven order and only grouped entries within group inAny Order( - Value(1), - Values(1f), - Values(1f, 1) + subList contains o inGiven order and only grouped entries within group inAny order( + entry {}, + entries({}), + entries({}, {}) ) - nullableList contains o inGiven order and only grouped entries within group inAny Order( - Value(null), - Values(null), - Values(null, 2), - Values(1, null), - Values(null, null) + nullableList contains o inGiven order and only grouped entries within group inAny order( + entry(null), + entries(null), + entries(null, {}), + entries({}, null), + entries(null, null) ) - star contains o inGiven order and only grouped entries within group inAny Order( - Value(null), - Values(null), - Values(null, 2), - Values(1, null), - Values(null, null) - ) - - list contains o inGiven order and only grouped entries within group inAny Order( - Entry {}, - ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) - ) - subList contains o inGiven order and only grouped entries within group inAny Order( - Entry {}, - ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, {}) - ) - nullableList contains o inGiven order and only grouped entries within group inAny Order( - Entry(null), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) - ) - star contains o inGiven order and only grouped entries within group inAny Order( - Entry(null), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, {}), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries({}, null), - ch.tutteli.atrium.api.infix.en_GB.creating.Entries(null, null) + star contains o inGiven order and only grouped entries within group inAny order( + entry(null), + entries(null), + entries(null, {}), + entries({}, null), + entries(null, null) ) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index 88a60ee72..d6805d28d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -1,20 +1,19 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.All -import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyValue -import ch.tutteli.atrium.api.infix.en_GB.creating.Pairs import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.utils.mapArguments -import ch.tutteli.atrium.specs.* +import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.integration.mfun2 +import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import ch.tutteli.atrium.specs.withNullableSuffix import kotlin.jvm.JvmName class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( mfun2(Companion::contains), mfun2(Companion::contains).withNullableSuffix(), - mfun2.() -> Unit>(Companion::contains).adjustName { "$it ${KeyValue::class.simpleName}" }, - mfun2.() -> Unit)?>(Companion::contains).adjustName { "$it ${KeyValue::class.simpleName}" }.withNullableSuffix(), + mfun2.() -> Unit>(Companion::contains), + mfun2.() -> Unit)?>(Companion::contains).withNullableSuffix(), fun1, String>(Companion::containsKey), fun1, String?>(Companion::containsKey).withNullableSuffix(), fun1, String>(Companion::containsNotKey), @@ -22,90 +21,46 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( "toBe ${Empty::class.simpleName}" to Companion::isEmpty, "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty ) { - companion object : WithAsciiReporter(){ + companion object : WithAsciiReporter() { private fun contains( expect: Expect>, pair: Pair, otherPairs: Array> - ): Expect> { - return if (otherPairs.isEmpty()) { - expect contains (pair.first to pair.second) - } else { - expect contains Pairs( - pair, - *otherPairs - ) - } - } + ): Expect> = + if (otherPairs.isEmpty()) expect contains (pair.first to pair.second) + else expect contains pairs(pair, *otherPairs) @JvmName("containsNullable") private fun contains( expect: Expect>, pair: Pair, otherPairs: Array> - ): Expect> { - return if (otherPairs.isEmpty()) { - expect contains (pair.first to pair.second) - } else { - expect contains Pairs( - pair, - *otherPairs - ) - } - } + ): Expect> = + if (otherPairs.isEmpty()) expect contains (pair.first to pair.second) + else expect contains pairs(pair, *otherPairs) @JvmName("containsKeyWithValueAssertions") private fun contains( expect: Expect>, keyValue: Pair.() -> Unit>, otherKeyValues: Array.() -> Unit>> - ): Expect> { - return if (otherKeyValues.isEmpty()) { - expect contains KeyValue( - keyValue.first, - keyValue.second - ) - } else { - mapArguments(keyValue, otherKeyValues).to { - KeyValue( - it.first, - it.second - ) - }.let { (first, others) -> - expect contains All( - first, - *others - ) - } - } - } + ): Expect> = + if (otherKeyValues.isEmpty()) expect contains keyValue(keyValue.first, keyValue.second) + else mapArguments(keyValue, otherKeyValues) + .to { keyValue(it.first, it.second) } + .let { (first, others) -> expect contains all(first, *others) } @JvmName("containsKeyWithNullableValueAssertions") private fun contains( expect: Expect>, keyValue: Pair.() -> Unit)?>, otherKeyValues: Array.() -> Unit)?>> - ): Expect> { - return if (otherKeyValues.isEmpty()) { - expect contains KeyValue( - keyValue.first, - keyValue.second - ) - } else { - mapArguments(keyValue, otherKeyValues).to { - KeyValue( - it.first, - it.second - ) - }.let { (first, others) -> - expect contains All( - first, - *others - ) - } - } - } + ): Expect> = + if (otherKeyValues.isEmpty()) expect contains keyValue(keyValue.first, keyValue.second) + else mapArguments(keyValue, otherKeyValues) + .to { keyValue(it.first, it.second) } + .let { (first, others) -> expect contains all(first, *others) } private fun containsKey(expect: Expect>, key: String) = expect containsKey key @@ -138,301 +93,120 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( var starMap: Expect> = notImplemented() map contains (1 to "a") - map contains Pairs(1 to "a", 2 to "b") - map contains KeyValue(1) {} - map contains All( - KeyValue(1) {}, - KeyValue(2) {}) - map contains Pairs(1.0 to StringBuilder("a")) - map contains Pairs( - 12f to "a", - 2L to StringBuilder("b") - ) - map contains KeyValue(1) {} - map contains All( - KeyValue(1) {}, - KeyValue(2) {}) - + map contains pairs(1 to "a", 2 to "b") + map contains keyValue(1) {} + map contains all(keyValue(1) {}, keyValue(2) {}) + map contains pairs(1.0 to StringBuilder("a")) + map contains pairs(12f to "a", 2L to StringBuilder("b")) + map contains keyValue(1) {} + map contains all(keyValue(1) {}, keyValue(2) {}) subMap contains (1 to "a") - subMap contains Pairs(1 to "a", 2 to "b") - subMap contains KeyValue(1) {} - subMap contains All( - KeyValue(1) {}, - KeyValue(2) {}) + subMap contains pairs(1 to "a", 2 to "b") + subMap contains keyValue(1) {} + subMap contains all(keyValue(1) {}, keyValue(2) {}) subMap contains (1.0 to StringBuilder("a")) - subMap contains Pairs( - 12f to "a", - 2L to StringBuilder("b") - ) - subMap contains KeyValue(1) {} - subMap contains All( - KeyValue(1) {}, - KeyValue(2) {}) + subMap contains pairs(12f to "a", 2L to StringBuilder("b")) + subMap contains keyValue(1) {} + subMap contains all(keyValue(1) {}, keyValue(2) {}) nullableKeyMap contains (1 to "a") - nullableKeyMap contains Pairs( - 1 to "a", - 2 to "b" - ) - nullableKeyMap contains KeyValue(1) {} - nullableKeyMap contains All( - KeyValue(1) {}, - KeyValue(2) {}) + nullableKeyMap contains pairs(1 to "a", 2 to "b") + nullableKeyMap contains keyValue(1) {} + nullableKeyMap contains all(keyValue(1) {}, keyValue(2) {}) nullableKeyMap contains (null to "a") - nullableKeyMap contains Pairs( - null to "a", - null to "b" - ) - nullableKeyMap contains Pairs( - null to "a", - 2 to "b" - ) - nullableKeyMap contains (KeyValue(null) {}) - nullableKeyMap contains All( - KeyValue(null) {}, - KeyValue(null) {}) - nullableKeyMap contains All( - KeyValue(null) {}, - KeyValue(2) {}) + nullableKeyMap contains pairs(null to "a", null to "b") + nullableKeyMap contains pairs(null to "a", 2 to "b") + nullableKeyMap contains (keyValue(null) {}) + nullableKeyMap contains all(keyValue(null) {}, keyValue(null) {}) + nullableKeyMap contains all(keyValue(null) {}, keyValue(2) {}) nullableValueMap contains (1 to "a") - nullableValueMap contains Pairs( - 1 to "a", - 2 to "b" - ) - nullableValueMap contains KeyValue(1) {} - nullableValueMap contains All( - KeyValue(1) {}, - KeyValue(2) {}) + nullableValueMap contains pairs(1 to "a", 2 to "b") + nullableValueMap contains keyValue(1) {} + nullableValueMap contains all(keyValue(1) {}, keyValue(2) {}) nullableValueMap contains (1 to null) - nullableValueMap contains Pairs( - 1 to null, - 2 to null - ) - nullableValueMap contains Pairs( - 1 to null, - 2 to "a" - ) - nullableValueMap contains (KeyValue(1, null)) - nullableValueMap contains All( - KeyValue( - 1, - null - ), KeyValue(2, null) - ) - nullableValueMap contains All( - KeyValue( - 1, - null - ), KeyValue(2) {}) - + nullableValueMap contains pairs(1 to null, 2 to null) + nullableValueMap contains pairs(1 to null, 2 to "a") + nullableValueMap contains (keyValue(1, null)) + nullableValueMap contains all(keyValue(1, null), keyValue(2, null)) + nullableValueMap contains all(keyValue(1, null), keyValue(2) {}) nullableKeyValueMap contains (1 to "a") - nullableKeyValueMap contains Pairs( - 1 to "a", - 2 to "b" - ) - nullableKeyValueMap contains KeyValue(1) {} - nullableKeyValueMap contains All( - KeyValue( - 1 - ) {}, KeyValue(2) {}) + nullableKeyValueMap contains pairs(1 to "a", 2 to "b") + nullableKeyValueMap contains keyValue(1) {} + nullableKeyValueMap contains all(keyValue(1) {}, keyValue(2) {}) nullableKeyValueMap contains (null to "a") - nullableKeyValueMap contains Pairs( - null to "a", - null to "b" - ) - nullableKeyValueMap contains Pairs( - null to "a", - 2 to "b" - ) - nullableKeyValueMap contains (KeyValue(null) {}) - nullableKeyValueMap contains All( - KeyValue( - null - ) {}, KeyValue(null) {}) - nullableKeyValueMap contains All( - KeyValue( - null - ) {}, KeyValue(2) {}) + nullableKeyValueMap contains pairs(null to "a", null to "b") + nullableKeyValueMap contains pairs(null to "a", 2 to "b") + nullableKeyValueMap contains (keyValue(null) {}) + nullableKeyValueMap contains all(keyValue(null) {}, keyValue(null) {}) + nullableKeyValueMap contains all(keyValue(null) {}, keyValue(2) {}) nullableKeyValueMap contains (1 to null) - nullableKeyValueMap contains Pairs( - 1 to null, - 2 to null - ) - nullableKeyValueMap contains Pairs( - 1 to null, - 2 to "a" - ) - nullableKeyValueMap contains (KeyValue( - 1, - null - )) - nullableKeyValueMap contains All( - KeyValue( - 1, - null - ), KeyValue(2, null) - ) - nullableKeyValueMap contains All( - KeyValue( - 1, - null - ), KeyValue(2) {}) + nullableKeyValueMap contains pairs(1 to null, 2 to null) + nullableKeyValueMap contains pairs(1 to null, 2 to "a") + nullableKeyValueMap contains (keyValue(1, null)) + nullableKeyValueMap contains all(keyValue(1, null), keyValue(2, null)) + nullableKeyValueMap contains all(keyValue(1, null), keyValue(2) {}) nullableKeyValueMap contains (null to null) - nullableKeyValueMap contains Pairs( - null to null, - null to null - ) - nullableKeyValueMap contains Pairs( - 1 to null, - null to "a" - ) - nullableKeyValueMap contains (KeyValue( - null, - null - )) - nullableKeyValueMap contains All( - KeyValue( - null, - null - ), KeyValue(null, null) - ) - nullableKeyValueMap contains All( - KeyValue( - 1, - null - ), KeyValue(null) {}) + nullableKeyValueMap contains pairs(null to null, null to null) + nullableKeyValueMap contains pairs(1 to null, null to "a") + nullableKeyValueMap contains (keyValue(null, null)) + nullableKeyValueMap contains all(keyValue(null, null), keyValue(null, null)) + nullableKeyValueMap contains all(keyValue(1, null), keyValue(null) {}) readOnlyNullableKeyValueMap contains (1 to "a") - readOnlyNullableKeyValueMap contains Pairs( - 1 to "a", - 2 to "b" - ) - readOnlyNullableKeyValueMap contains KeyValue( - 1 - ) {} - readOnlyNullableKeyValueMap contains All( - KeyValue(1) {}, - KeyValue(2) {}) + readOnlyNullableKeyValueMap contains pairs(1 to "a", 2 to "b") + readOnlyNullableKeyValueMap contains keyValue(1) {} + readOnlyNullableKeyValueMap contains all(keyValue(1) {}, keyValue(2) {}) readOnlyNullableKeyValueMap contains (null to "a") - readOnlyNullableKeyValueMap contains Pairs( - null to "a", - null to "b" - ) - readOnlyNullableKeyValueMap contains Pairs( - null to "a", - 2 to "b" - ) - readOnlyNullableKeyValueMap contains (KeyValue( - null - ) {}) - readOnlyNullableKeyValueMap contains All( - KeyValue(null) {}, - KeyValue(null) {}) - readOnlyNullableKeyValueMap contains All( - KeyValue(null) {}, - KeyValue(2) {}) + readOnlyNullableKeyValueMap contains pairs(null to "a", null to "b") + readOnlyNullableKeyValueMap contains pairs(null to "a", 2 to "b") + readOnlyNullableKeyValueMap contains (keyValue(null) {}) + readOnlyNullableKeyValueMap contains all(keyValue(null) {}, keyValue(null) {}) + readOnlyNullableKeyValueMap contains all(keyValue(null) {}, keyValue(2) {}) readOnlyNullableKeyValueMap contains (1 to null) - readOnlyNullableKeyValueMap contains Pairs( - 1 to null, - 2 to null - ) - readOnlyNullableKeyValueMap contains Pairs( - 1 to null, - 2 to "a" - ) - readOnlyNullableKeyValueMap contains (KeyValue( - 1, - null - )) - readOnlyNullableKeyValueMap contains All( - KeyValue(1, null), - KeyValue(2, null) - ) - readOnlyNullableKeyValueMap contains All( - KeyValue(1, null), - KeyValue(2) {}) + readOnlyNullableKeyValueMap contains pairs(1 to null, 2 to null) + readOnlyNullableKeyValueMap contains pairs(1 to null, 2 to "a") + readOnlyNullableKeyValueMap contains (keyValue(1, null)) + readOnlyNullableKeyValueMap contains all(keyValue(1, null), keyValue(2, null)) + readOnlyNullableKeyValueMap contains all(keyValue(1, null), keyValue(2) {}) readOnlyNullableKeyValueMap contains (null to null) - readOnlyNullableKeyValueMap contains Pairs( - null to null, - null to null - ) - readOnlyNullableKeyValueMap contains Pairs( - 1 to null, - null to "a" - ) - readOnlyNullableKeyValueMap contains (KeyValue( - null, - null - )) - readOnlyNullableKeyValueMap contains All( - KeyValue(null, null), - KeyValue(null, null) - ) - readOnlyNullableKeyValueMap contains All( - KeyValue(1, null), - KeyValue(null) {}) + readOnlyNullableKeyValueMap contains pairs(null to null, null to null) + readOnlyNullableKeyValueMap contains pairs(1 to null, null to "a") + readOnlyNullableKeyValueMap contains (keyValue(null, null)) + readOnlyNullableKeyValueMap contains all(keyValue(null, null), keyValue(null, null)) + readOnlyNullableKeyValueMap contains all(keyValue(1, null), keyValue(null) {}) readOnlyNullableKeyValueMap contains (1 to "a") - readOnlyNullableKeyValueMap contains Pairs( - 1 to "a", - 2 to "b" - ) - readOnlyNullableKeyValueMap contains KeyValue( - 1 - ) {} - readOnlyNullableKeyValueMap contains All( - KeyValue(1) {}, - KeyValue(2) {}) + readOnlyNullableKeyValueMap contains pairs(1 to "a", 2 to "b") + readOnlyNullableKeyValueMap contains keyValue(1) {} + readOnlyNullableKeyValueMap contains all(keyValue(1) {}, keyValue(2) {}) starMap contains (null to "a") - starMap contains Pairs( - null to "a", - null to "b" - ) - starMap contains Pairs(null to "a", 2 to "b") - starMap contains (KeyValue(null) {}) - starMap contains All( - KeyValue(null) {}, - KeyValue(null) {}) - starMap contains All( - KeyValue(null) {}, - KeyValue(2) {}) + starMap contains pairs(null to "a", null to "b") + starMap contains pairs(null to "a", 2 to "b") + starMap contains (keyValue(null) {}) + starMap contains all(keyValue(null) {}, keyValue(null) {}) + starMap contains all(keyValue(null) {}, keyValue(2) {}) starMap contains (1 to null) - starMap contains Pairs(1 to null, 2 to null) - starMap contains Pairs(1 to null, 2 to "a") - starMap contains (KeyValue(1, null)) - starMap contains All( - KeyValue(1, null), - KeyValue(2, null) - ) - starMap contains All( - KeyValue(1, null), - KeyValue(2) {}) + starMap contains pairs(1 to null, 2 to null) + starMap contains pairs(1 to null, 2 to "a") + starMap contains (keyValue(1, null)) + starMap contains all(keyValue(1, null), keyValue(2, null)) + starMap contains all(keyValue(1, null), keyValue(2) {}) starMap contains (null to null) - starMap contains Pairs( - null to null, - null to null - ) - starMap contains Pairs(1 to null, null to "a") - starMap contains (KeyValue(null, null)) - starMap contains All( - KeyValue( - null, - null - ), KeyValue(null, null) - ) - starMap contains All( - KeyValue(1, null), - KeyValue(null) {}) + starMap contains pairs(null to null, null to null) + starMap contains pairs(1 to null, null to "a") + starMap contains (keyValue(null, null)) + starMap contains all(keyValue(null, null), keyValue(null, null)) + starMap contains all(keyValue(1, null), keyValue(null) {}) map containsKey 1 map containsKey 1f diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt index 6c2776d8d..de6704534 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapEntryFeatureAssertionsSpec.kt @@ -1,10 +1,10 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.property +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class MapEntryFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.MapEntryFeatureAssertionsSpec( property, String>(Expect>::key), diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt index 21328ac3e..27ab3c86a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/ThrowableAssertionsSpec.kt @@ -1,6 +1,5 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.* import ch.tutteli.atrium.specs.testutils.WithAsciiReporter @@ -21,7 +20,7 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss vararg otherExpected: Any ): Expect = if (otherExpected.isEmpty()) expect messageContains expected - else expect messageContains Values( + else expect messageContains values( expected, *otherExpected ) @@ -45,7 +44,7 @@ class ThrowableAssertionsSpec : ch.tutteli.atrium.specs.integration.ThrowableAss a1 = a1 message {} a1 = a1 messageContains "a" a1 = a1 messageContains 'a' - a1 = a1 messageContains Values( + a1 = a1 messageContains values( "a", 1, 'b' From 763cb2f52f031b226bd35495954bc7f14368c1e3 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 4 Apr 2020 14:55:46 +0200 Subject: [PATCH 126/142] lower case all pseudo-keywords, move extension-keywords to normal API By moving the keywords to atrium-api-infix-en_GB-common we hope that we don't get into the situation where we would need the same keyword also there (or in another extension) and thus run into name clashes. For the same reason we move all parameter objects which are not extension specific (e.g. PathWithCreator has to stay in jdk8 extension) also to atrium-api-infix-en_GB-common. Moreover: - make asPath infix with the help of `o` - rename genericHelperFunctions.kt to helperFunctions.kt - move parameter objects which are not very specific to one type to the package creating (instead of e.g. creating.list) - adjust module-info.java for API and extensions, it's totally wrong and Kotlin does not recognise it :( --- .../src/module/module-info.java | 1 + .../src/module/module-info.java | 1 + .../api/infix/en_GB/charSequenceAssertions.kt | 17 +++-- .../en_GB/charSequenceContainsCreators.kt | 2 +- .../api/infix/en_GB/collectionAssertions.kt | 8 ++- .../creating/{list => }/IndexWithCreator.kt | 2 +- .../creating/{map => }/KeyWithCreator.kt | 4 +- .../en_GB/creating/PresentWithCreator.kt | 13 ++++ .../{charsequence => }/RegexPatterns.kt | 2 +- .../en_GB/creating}/SuccessWithCreator.kt | 2 +- .../impl/nameContainsNotFun.kt | 11 ++- .../builders/impl/nameContainsNotFun.kt | 23 +++--- ...cHelperFunctions.kt => helperFunctions.kt} | 13 ++++ .../atrium/api/infix/en_GB/keywords.kt | 71 ++++++++++++------- .../atrium/api/infix/en_GB/listAssertions.kt | 5 +- .../atrium/api/infix/en_GB/mapAssertions.kt | 13 ++-- .../infix/en_GB/CharSequenceAssertionsSpec.kt | 18 ++--- .../infix/en_GB/CollectionAssertionsSpec.kt | 20 +++--- .../api/infix/en_GB/MapAssertionsSpec.kt | 36 +++++----- .../src/module/module-info.java | 9 ++- .../creating/optional/PresentWithCreator.kt | 15 ---- .../api/infix/en_GB/jdk8/fileAssertions.kt | 12 ++-- .../atrium/api/infix/en_GB/jdk8/keywords.kt | 40 ----------- .../infix/en_GB/jdk8/optionalAssertions.kt | 15 ++-- .../api/infix/en_GB/jdk8/pathAssertions.kt | 3 +- .../src/module/module-info.java | 2 + .../en_GB/jdk8/FileAsPathAssertionsSpec.kt | 3 +- .../en_GB/jdk8/OptionalAssertionsSpec.kt | 19 ++--- .../infix/en_GB/jdk8/PathAssertionsSpec.kt | 5 +- .../en_GB/kotlin_1_3/resultAssertions.kt | 7 +- .../kotlin_1_3/ResultFeatureAssertionsSpec.kt | 12 ++-- .../src/module/module-info.java | 3 +- 32 files changed, 217 insertions(+), 190 deletions(-) rename apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/{list => }/IndexWithCreator.kt (87%) rename apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/{map => }/KeyWithCreator.kt (78%) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt rename apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/{charsequence => }/RegexPatterns.kt (86%) rename apis/infix-en_GB/{extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result => atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating}/SuccessWithCreator.kt (82%) rename apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/{genericHelperFunctions.kt => helperFunctions.kt} (83%) delete mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt delete mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt diff --git a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/module/module-info.java b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/module/module-info.java index 906db56a2..709bf449c 100644 --- a/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/module/module-info.java +++ b/apis/fluent-en_GB/extensions/jdk8/atrium-api-fluent-en_GB-jdk8-jvm/src/module/module-info.java @@ -1,4 +1,5 @@ module ch.tutteli.atrium.api.fluent.en_GB.jdk8 { + requires ch.tutteli.atrium.api.fluent.en_GB; requires ch.tutteli.atrium.domain.builders; requires ch.tutteli.kbox; requires ch.tutteli.niok; diff --git a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-jvm/src/module/module-info.java b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-jvm/src/module/module-info.java index 82f4eed69..8dd94c0e0 100644 --- a/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-jvm/src/module/module-info.java +++ b/apis/fluent-en_GB/extensions/kotlin_1_3/atrium-api-fluent-en_GB-kotlin_1_3-jvm/src/module/module-info.java @@ -1,4 +1,5 @@ module ch.tutteli.atrium.api.fluent.en_GB.kotlin_1_3 { + requires ch.tutteli.atrium.api.fluent.en_GB; requires ch.tutteli.atrium.domain.builders.kotlin_1_3; requires ch.tutteli.kbox; requires kotlin.stdlib; diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt index 42059160b..992e46804 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceAssertions.kt @@ -3,7 +3,7 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotCheckerOption import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.NotCheckerOptionImpl import ch.tutteli.atrium.api.infix.en_GB.creating.All -import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns +import ch.tutteli.atrium.api.infix.en_GB.creating.RegexPatterns import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -173,7 +173,8 @@ infix fun Expect.containsRegex(patterns: RegexPatterns): E * Helper function to create a [RegexPatterns] based on the given [pattern] and [otherPatterns] * -- allows to express `String, vararg String`. */ -fun regexPatterns(pattern: String, vararg otherPatterns: String): RegexPatterns = RegexPatterns(pattern, otherPatterns) +fun regexPatterns(pattern: String, vararg otherPatterns: String): RegexPatterns = + RegexPatterns(pattern, otherPatterns) /** * Expects that the subject of the assertion (a [CharSequence]) contains a sequence which matches the given @@ -285,32 +286,34 @@ infix fun Expect.endsNotWith(expected: Char) = /** * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isEmpty]. * - * @param Empty Has to be `Empty`. + * @param empty Use the pseudo-keyword `empty`. * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = +infix fun Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.charSequence.isEmpty(this)) /** * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isNotEmpty]. * - * @param Empty Has to be `Empty`. + * @param empty Use the pseudo-keyword `empty`. * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = +infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.charSequence.isNotEmpty(this)) /** * Expects that the subject of the assertion (a [CharSequence]) [CharSequence].[kotlin.text.isNotBlank]. * + * @param blank Use the pseudo-keyword `blank`. + * * @return This assertion container to support a fluent API. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") Blank: Blank) = +infix fun Expect.notToBe(@Suppress("UNUSED_PARAMETER") blank: blank) = addAssertion(ExpectImpl.charSequence.isNotBlank(this)) /** diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt index 770834e91..37f07a3b5 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -1,7 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.All -import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.RegexPatterns +import ch.tutteli.atrium.api.infix.en_GB.creating.RegexPatterns import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt index eeb129f49..8b2524975 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/collectionAssertions.kt @@ -6,19 +6,23 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl /** * Expects that the subject of the assertion (a [Collection]) is an empty [Collection]. * + * @param empty Use the pseudo-keyword `empty`. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.collection.isEmpty(this)) /** * Expects that the subject of the assertion (a [Collection]) is not an empty [Collection]. * + * @param empty Use the pseudo-keyword `empty`. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = +infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.collection.isNotEmpty(this)) /** diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt similarity index 87% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt index cd674220f..9ad39c86b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/list/IndexWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt @@ -1,4 +1,4 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.list +package ch.tutteli.atrium.api.infix.en_GB.creating import ch.tutteli.atrium.creating.Expect diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt similarity index 78% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt index c4c2716cd..a92419580 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt @@ -1,4 +1,4 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.map +package ch.tutteli.atrium.api.infix.en_GB.creating import ch.tutteli.atrium.creating.Expect @@ -7,7 +7,7 @@ import ch.tutteli.atrium.creating.Expect * a resulting feature of type [V]. * * Use the function `key(...) { ... }` to create this representation where the first parameter corresponds - * to the [key] and the second is the [assertionCreator] + * to the [key] and the second is the [assertionCreator]. * * @since 0.11.0 */ diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt new file mode 100644 index 000000000..2658a26e4 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt @@ -0,0 +1,13 @@ +package ch.tutteli.atrium.api.infix.en_GB.creating + +import ch.tutteli.atrium.creating.Expect + +/** + * Parameter object which represents a present value (e.g. to represent a present `Optional`) with an element type [E] + * combined with an [assertionCreator] which defines assertions for the element. + * + * Use the function `present { ... }` to create this representation. + * + * @since 0.11.0 + */ +data class PresentWithCreator(val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt similarity index 86% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt index 2456dc388..f88013f5b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/RegexPatterns.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt @@ -1,4 +1,4 @@ -package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence +package ch.tutteli.atrium.api.infix.en_GB.creating import ch.tutteli.atrium.domain.builders.utils.VarArgHelper diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt similarity index 82% rename from apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt index 95d86a1b2..cb9d974f3 100644 --- a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/creating/result/SuccessWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt @@ -1,4 +1,4 @@ -package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3.creating.result +package ch.tutteli.atrium.api.infix.en_GB.creating import ch.tutteli.atrium.creating.Expect diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt index 3f76426d6..df9e8c296 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/charsequence/contains.builders/impl/nameContainsNotFun.kt @@ -6,7 +6,12 @@ import ch.tutteli.atrium.creating.Expect import kotlin.reflect.KFunction2 internal object StaticName { - private val f: KFunction2, Values, Expect> = - Expect::containsNot - val nameContainsNotValuesFun = "`${f.name} values`" + val nameContainsNotValuesFun: String = { + val f: KFunction2, Values, Expect> = + Expect::containsNot + //TODO use once https://youtrack.jetbrains.com/issue/KT-38013 is fixed (there are other places where "values" is hard-coded) +// val values : KFunction2, Values> = ::values +// "`${f.name} ${values.name}`" + "`${f.name} values`" + }() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt index 7f360e1cb..06a1796f0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/contains/builders/impl/nameContainsNotFun.kt @@ -1,7 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl -import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.containsNot +import ch.tutteli.atrium.api.infix.en_GB.creating.Values import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption import ch.tutteli.atrium.api.infix.en_GB.o import ch.tutteli.atrium.api.infix.en_GB.the @@ -12,12 +12,17 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NotS import kotlin.reflect.KFunction2 internal object StaticName { - private val f: KFunction2>, o, NotCheckerOption, NotSearchBehaviour>> = - Expect>::containsNot - private val fThe: KFunction2< - IterableContains.CheckerOption, InAnyOrderSearchBehaviour>, - Values, - Expect> - > = IterableContains.CheckerOption, InAnyOrderSearchBehaviour>::the - val nameContainsNotValuesFun = "`${f.name} ${o::class.simpleName} ${fThe.name} values`" + val nameContainsNotValuesFun: String = { + val containsNotKf: KFunction2>, o, NotCheckerOption, NotSearchBehaviour>> = + Expect>::containsNot + val theKf: KFunction2< + IterableContains.CheckerOption, InAnyOrderSearchBehaviour>, + Values, + Expect> + > = IterableContains.CheckerOption, InAnyOrderSearchBehaviour>::the + //TODO use once https://youtrack.jetbrains.com/issue/KT-38013 is fixed (there are other places where "values" is hard-coded) +// val values : KFunction2, Values> = ::values +// "`${f.name} ${o::class.simpleName} ${fThe.name} ${values.name}`" + "`${containsNotKf.name} ${o::class.simpleName} ${theKf.name} values`" + }() } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt similarity index 83% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt index 8e7109216..3ec6af517 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/genericHelperFunctions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt @@ -39,6 +39,18 @@ fun entries( */ fun pairs(pair: Pair, vararg otherPairs: Pair): Pairs = Pairs(pair, otherPairs) +/** + * Helper function to create a [PresentWithCreator] based on the given [assertionCreator]. + */ +fun present(assertionCreator: Expect.() -> Unit) = + PresentWithCreator(assertionCreator) + +/** + * Helper function to create a [SuccessWithCreator] based on the given [assertionCreator]. + */ +fun success(assertionCreator: Expect.() -> Unit) = + SuccessWithCreator(assertionCreator) + /** * Helper function to create a [Value] based on the given [value]. */ @@ -49,3 +61,4 @@ fun value(value: T): Value = Value(value) * -- allows to express `T, vararg T`. */ fun values(value: T, vararg otherValues: T): Values = Values(value, otherValues) + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 7bc920613..f4e0726b0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -2,8 +2,6 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.creating.Expect - /** * Marker interface for keywords. * @@ -17,50 +15,56 @@ internal const val ERR_KEYWORD_GIVEN_COLLECTION_ASSUMED = "This call will most probably fail at runtime because the given subject is not a collection as you might have assumed. If you really want to compare the subject against the keyword, then cast the keyword to Any" /** - * Represents a helper construct which allows to express emptiness. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * A helper construct to allow expressing assertions about a path being a regular file. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ -object Empty : Keyword +object aRegularFile : Keyword /** - * Represents a helper construct which allows to express presence. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * A helper construct to allow expressing assertions about a path being a directory. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ -object Present : Keyword +object aDirectory : Keyword /** * Represents a helper construct which allows to express blankness. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ -object Blank : Keyword - -/** - * Represents the pseudo keyword `contain` as in [to] `contain`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. - */ -object contain : Keyword +object blank : Keyword /** * Represents the pseudo keyword `case` as in [ignoring] `case`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ object case : Keyword +/** + * Represents a helper construct which allows to express emptiness. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object empty : Keyword + /** * Represents the pseudo keyword `entries` as in [grouped] `entries`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ object entries : Keyword +/** + * A helper construct to allow expressing assertions about path existence. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object exist : Keyword + /** * Represents the pseudo keyword `group` as in [within] `group`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ object group : Keyword /** * Represents the pseudo keyword `next` as in [has] `next`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. * * @since 0.11.0 */ @@ -71,7 +75,7 @@ object next : Keyword * A reader should skip this filler without reading it. For instance, `contains o atLeast 1...` should be read as * `contains at least once...` * - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. * * @since 0.11.0 */ @@ -79,20 +83,39 @@ object o : Keyword /** * Represents the pseudo keyword `only` as in [and] `only`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ object only : Keyword /** * Represents the pseudo keyword `order` as in [inAny] `order`. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. */ object order : Keyword +/** + * Represents a helper construct which allows to express presence. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object present : Keyword + + +/** + * A helper construct to allow expressing assertions about a path being readable. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object readable : Keyword + /** * Represents the pseudo keyword `success` as in [toBe] `success. - * It can be used for a parameter less function so that it has one parameter and thus can be used as infix function. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. * * @since 0.11.0 */ object success : Keyword + +/** + * A helper construct to allow expressing assertions about a path being writable. + * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. + */ +object writable : Keyword diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt index 946d6e502..dec25d4fd 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/listAssertions.kt @@ -1,6 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB -import ch.tutteli.atrium.api.infix.en_GB.creating.list.IndexWithCreator +import ch.tutteli.atrium.api.infix.en_GB.creating.IndexWithCreator import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -31,4 +31,5 @@ infix fun > Expect.get(index: IndexWithCreator): Expect /** * Helper function to create an [IndexWithCreator] based on the given [index] and [assertionCreator]. */ -fun index(index: Int, assertionCreator: Expect.() -> Unit) = IndexWithCreator(index, assertionCreator) +fun index(index: Int, assertionCreator: Expect.() -> Unit) = + IndexWithCreator(index, assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt index f90a318eb..eb4b08eb7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapAssertions.kt @@ -3,7 +3,7 @@ package ch.tutteli.atrium.api.infix.en_GB import ch.tutteli.atrium.api.infix.en_GB.creating.All import ch.tutteli.atrium.api.infix.en_GB.creating.Pairs import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyWithValueCreator -import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyWithCreator +import ch.tutteli.atrium.api.infix.en_GB.creating.KeyWithCreator import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -121,7 +121,8 @@ infix fun > Expect.getExisting(key: KeyWithCreator key(key: K, assertionCreator: Expect.() -> Unit) = KeyWithCreator(key, assertionCreator) +fun key(key: K, assertionCreator: Expect.() -> Unit) = + KeyWithCreator(key, assertionCreator) /** @@ -147,19 +148,23 @@ infix fun > Expect.keys(assertionCreator: Expect> Expect.toBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.map.isEmpty(this)) /** * Expects that the subject of the assertion (a [Map]) is not an empty [Map]. * + * @param empty Use the pseudo-keyword `empty`. + * * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ -infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") Empty: Empty) = +infix fun > Expect.notToBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.map.isNotEmpty(this)) /** diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt index a609ed362..0dacab299 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceAssertionsSpec.kt @@ -6,9 +6,9 @@ import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSequenceAssertionsSpec( - "toBe ${Empty::class.simpleName}" to Companion::toBeEmpty, - "notToBe ${Empty::class.simpleName}" to Companion::notToBeEmpty, - "notToBe ${Blank::class.simpleName}" to Companion::notToBeBlank, + "toBe ${empty::class.simpleName}" to Companion::toBeEmpty, + "notToBe ${empty::class.simpleName}" to Companion::notToBeEmpty, + "notToBe ${blank::class.simpleName}" to Companion::notToBeBlank, fun1(Expect::startsWith), fun1(Expect::startsWith), fun1(Expect::startsNotWith), @@ -21,18 +21,18 @@ class CharSequenceAssertionsSpec : ch.tutteli.atrium.specs.integration.CharSeque fun1(Expect::mismatches) ) { companion object : WithAsciiReporter(){ - private fun toBeEmpty(expect: Expect) = expect toBe Empty - private fun notToBeEmpty(expect: Expect) = expect notToBe Empty - private fun notToBeBlank(expect: Expect) = expect notToBe Blank + private fun toBeEmpty(expect: Expect) = expect toBe empty + private fun notToBeEmpty(expect: Expect) = expect notToBe empty + private fun notToBeBlank(expect: Expect) = expect notToBe blank } @Suppress("unused", "UNUSED_VALUE") private fun ambiguityTest() { val a1: Expect = notImplemented() - a1 toBe Empty - a1 notToBe Empty - a1 notToBe Blank + a1 toBe empty + a1 notToBe empty + a1 notToBe blank a1 startsWith "expected" a1 startsNotWith "expected" diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt index ecc1cef15..95aa1b235 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CollectionAssertionsSpec.kt @@ -5,12 +5,12 @@ import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.testutils.WithAsciiReporter class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionAssertionsSpec( - "toBe ${Empty::class.simpleName}" to Companion::isEmpty, - "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty + "toBe ${empty::class.simpleName}" to Companion::isEmpty, + "notToBe ${empty::class.simpleName}" to Companion::isNotEmpty ) { companion object : WithAsciiReporter() { - private fun isEmpty(expect: Expect>) = expect toBe Empty - private fun isNotEmpty(expect: Expect>) = expect notToBe Empty + private fun isEmpty(expect: Expect>) = expect toBe empty + private fun isNotEmpty(expect: Expect>) = expect notToBe empty } @@ -21,14 +21,14 @@ class CollectionAssertionsSpec : ch.tutteli.atrium.specs.integration.CollectionA val star: Expect> = notImplemented() - a1 toBe Empty - a1 notToBe Empty + a1 toBe empty + a1 notToBe empty - a1b toBe Empty - a1b notToBe Empty + a1b toBe empty + a1b notToBe empty - star toBe Empty - star notToBe Empty + star toBe empty + star notToBe empty } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt index d6805d28d..0be210564 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/MapAssertionsSpec.kt @@ -18,8 +18,8 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( fun1, String?>(Companion::containsKey).withNullableSuffix(), fun1, String>(Companion::containsNotKey), fun1, String?>(Companion::containsNotKey).withNullableSuffix(), - "toBe ${Empty::class.simpleName}" to Companion::isEmpty, - "notToBe ${Empty::class.simpleName}" to Companion::isNotEmpty + "toBe ${empty::class.simpleName}" to Companion::isEmpty, + "notToBe ${empty::class.simpleName}" to Companion::isNotEmpty ) { companion object : WithAsciiReporter() { @@ -76,9 +76,9 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( private fun containsNotKey(expect: Expect>, key: String?) = expect containsNotKey key - private fun isEmpty(expect: Expect>) = expect toBe Empty + private fun isEmpty(expect: Expect>) = expect toBe empty - private fun isNotEmpty(expect: Expect>) = expect notToBe Empty + private fun isNotEmpty(expect: Expect>) = expect notToBe empty } @@ -227,21 +227,21 @@ class MapAssertionsSpec : ch.tutteli.atrium.specs.integration.MapAssertionsSpec( readOnlyNullableKeyValueMap containsNotKey 1f - map = map toBe Empty - subMap = subMap toBe Empty - nullableKeyMap = nullableKeyMap toBe Empty - nullableValueMap = nullableValueMap toBe Empty - nullableKeyValueMap = nullableKeyValueMap toBe Empty - readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap toBe Empty - starMap = starMap toBe Empty + map = map toBe empty + subMap = subMap toBe empty + nullableKeyMap = nullableKeyMap toBe empty + nullableValueMap = nullableValueMap toBe empty + nullableKeyValueMap = nullableKeyValueMap toBe empty + readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap toBe empty + starMap = starMap toBe empty - map = map notToBe Empty - subMap = subMap notToBe Empty - nullableKeyMap = nullableKeyMap notToBe Empty - nullableValueMap = nullableValueMap notToBe Empty - nullableKeyValueMap = nullableKeyValueMap notToBe Empty - readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap notToBe Empty - starMap = starMap notToBe Empty + map = map notToBe empty + subMap = subMap notToBe empty + nullableKeyMap = nullableKeyMap notToBe empty + nullableValueMap = nullableValueMap notToBe empty + nullableKeyValueMap = nullableKeyValueMap notToBe empty + readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap notToBe empty + starMap = starMap notToBe empty } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java index 311fe4b30..921dbaa27 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/src/module/module-info.java @@ -4,6 +4,11 @@ module ch.tutteli.atrium.api.infix.en_GB { exports ch.tutteli.atrium.api.infix.en_GB; -// exports ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders; -// exports ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders; + exports ch.tutteli.atrium.api.infix.en_GB.creating; + exports ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders; + exports ch.tutteli.atrium.api.infix.en_GB.creating.feature; + exports ch.tutteli.atrium.api.infix.en_GB.creating.iterable; + exports ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders; + exports ch.tutteli.atrium.api.infix.en_GB.creating.map; + exports ch.tutteli.atrium.api.infix.en_GB.workaround; } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt deleted file mode 100644 index a496f75cb..000000000 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/optional/PresentWithCreator.kt +++ /dev/null @@ -1,15 +0,0 @@ -@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) -package ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.optional - -import ch.tutteli.atrium.creating.Expect -import java.util.Optional - -/** - * Parameter object which represents a present [Optional] with an element type [E] combined - * with an [assertionCreator] which defines assertions for the element. - * - * Use the function `present { ... }` to create this representation. - * - * @since 0.11.0 - */ -data class PresentWithCreator(val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt index 5fcfa389f..6dba66a94 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/fileAssertions.kt @@ -2,6 +2,7 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 +import ch.tutteli.atrium.api.infix.en_GB.o import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import java.io.File @@ -11,25 +12,26 @@ import java.nio.file.Path * Turns `Expect` into `Expect`. * * The transformation as such is not reflected in reporting. - * Use `feature(File::toPath)` if you want to show the transformation in reporting. + * Use `feature File::toPath` if you want to show the transformation in reporting. * * @return The newly created [Expect] for the transformed subject. * * @since 0.11.0 */ -fun Expect.asPath(): Expect = - ExpectImpl.changeSubject(this).unreported { it.toPath() } +infix fun Expect.asPath( + @Suppress("UNUSED_PARAMETER") o: o +): Expect = ExpectImpl.changeSubject(this).unreported { it.toPath() } /** * Expects that the subject of the assertion holds all assertions the given [assertionCreator] creates for * the subject as [Path]. * * The transformation as such is not reflected in reporting. - * Use `feature(File::toPath, assertionCreator)` if you want to show the transformation in reporting. + * Use `feature of(File::toPath, assertionCreator)` if you want to show the transformation in reporting. * * @return An [Expect] for the current subject of the assertion. * * @since 0.11.0 */ infix fun Expect.asPath(assertionCreator: Expect.() -> Unit): Expect = - apply { asPath().addAssertionsCreatedBy(assertionCreator) } + apply { asPath(o).addAssertionsCreatedBy(assertionCreator) } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt deleted file mode 100644 index 48de145f4..000000000 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/keywords.kt +++ /dev/null @@ -1,40 +0,0 @@ -@file:Suppress( - /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */ - "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE", - "ClassName" -) - -package ch.tutteli.atrium.api.infix.en_GB.jdk8 - -import ch.tutteli.atrium.api.infix.en_GB.Keyword - - -/** - * A helper construct to allow expressing assertions about path existence. - * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. - */ -object exist : Keyword - -/** - * A helper construct to allow expressing assertions about a path being a regular file. - * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. - */ -object aRegularFile : Keyword - -/** - * A helper construct to allow expressing assertions about a path being a directory. - * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. - */ -object aDirectory : Keyword - -/** - * A helper construct to allow expressing assertions about a path being a readable. - * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. - */ -object readable : Keyword - -/** - * A helper construct to allow expressing assertions about a path being a writable. - * It can be used for a parameterless function so that it has one parameter and thus can be used as infix function. - */ -object writable : Keyword diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt index 48ccce2ac..c3d111a1e 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/optionalAssertions.kt @@ -2,9 +2,9 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 -import ch.tutteli.atrium.api.infix.en_GB.Empty -import ch.tutteli.atrium.api.infix.en_GB.Present -import ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.optional.PresentWithCreator +import ch.tutteli.atrium.api.infix.en_GB.empty +import ch.tutteli.atrium.api.infix.en_GB.present +import ch.tutteli.atrium.api.infix.en_GB.creating.PresentWithCreator import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.optional @@ -21,7 +21,7 @@ import java.util.* * * @since 0.11.0 */ -infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: Empty) = +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: empty) = addAssertion(ExpectImpl.optional.isEmpty(this)) /** @@ -36,7 +36,7 @@ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") empty: * * @since 0.11.0 */ -infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") present: Present) = +infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") present: present) = ExpectImpl.optional.isPresent(this).getExpectOfFeature() /** @@ -50,8 +50,3 @@ infix fun > Expect.toBe(@Suppress("UNUSED_PARAMETER") pres */ infix fun > Expect.toBe(present: PresentWithCreator): Expect = ExpectImpl.optional.isPresent(this).addToInitial(present.assertionCreator) - -/** - * Helper function to create a [PresentWithCreator] based on the given [assertionCreator]. - */ -fun present(assertionCreator: Expect.() -> Unit) = PresentWithCreator(assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt index b63fe1add..83af113a3 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/pathAssertions.kt @@ -2,6 +2,7 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 +import ch.tutteli.atrium.api.infix.en_GB.* import ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.path.PathWithCreator import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -188,7 +189,7 @@ infix fun Expect.resolve(path: PathWithCreator): Expect = ExpectImpl.path.resolve(this, path.path).addToInitial(path.assertionCreator) /** - * Helper function to create an [PathWithCreator] based on the given [path] and [assertionCreator]. + * Helper function to create a [PathWithCreator] based on the given [path] and [assertionCreator]. */ fun path(path: String, assertionCreator: Expect.() -> Unit) = PathWithCreator(path, assertionCreator) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java index 20b5852f8..26d81d3a6 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/module/module-info.java @@ -1,4 +1,5 @@ module ch.tutteli.atrium.api.infix.en_GB.jdk8 { + requires ch.tutteli.atrium.api.infix.en_GB; requires ch.tutteli.atrium.domain.builders; requires ch.tutteli.kbox; requires ch.tutteli.niok; @@ -6,4 +7,5 @@ module ch.tutteli.atrium.api.infix.en_GB.jdk8 { requires java.base; exports ch.tutteli.atrium.api.infix.en_GB.jdk8; + exports ch.tutteli.atrium.api.infix.en_GB.jdk8.creating.path; } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt index 9a5a520f2..e3da3d421 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/FileAsPathAssertionsSpec.kt @@ -1,5 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 +import ch.tutteli.atrium.api.infix.en_GB.o import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.notImplemented import ch.tutteli.atrium.specs.testutils.WithAsciiReporter @@ -14,7 +15,7 @@ class FileAsPathAssertionsSpec : ch.tutteli.atrium.specs.integration.FileAsPathA private fun ambiguityTest() { var a1: Expect = notImplemented() - a1.asPath() + a1 asPath o a1 = a1 asPath { } } } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt index 1864c2312..2fc497b83 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/OptionalAssertionsSpec.kt @@ -1,7 +1,7 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 -import ch.tutteli.atrium.api.infix.en_GB.Empty -import ch.tutteli.atrium.api.infix.en_GB.Present +import ch.tutteli.atrium.api.infix.en_GB.empty +import ch.tutteli.atrium.api.infix.en_GB.present import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.feature0 import ch.tutteli.atrium.specs.fun0 @@ -17,10 +17,11 @@ class OptionalAssertionsSpec : OptionalAssertionsSpec( fun1(Companion::toBePresent) ) { companion object : WithAsciiReporter() { - private fun toBeEmpty(expect: Expect>) = expect toBe Empty + private fun toBeEmpty(expect: Expect>) = expect toBe empty private fun toBePresent(expect: Expect>, assertionCreator: Expect.() -> Unit) = expect toBe present(assertionCreator) - private fun toBePresentFeature(expect: Expect>) = expect toBe Present + + private fun toBePresentFeature(expect: Expect>) = expect toBe present } @Suppress("unused", "UNUSED_VALUE") @@ -30,11 +31,11 @@ class OptionalAssertionsSpec : OptionalAssertionsSpec( var star: Expect> = notImplemented() - o1 = o1 toBe Empty - o1b = o1b toBe Empty - star = star toBe Empty - o1 toBe Present - o1b toBe Present + o1 = o1 toBe empty + o1b = o1b toBe empty + star = star toBe empty + o1 toBe present + o1b toBe present // following is not supported on purpose as we don't know what type the element is in this case //star toBe Present o1 toBe present {} diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt index 25b3427df..f34a6cfca 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/PathAssertionsSpec.kt @@ -1,10 +1,11 @@ package ch.tutteli.atrium.api.infix.en_GB.jdk8 -import ch.tutteli.atrium.specs.testutils.WithAsciiReporter +import ch.tutteli.atrium.api.infix.en_GB.* import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.specs.fun1 import ch.tutteli.atrium.specs.name import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.testutils.WithAsciiReporter import java.nio.file.Path import java.nio.file.Paths @@ -20,7 +21,7 @@ class PathAssertionsSpec : ch.tutteli.atrium.specs.integration.PathAssertionsSpe fun1(Expect::toBe).name to Companion::isRegularFile, fun1(Expect::toBe).name to Companion::isDirectory ) { - companion object : WithAsciiReporter(){ + companion object : WithAsciiReporter() { private fun exists(expect: Expect) = expect to exist private fun existsNot(expect: Expect) = expect notTo exist diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt index 44d941a7c..57259ca55 100644 --- a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt +++ b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/resultAssertions.kt @@ -1,6 +1,6 @@ package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3 -import ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3.creating.result.SuccessWithCreator +import ch.tutteli.atrium.api.infix.en_GB.creating.SuccessWithCreator import ch.tutteli.atrium.api.infix.en_GB.success import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl @@ -57,8 +57,3 @@ inline fun Expect>.isFailure(): Ex inline infix fun Expect>.isFailure( noinline assertionCreator: Expect.() -> Unit ): Expect = ExpectImpl.result.isFailure(this, TExpected::class).addToFeature(assertionCreator) - -/** - * Helper function to create an [SuccessWithCreator] based on the given [assertionCreator]. - */ -fun success(assertionCreator: Expect.() -> Unit) = SuccessWithCreator(assertionCreator) diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt index abecddb10..fc8abfdbd 100644 --- a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt +++ b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/kotlin_1_3/ResultFeatureAssertionsSpec.kt @@ -1,14 +1,17 @@ package ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3 -import ch.tutteli.atrium.creating.Expect -import ch.tutteli.atrium.specs.* -import ch.tutteli.atrium.specs.integration.ResultFeatureAssertionsSpec import ch.tutteli.atrium.api.infix.en_GB.success +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.integration.ResultFeatureAssertionsSpec +import ch.tutteli.atrium.specs.notImplemented +import ch.tutteli.atrium.specs.withFeatureSuffix +import ch.tutteli.atrium.specs.withNullableSuffix class ResultFeatureAssertionsSpec : ResultFeatureAssertionsSpec( ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessFeature)).withFeatureSuffix(), "toBe ${success::class::simpleName}" to Companion::toBeSuccess, - ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessFeatureNullable)).withFeatureSuffix().withNullableSuffix(), + ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessFeatureNullable)).withFeatureSuffix() + .withNullableSuffix(), ("toBe ${success::class::simpleName}" to (Companion::toBeSuccessNullable)).withNullableSuffix(), ("isFailure" to Companion::isFailureFeature).withFeatureSuffix(), "isFailure" to Companion::isFailure @@ -28,6 +31,7 @@ class ResultFeatureAssertionsSpec : ResultFeatureAssertionsSpec( expect: Expect>, assertionCreator: Expect.() -> Unit ) = expect toBe success { assertionCreator() } + private fun isFailure( expect: Expect>, assertionCreator: Expect.() -> Unit diff --git a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-jvm/src/module/module-info.java b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-jvm/src/module/module-info.java index 5de512531..9049a91e4 100644 --- a/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-jvm/src/module/module-info.java +++ b/apis/infix-en_GB/extensions/kotlin_1_3/atrium-api-infix-en_GB-kotlin_1_3-jvm/src/module/module-info.java @@ -1,7 +1,8 @@ module ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3 { + requires ch.tutteli.atrium.api.infix.en_GB; requires ch.tutteli.atrium.domain.builders.kotlin_1_3; requires ch.tutteli.kbox; requires kotlin.stdlib; -// exports ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3; + exports ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3; } From d25769b6c4d60f14e4ab17440c7dce5438556d79 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 4 Apr 2020 15:16:16 +0200 Subject: [PATCH 127/142] don't mention `to support a fluent API` in KDoc ...and don't mention that the same Expect is returned but `An [Expect] for the current subject of the assertion.` --- .../en_GB/charSequenceContainsCreators.kt | 24 +++++++------- .../iterableContainsInAnyOrderCreators.kt | 10 +++--- .../iterableContainsInAnyOrderOnlyCreators.kt | 10 +++--- .../iterableContainsInOrderOnlyCreators.kt | 10 +++--- ...rableContainsInOrderOnlyGroupedCreators.kt | 4 +-- .../en_GB/charSequenceContainsCreators.kt | 32 +++++++++---------- .../iterableContainsInAnyOrderCreators.kt | 6 ++-- .../iterableContainsInAnyOrderOnlyCreators.kt | 10 +++--- .../iterableContainsInOrderOnlyCreators.kt | 8 ++--- ...rableContainsInOrderOnlyGroupedCreators.kt | 4 +-- 10 files changed, 59 insertions(+), 59 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt index 3cd8f6038..b65fb99b8 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt @@ -23,7 +23,7 @@ import kotlin.jvm.JvmName * * @param expected The value which is expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ @@ -51,7 +51,7 @@ fun CheckerOption.value(expected: Any * @param expected The value which is expected to be contained within the input of the search. * @param otherExpected Additional values which are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] or one of the [otherExpected] is not a * [CharSequence], [Number] or [Char]. @@ -75,7 +75,7 @@ fun CheckerOption.values( * * @param expected The value which is expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ @@ -105,7 +105,7 @@ fun CheckerOption.value( * @param expected The value which is expected to be contained within the input of the search. * @param otherExpected Additional values which are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] or one of the [otherExpected] is not a * [CharSequence], [Number] or [Char]. @@ -130,7 +130,7 @@ fun CheckerOption.values( * * @param expected The value which is expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ @@ -155,7 +155,7 @@ fun Builder.value(expected: A * @param expected The value which is expected to be contained within the input of the search. * @param otherExpected Additional values which are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] or one of the [otherExpected] is not a * [CharSequence], [Number] or [Char]. @@ -183,7 +183,7 @@ fun Builder.values( * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun CheckerOption.regex( @@ -209,7 +209,7 @@ fun CheckerOption.regex( * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.9.0 @@ -238,7 +238,7 @@ fun CheckerOption.regex( * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @JvmName("regexIgnoringCase") @@ -268,7 +268,7 @@ fun CheckerOption.regex( * @param pattern The pattern which is expected to have a match against the input of the search. * @param otherPatterns Additional patterns which are expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun Builder.regex( @@ -290,7 +290,7 @@ fun Builder.regex( * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given * [expectedIterable] does not have elements (is empty). @@ -318,7 +318,7 @@ fun CheckerOption.elementsOf( * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given * [expectedIterable] does not have elements (is empty). diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt index 64a4fe83b..6190c56b7 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderCreators.kt @@ -16,7 +16,7 @@ import ch.tutteli.kbox.glue * * @param expected The value which is expected to be contained within this [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > CheckerOption.value(expected: E): Expect = @@ -39,7 +39,7 @@ fun > CheckerOption.value(ex * @param expected The object which is expected to be contained within this [Iterable]. * @param otherExpected Additional objects which are expected to be contained within this [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > CheckerOption.values( @@ -58,7 +58,7 @@ fun > CheckerOption.values( * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > CheckerOption.entry( @@ -77,7 +77,7 @@ fun > CheckerOption. * @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry * which we are looking for (see [assertionCreatorOrNull] for more information). * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > CheckerOption.entries( @@ -99,7 +99,7 @@ fun > CheckerOption. * * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). * diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt index bb8ffb7ac..12ec88a2c 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -20,7 +20,7 @@ import ch.tutteli.kbox.glue * * @param expected The value which is expected to be contained within the [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.value(expected: E): Expect = @@ -39,7 +39,7 @@ fun > Builder.value(expe * @param expected The value which is expected to be contained within the [Iterable]. * @param otherExpected Additional values which are expected to be contained within [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.values( @@ -62,7 +62,7 @@ fun > Builder.values( * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.entry( @@ -94,7 +94,7 @@ fun > Builder.en * @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry * which we are looking for (see [assertionCreatorOrNull] for more information). * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.entries( @@ -120,7 +120,7 @@ fun > Builder.en * * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable] * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). * diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt index 8f798b164..7b7a29117 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -20,7 +20,7 @@ import ch.tutteli.kbox.glue * * @param expected The value which is expected to be contained within the [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.value(expected: E): Expect = @@ -38,7 +38,7 @@ fun > Builder.value(expecte * @param expected The value which is expected to be contained within the [Iterable]. * @param otherExpected Additional values which are expected to be contained within [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.values( @@ -61,7 +61,7 @@ fun > Builder.values( * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.entry( @@ -84,7 +84,7 @@ fun > Builder.entry * @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry * which we are looking for (see [assertionCreatorOrNull] for more information). * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.entries( @@ -110,7 +110,7 @@ fun > Builder.entri * * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). * diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt index 0d50be5f0..a82240127 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt @@ -19,7 +19,7 @@ import kotlin.jvm.JvmName * @param otherExpectedGroups Additional groups of values which are expected to appear after the [secondGroup] within * [Iterable] whereas the groups have to appear in the given order. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ fun > Builder.inAnyOrder( @@ -48,7 +48,7 @@ fun > Builder. * @param otherExpectedGroups Additional groups of values which are expected to appear after the [secondGroup] within * [Iterable] whereas the groups have to appear in the given order. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @JvmName("inAnyOrderEntries") diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt index 37f07a3b5..d1179e78c 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -26,7 +26,7 @@ import kotlin.jvm.JvmName * * @param expected The value which is expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ @@ -54,7 +54,7 @@ infix fun CheckerOption.value(expecte * @param values The values which should not be found within the input of the search * -- use the function `values(t, ...)` to create a [Values]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case one of the [values] is not a [CharSequence], [Number] or [Char]. */ @@ -75,7 +75,7 @@ infix fun CheckerOption.the(values: V * * @param expected The value which is expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ @@ -104,7 +104,7 @@ infix fun CheckerOption.value * @param values The values which are expected to be contained within the input of the search * -- use the function `values(t, ...)` to create a [Values]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case one of the [values] is not a [CharSequence], [Number] or [Char]. */ @@ -125,7 +125,7 @@ infix fun CheckerOption.the(v * * @param expected The value which is expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char]. */ @@ -153,7 +153,7 @@ infix fun Builder.value(expec * @param values The values which are expected to be contained within the input of the search * -- use the function `values(t, ...)` to create a [Values]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case one of the [values] is not a [CharSequence], [Number] or [Char]. */ @@ -168,7 +168,7 @@ infix fun Builder.the(values: * * @param pattern The pattern which is expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun CheckerOption.regex(pattern: String): Expect = @@ -182,7 +182,7 @@ infix fun CheckerOption.regex(pattern * * @param pattern The pattern which is expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.11.0 @@ -209,7 +209,7 @@ infix fun CheckerOption.matchFor( * @param patterns The patterns which are expected to have a match against the input of the search * -- use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun CheckerOption.the(patterns: RegexPatterns): Expect = @@ -233,7 +233,7 @@ infix fun CheckerOption.the(patterns: * @param patterns The patterns which are expected to have a match against the input of the search -- * use the function `all(Regex(...), ...)` to create a [All]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * * @since 0.11.0 @@ -251,7 +251,7 @@ infix fun CheckerOption.matchFor(patt * * @param pattern The patterns which is expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @JvmName("regexIgnoringCase") @@ -276,7 +276,7 @@ infix fun CheckerOption.regex * @param patterns The patterns which are expected to have a match against the input of the search * -- use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @JvmName("regexIgnoringCase") @@ -291,7 +291,7 @@ infix fun CheckerOption.the(p * * @param pattern The patterns which is expected to have a match against the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Builder.regex(pattern: String): Expect = @@ -317,7 +317,7 @@ infix fun Builder.regex(patte * @param patterns The patterns which are expected to have a match against the input of the search -- * use the function `regexPatterns(t, ...)` to create a [RegexPatterns]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun Builder.the(patterns: RegexPatterns): Expect = @@ -337,7 +337,7 @@ infix fun Builder.the(pattern * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given * [expectedIterable] does not have elements (is empty). @@ -366,7 +366,7 @@ infix fun CheckerOption.elementsOf( * * @param expectedIterable The [Iterable] whose elements are expected to be contained within the input of the search. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case [expectedIterable] is not a [CharSequence], [Number] or [Char] or the given * [expectedIterable] does not have elements (is empty). diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt index 8209a57a4..50cc8019e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt @@ -18,7 +18,7 @@ import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAn * * @param expected The value which is expected to be contained within this [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > CheckerOption.value(expected: E): Expect = @@ -58,7 +58,7 @@ infix fun > CheckerOption.th * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > CheckerOption.entry( @@ -91,7 +91,7 @@ infix fun > CheckerOption> Builder.value(expected: E): Expect = @@ -38,7 +38,7 @@ infix fun > Builder.valu * @param values The values which are expected to be contained within the [Iterable] * -- use the function `values(t, ...)` to create a [Values]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.the(values: Values): Expect = @@ -59,7 +59,7 @@ infix fun > Builder.the( * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.entry( @@ -89,7 +89,7 @@ infix fun > Builder> Builder> Builder.value(expected: E): Expect = @@ -60,7 +60,7 @@ infix fun > Builder.the(val * for has to hold; or in other words, the function which defines whether an entry is the one we are looking for * or not. In case it is defined as `null`, then an entry is identified if it is `null` as well. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.entry( @@ -82,7 +82,7 @@ infix fun > Builder * @param entries The entries which are expected to be contained within the [Iterable] * -- use the function `entries(t, ...)` to create an [Entries]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.the( @@ -102,7 +102,7 @@ infix fun > Builder * * @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable]. * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. * @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty). * diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt index 020300e45..eda28cbf7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyGroupedCreators.kt @@ -19,7 +19,7 @@ import kotlin.jvm.JvmName * -- use `order(group, group, ...)` to create an [Order] where group is either `value(e)` or `values(e, ...)`; * so a call could look as follows: `inAny order(values(1, 2), value(2), values(3, 2)) * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ infix fun > Builder.inAny( @@ -58,7 +58,7 @@ fun order( * ) * ``` * - * @return The [Expect] for which the assertion was built to support a fluent API. + * @return An [Expect] for the current subject of the assertion. * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. */ @JvmName("inAnyOrderEntries") From 5dfec9818164ca733e46747a763dc13644d76db0 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 4 Apr 2020 15:32:18 +0200 Subject: [PATCH 128/142] adjust differences to new infix API --- apis/differences.md | 352 +++++++++++++++++++++++--------------------- 1 file changed, 181 insertions(+), 171 deletions(-) diff --git a/apis/differences.md b/apis/differences.md index 1663e47f6..bd20f9781 100644 --- a/apis/differences.md +++ b/apis/differences.md @@ -14,19 +14,18 @@ These modules bundle: Following a list of the available bundle-modules. The links point to the KDoc of their included API where you find an overview of all available assertion functions of the API. -- [atrium-cc-de_CH-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.de_-c-h/index.html) -- [atrium-cc-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.en_-g-b/index.html) -- [atrium-cc-infix-en_GB-robstoll](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.cc.infix.en_-g-b/index.html) +- [atrium-fluent-en_GB](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html) +- [atrium-infix-en_GB](https://robstoll.github.io/atrium/latest#/doc/ch.tutteli.atrium.api.infix.en_-g-b/index.html) ---- -Following an excerpt of a build.gradle file which uses two APIs (see +Following an excerpt of a build.gradle file which uses twit APIs (see [README#Installation](https://github.com/robstoll/atrium/tree/master/README.md#installation) for the rest): ``` dependencies { - testCompile "ch.tutteli:atrium-cc-en_GB-robstoll:$atrium_version" - testCompile "ch.tutteli:atrium-api-cc-infix-en_GB-jvm:$atrium_version" + testCompile "ch.tutteli:atrium-fluent-en_GB:$atrium_version" + testCompile "ch.tutteli:atrium-api-infix-en_GB:$atrium_version" } ``` @@ -34,25 +33,24 @@ The first dependency points to a bundle-module, the second one just adds the inf :warning: if you want to use the same API in different languages, then you have to make sure that you exclude all translation modules but one (I suggest you keep the one which is your primary language). -If you forget to do it, then the compiler will complain that you have the same enums multiple times on your classpath. +If you forget to dit it, then the compiler will complain that you have the same enums multiple times on your classpath. # Different API styles -Atrium provides different APIs where the API differ in its style and the language in which it is written. -This site focuses on the different styles of APIs and compares their en_GB versions. -We do not show every single difference but merely where the APIs differ in naming. -For instance, the assertion function `Assert.toBe`: +Atrium currently provides two API styles: fluent and infix. +We dit not show every single difference but merely where the APIs differ in naming. +For instance, the assertion function `Expect.toBe`: -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).toBe(2) +expect(x).toBe(2) ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) toBe 2 +expect(x) toBe 2 ``` -is too similar, we will not list it here (ok, we did now but I guess you get the point). +is toit similar, we will not list it here (ok, we did now but I guess you get the point). ## Table of Content - [Empty CharSequence / Collection](#empty-charsequence--collection) @@ -69,42 +67,47 @@ is too similar, we will not list it here (ok, we did now but I guess you get the ## Empty CharSequence / Collection -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).isEmpty() -assert(x).isNotEmpty() +expect(x).isEmpty() +expect(x).isNotEmpty() ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) toBe Empty -assert(x) notToBe Empty +expect(x) toBe empty +expect(x) notToBe empty ``` ## `and` property -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).isGreaterThan(1).and.isLessThan(10) -assert(x) { /*...*/ } and { /*...*/ } +expect(x).isGreaterThan(1).and.isLessThan(10) +expect(x) { /*...*/ } and { /*...*/ } ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -// does only support the group syntax -assert(x) { /*...*/ } and { /*...*/ } +expect(x) isGreaterThan 1 and o isLessThan 10 +expect(x) { /*...*/ } and { /*...*/ } ``` +Note that `o` is a filler object which is only there so that we can turn extension methods without parameters into +a method with one parameter and thus make it available as infix method. + ## CharSequence contains -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).contains("hello", "world") -assert(x).contains.atLeast(1).butAtMost(2).value("hello") -assert(x).contains.exactly(1).values("hello", "robert") -assert(x).contains.atMost(2).regex("h(e|a)llo") -assert(x).contains.ignoringCase.notOrAtMost(1).regex("h(e|a)llo", "[Rr]obert") +expect(x).contains("hello", "world") +expect(x).contains.atLeast(1).butAtMost(2).value("hello") +expect(x).contains.exactly(1).values("hello", "robert") +expect(x).contains.atMost(2).regex("h(e|a)llo") +expect(x).contains.atMost(2).regex(Regex("h(e|a)llo")) +expect(x).contains.ignoringCase.regex("h(e|a)llo", "[Rr]obert") +expect(x).contains.ignoringCase.notOrAtMost(1).elementsOf(anIterable) ``` Notice that the final steps `value`, `values` and `regex` @@ -113,39 +116,41 @@ are applicable to all shown examples (e.g. `exactly(1).values("hello", "robert")` could have been finished with `exactly(1).regex("h(e|a)llo")` as well). -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) contains Values("hello", "world") -assert(x) to contain atLeast 1 butAtMost 2 value "hello" -assert(x) to contain exactly 1 the Values("hello", "robert") -assert(x) to contain atMost 2 regex "h(e|a)llo" -assert(x) to contain ignoring case notOrAtMost 1 the RegexPatterns("h(e|a)llo", "[Rr]obert") +expect(x) contains values("hello", "world") +expect(x) contains o atLeast 1 butAtMost 2 value "hello" +expect(x) contains o exactly 1 the values("hello", "robert") +expect(x) contains o atMost 2 regex "h(e|a)llo" +expect(x) contains o atMost 2 matchFor Regex("h(e|a)llo") +expect(x) contains o ignoring case notOrAtMost 1 the regexPatterns("h(e|a)llo", "[Rr]obert") +expect(x) contains o ignoring case notOrAtMost 1 elementsOf anIterable ``` Notice that the final steps -`value`, `Values(...)`, `regex` and `RegexPatterns(..)` +`value`, `values(...)`, `regex` and `regexPatterns(..)` in the sophisticated assertion building process are applicable to all shown examples -(e.g. `exactly(1).values("hello", "robert")` could have been finished with `exactly(1).regex("h(e|a)llo")` as well). +(e.g. `exactly 1 values("hello", "robert")` could have been finished with `exactly 1 regex "h(e|a)llo"` as well). ## Iterable contains ### Iterable contains in any order -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).contains(1.2) -assert(x).contains(1.2, 5.7) -assert(x).contains { isLessThan(2) } -assert(x).contains({ isLessThan(2) }, { isGreaterThan 5 }) +expect(x).contains(1.2) +expect(x).contains(1.2, 5.7) +expect(x).contains { isLessThan(2) } +expect(x).contains({ isLessThan(2) }, { isGreaterThan(5) }) -assert(x).contains.inAnyOrder.atLeast(1).butAtMost(2).value(3.2) -assert(x).contains.inAnyOrder.exactly(1).values("hello", "robert") -assert(x).contains.inAnyOrder.atMost(2).entry { isLessOrEquals(2) } -assert(x).contains.inAnyOrder.notOrAtMost(2).entries({ notToBe(3) }, { isGreaterOrEquals(2) }) -assert(x).contains.inAnyOrder.only.value("hello") -assert(x).contains.inAnyOrder.only.values(personA, personB) -assert(x).contains.inAnyOrder.only.entry { isLessThan(2) } -assert(x).contains.inAnyOrder.only.entries({ toBe(3) }, { isLessThan(2) }) +expect(x).contains.inAnyOrder.atLeast(1).butAtMost(2).value(3.2) +expect(x).contains.inAnyOrder.exactly(1).values("hello", "robert") +expect(x).contains.inAnyOrder.atMost(2).entry { isLessOrEquals(2) } +expect(x).contains.inAnyOrder.notOrAtMost(2).entries({ notToBe(3) }, { isGreaterOrEquals(2) }) +expect(x).contains.inAnyOrder.only.value("hello") +expect(x).contains.inAnyOrder.only.values(personA, personB) +expect(x).contains.inAnyOrder.only.entry { isLessThan(2) } +expect(x).contains.inAnyOrder.only.entries({ toBe(3) }, { isLessThan(2) }) ``` Notice that the final steps `value`, `values`, `entry` and `entries` @@ -153,198 +158,203 @@ in the sophisticated assertion building process are applicable to all shown examples (e.g. `butAtMost(2).value(3.2)` could have been finished with `entries(...)` as well) -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) contains 1.2 -assert(x) contains Values(1.2, 5.7) // or Objects as alternative -assert(x) contains { o isLessThan 2 } -assert(x) contains Entries({ o isLessThan 2 }, { o isGreaterThan 5 }) +expect(x) contains 1.2 +expect(x) contains values(1.2, 5.7) // or Objects as alternative +expect(x) contains { it isLessThan 2 } +expect(x) contains entries({ it isLessThan 2 }, { it isGreaterThan 5 }) -assert(x) to contain inAny order atLeast 1 butAtMost 2 value 3.2 -assert(x) to contain inAny order exactly 1 the Values("hello", "robert") -assert(x) to contain inAny order atMost 2 entry { o isLessOrEquals 2 } -assert(x) to contain inAny order notOrAtMost 2 the Entries({ o notToBe 3 }, { o isGreaterOrEquals 2 }) -assert(x) to contain inAny order but only value "hello") -assert(x) to contain inAny order but only the Values(personA, personB) -assert(x) to contain inAny order but only entry { o isLessThan 2 } -assert(x) to contain inAny order but only the Entries({ o toBe 3 }, { o isLessThan 2 }) +expect(x) contains o inAny order atLeast 1 butAtMost 2 value 3.2 +expect(x) contains o inAny order exactly 1 the values("hello", "robert") +expect(x) contains o inAny order atMost 2 entry { it isLessOrEquals 2 } +expect(x) contains o inAny order notOrAtMost 2 the entries({ it notToBe 3 }, { it isGreaterOrEquals 2 }) +expect(x) contains o inAny order but only value "hello" +expect(x) contains o inAny order but only the values(personA, personB) +expect(x) contains o inAny order but only entry { it isLessThan 2 } +expect(x) contains o inAny order but only the entries({ it toBe 3 }, { it isLessThan 2 }) ``` -Notice that the final steps -`value`, `Values(...)`, `entry` and `Entries(...)` +Note that `o` is a filler object which is only there so that we can turn extension methods without parameters into +a method with one parameter and thus make it available as infix method. + +The final steps `value`, `values(...)`, `entry` and `entries(...)` in the sophisticated assertion building process, are applicable to all shown examples -(e.g. `butAtMost 2 value 3.2` could have been finished with `Entries(...)` as well) +(e.g. `butAtMost 2 value 3.2` could have been finished with `entries(...)` as well) ### Iterable contains in order -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).containsExactly(1.2) -assert(x).containsExactly(1.2, 5.7) -assert(x).containsExactly({ isLessThan(2) }) -assert(x).containsExactly({ isLessThan(2) }, { isGreaterThan 5 }) +expect(x).containsExactly(1.2) +expect(x).containsExactly(1.2, 5.7) +expect(x).containsExactly({ isLessThan(2) }) +expect(x).containsExactly({ isLessThan(2) }, { isGreaterThan 5 }) -assert(x).contains.inOrder.only.value("hello") -assert(x).contains.inOrder.only.values("hello", "world") -assert(x).contains.inOrder.only.entry { isLessThan(2) } -assert(x).contains.inOrder.only.entries({ toBe(3) }, { isLessThan(2) }) -assert(x).contains.inOrder.only.grouped.within.inAnyOrder( - Value(1), - Values(1, 2), - Values(3, 4) +expect(x).contains.inOrder.only.value("hello") +expect(x).contains.inOrder.only.values("hello", "world") +expect(x).contains.inOrder.only.entry { isLessThan(2) } +expect(x).contains.inOrder.only.entries({ toBe(3) }, { isLessThan(2) }) +expect(x).contains.inOrder.only.grouped.within.inAnyOrder( + value(1), + values(1, 2), + values(3, 4) ) -assert(x).contains.inOrder.only.grouped.within.inAnyOrder( - Entry({ toBe(1) }), - Entries({ isLessThan(2) },{ isGreaterThan(2) }), - Entries({ toBe(3) }, { toBe(4) }) +expect(x).contains.inOrder.only.grouped.within.inAnyOrder( + entry { toBe(1) }, + entries({ isLessThan(2) },{ isGreaterThan(2) }), + entries({ toBe(3) }, { toBe(4) }) ) ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) containsExactly 1.2 -assert(x) containsExactly Values(1.2, 5.7) // or Objects as alternative -assert(x) containsExactly { o isLessThan 2 } -assert(x) containsExactly Entries({ o isLessThan 2 }, { o isGreaterThan 5 }) +expect(x) containsExactly 1.2 +expect(x) containsExactly values(1.2, 5.7) // or Objects as alternative +expect(x) containsExactly { it isLessThan 2 } +expect(x) containsExactly entries({ it isLessThan 2 }, { it isGreaterThan 5 }) -assert(x) contains inGiven order and only value "hello" -assert(x) contains inGiven order and only the Values("hello", "world") -assert(x) contains inGiven order and only entry { o isLessThan 2 } -assert(x) contains inGiven order and only the Entries({ o toBe 3 }, { o isLessThan 2 }) -assert(x) contains inGiven order and only grouped entries within group inAny Order( - Value(1), - Values(1, 2), - Values(3, 4) +expect(x) contains o inGiven order and only value "hello" +expect(x) contains o inGiven order and only the values("hello", "world") +expect(x) contains o inGiven order and only entry { it isLessThan 2 } +expect(x) contains o inGiven order and only the entries({ it toBe 3 }, { it isLessThan 2 }) +expect(x) contains o inGiven order and only grouped entries within group inAny Order( + value(1), + values(1, 2), + values(3, 4) ) -assert(x) contains inGiven order and only grouped entries within group inAny Order( - Entry({ o toBe(1) }), - Entries({ o isLessThan(2) },{ o isGreaterThan(2) }), - Entries({ o toBe(3) }, { o toBe(4) }) +expect(x) contains o inGiven order and only grouped entries within group inAny Order( + entry { it toBe 1 }, + entries({ it isLessThan 2 },{ it isGreaterThan 2 }), + entries({ it toBe 3 }, { it toBe 4 }) ) ``` +Note that `o` is a filler object which is only there so that we can turn extension methods without parameters into +a method with one parameter and thus make it available as infix method. + ## Iterable contains not -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).containsNot(1.2) -assert(x).containsNot(1.2, 5.7) +expect(x).containsNot(1.2) +expect(x).containsNot(1.2, 5.7) -assert(x).containsNot.value(null) -assert(x).containsNot.values(null, 1) -assert(x).containsNot.entry { isLessThan(2) } -assert(x).containsNot.entries(null, { isLessThan(2) }, { isGreaterThan 5 }) +expect(x).containsNot.value(null) +expect(x).containsNot.values(null, 1) +expect(x).containsNot.entry { isLessThan(2) } +expect(x).containsNot.entries(null, { isLessThan(2) }, { isGreaterThan 5 }) ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) containsNot 1.2 -assert(x) containsNot Values(1.2, 5.7) +expect(x) containsNot 1.2 +expect(x) containsNot values(1.2, 5.7) -assert(x) notTo contain value null -assert(x) notTo contain the Values(null, 1) -assert(x) notTo contain entry { o isLessThan 2 } -assert(x) notTo contain the Entries(null, { o isLessThan 2 }, { o isGreaterThan 5 }) +expect(x) containsNot o value null +expect(x) containsNot o the values(null, 1) +expect(x) containsNot o entry { it isLessThan 2 } +expect(x) containsNot o the entries(null, { it isLessThan 2 }, { it isGreaterThan 5 }) ``` # Iterable predicate-like assertions For more sophisticated assertions such as "there should be two matches", use the sophisticated assertion builder `contains.inAnyOrder` -> see [Iterable contains in any order](#iterable-contains-in-any-order) for more information -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).any { startsWith("hello") } -assert(x).none { endsWith(".") } -assert(x).all { isNumericallyEqualTo(12.2) } +expect(x).any { startsWith("hello") } +expect(x).none { endsWith(".") } +expect(x).all { isNumericallyEqualTo(12.2) } -assert(x).any(null) -assert(x).none(null) -assert(x).all(null) +expect(x).any(null) +expect(x).none(null) +expect(x).all(null) ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) any { o startsWith "hello" } -assert(x) none { o endsWith "." } -assert(x) all { o isNumericallyEqualTo 12.2 } +expect(x) any { it startsWith "hello" } +expect(x) none { it endsWith "." } +expect(x) all { it isNumericallyEqualTo 12.2 } -assert(x) any null -assert(x) none null -assert(x) all null +expect(x) any null +expect(x) none null +expect(x) all null ``` # List get -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).get(0).isLessThan(1) -assert(x).get(0) { isGreaterThan(1) } +expect(x).get(0).isLessThan(1) +expect(x).get(0) { isGreaterThan(1) } //in case of a nullable element type -assert(x).get(0).toBe(null) +expect(x).get(0).toBe(null) ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) get 0 isLessThan 1 -assert(x) get Index(0) assertIt { o isGreaterThan 1 } +expect(x) get 0 isLessThan 1 +expect(x) get index(0) { it isGreaterThan 1 } //in case of a nullable element type -assert(x) get 0 toBe null +expect(x) get 0 toBe null ``` # Map getExisting -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).getExisting("a").isLessThan(1) -assert(x).getExisting("a") { isGreaterThan(1) } +expect(x).getExisting("a").isLessThan(1) +expect(x).getExisting("a") { isGreaterThan(1) } //in case of a nullable value type -assert(x).getExisting("a").notToBeNull { isGreaterThan(1) } +expect(x).getExisting("a").notToBeNull { isGreaterThan(1) } ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) getExisting "a" isLessThan 1 -assert(x) getExisting Key("a") assertIt { o isGreaterThan 1 } +expect(x) getExisting "a" isLessThan 1 +expect(x) getExisting key("a") { it isGreaterThan 1 } //in case of a nullable value type -assert(x) getExisting Key("a") notToBeNull { o isGreaterThan 1 } +expect(x) getExisting "a" notToBeNull { it isGreaterThan 1 } ``` # Map contains -*atrium-api-cc-en_GB* +*atrium-api-fluent-en_GB* ```kotlin -assert(x).contains("a" to 1) -assert(x).contains("a" to 1, "b" to 2) -assert(x).contains(KeyValue("a") { isGreaterThan(3).and.isLessThan(10) }) -assert(x).contains(KeyValue("a") { toBe(2) }, KeyValue("b") { isLessThan(3) }) +expect(x).contains("a" to 1) +expect(x).contains("a" to 1, "b" to 2) +expect(x).contains(KeyValue("a") { isGreaterThan(3).and.isLessThan(10) }) +expect(x).contains(KeyValue("a") { toBe(2) }, KeyValue("b") { isLessThan(3) }) //in case of a nullable value type -assert(x).contains("a" to null) -assert(x).contains("a" to null, "b" to 2) -assert(x).contains(KeyValue("a", null)) -assert(x).contains( +expect(x).contains("a" to null) +expect(x).contains("a" to null, "b" to 2) +expect(x).contains(KeyValue("a", null)) +expect(x).contains( KeyValue("a", null) KeyValue("b") { isLessThan(2) } ) ``` -*atrium-api-cc-infix-en_GB* +*atrium-api-infix-en_GB* ```kotlin -assert(x) contains ("a" to 1) -assert(x) contains Pairs("a" to 1, "b" to 2) -assert(x) contains KeyValue("a") { - o isGreaterThan 3 - o isLessThan 10 +expect(x) contains ("a" to 1) +expect(x) contains pairs("a" to 1, "b" to 2) +expect(x) contains keyValue("a") { + it isGreaterThan 3 + it isLessThan 10 } -assert(x) contains All(KeyValue("a") { o toBe 2 }, KeyValue("b") { o isLessThan 3 }) +expect(x) contains all(keyValue("a") { it toBe 2 }, keyValue("b") { it isLessThan 3 }) //in case of a nullable value type -assert(x) contains ("a" to null) -assert(x) contains Pairs("a" to null, "b" to 2) -assert(x) contains KeyValue("a", null) -assert(x) contains All( - KeyValue("a", null), - KeyValue("b") { o isLessThan 2 } +expect(x) contains ("a" to null) +expect(x) contains pairs("a" to null, "b" to 2) +expect(x) contains keyValue("a", null) +expect(x) contains all( + keyValue("a", null), + keyValue("b") { it isLessThan 2 } ) ``` From a24a2d823c672c8dea31aa1caa9e8637daa43d38 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 4 Apr 2020 15:38:52 +0200 Subject: [PATCH 129/142] make constructor of parameter objects internal in the new infix API --- .../kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt | 5 ++++- .../ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt | 3 ++- .../ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt | 2 +- .../atrium/api/infix/en_GB/creating/IndexWithCreator.kt | 2 +- .../atrium/api/infix/en_GB/creating/KeyWithCreator.kt | 2 +- .../ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt | 2 +- .../atrium/api/infix/en_GB/creating/PresentWithCreator.kt | 2 +- .../tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt | 2 +- .../atrium/api/infix/en_GB/creating/SuccessWithCreator.kt | 2 +- .../ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt | 2 +- .../ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt | 2 +- .../atrium/api/infix/en_GB/creating/feature/Feature.kt | 2 +- .../api/infix/en_GB/creating/feature/FeatureWithCreator.kt | 2 +- .../en_GB/creating/feature/MetaFeatureOptionWithCreator.kt | 2 +- .../atrium/api/infix/en_GB/creating/iterable/Order.kt | 2 +- .../api/infix/en_GB/creating/map/KeyWithValueCreator.kt | 5 ++++- .../api/infix/en_GB/iterableContainsInAnyOrderCreators.kt | 2 +- .../infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt | 2 +- .../api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt | 2 +- .../api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt | 2 +- 20 files changed, 27 insertions(+), 20 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt index 1a42f62ea..56752df0b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/All.kt @@ -7,4 +7,7 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper * * Use the function `all(t, ...)` to create this representation. */ -class All(override val expected: T, override val otherExpected: Array) : VarArgHelper +class All internal constructor( + override val expected: T, + override val otherExpected: Array +) : VarArgHelper diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt index 0b90baa4e..e1155d70d 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entries.kt @@ -1,4 +1,5 @@ @file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */) + package ch.tutteli.atrium.api.infix.en_GB.creating import ch.tutteli.atrium.assertions.Assertion @@ -24,7 +25,7 @@ import ch.tutteli.kbox.glue * In case it is defined as `null`, then an entry is identified if it is `null` as well. * @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s. */ -class Entries( +class Entries internal constructor( val assertionCreatorOrNull: (Expect.() -> Unit)?, val otherAssertionCreatorsOrNulls: Array.() -> Unit)?> ) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt index 9b266c33f..6e8b3be6e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Entry.kt @@ -19,7 +19,7 @@ import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries * to be identified if it holds all [Assertion]s the lambda creates. * In case it is defined as `null`, then an entry is identified if it is `null` as well. */ -data class Entry( +data class Entry internal constructor( val assertionCreatorOrNull: (Expect.() -> Unit)? ) : GroupWithoutNullableEntries<(Expect.() -> Unit)?>, GroupWithNullableEntries<(Expect.() -> Unit)?> { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt index 9ad39c86b..d6a35f764 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/IndexWithCreator.kt @@ -11,4 +11,4 @@ import ch.tutteli.atrium.creating.Expect * * @since 0.11.0 */ -data class IndexWithCreator(val index: Int, val assertionCreator: Expect.() -> Unit) +data class IndexWithCreator internal constructor(val index: Int, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt index a92419580..1529b2746 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/KeyWithCreator.kt @@ -11,4 +11,4 @@ import ch.tutteli.atrium.creating.Expect * * @since 0.11.0 */ -data class KeyWithCreator(val key: K, val assertionCreator: Expect.() -> Unit) +data class KeyWithCreator internal constructor(val key: K, val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt index 709319f71..3f352d9e6 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Pairs.kt @@ -7,7 +7,7 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper * * Use the function `pairs(x to y, ...)` to create this representation. */ -class Pairs( +class Pairs internal constructor( override val expected: Pair, override val otherExpected: Array> ) : VarArgHelper> diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt index 2658a26e4..68cd2df3b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/PresentWithCreator.kt @@ -10,4 +10,4 @@ import ch.tutteli.atrium.creating.Expect * * @since 0.11.0 */ -data class PresentWithCreator(val assertionCreator: Expect.() -> Unit) +data class PresentWithCreator internal constructor(val assertionCreator: Expect.() -> Unit) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt index f88013f5b..6d66c5828 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/RegexPatterns.kt @@ -7,7 +7,7 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper * * Use the function `regexPatterns("pattern", ...)` to create this representation. */ -class RegexPatterns(pattern: String, otherPatterns: Array) : +class RegexPatterns internal constructor(pattern: String, otherPatterns: Array) : VarArgHelper { override val expected = pattern override val otherExpected = otherPatterns diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt index cb9d974f3..8ea1e0972 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/SuccessWithCreator.kt @@ -9,4 +9,4 @@ import ch.tutteli.atrium.creating.Expect * * @since 0.11.0 */ -data class SuccessWithCreator(val assertionCreator: Expect.() -> Unit); +data class SuccessWithCreator internal constructor(val assertionCreator: Expect.() -> Unit); diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt index 6fad286c1..f7b33e80a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Value.kt @@ -10,7 +10,7 @@ import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries * * Use the function `value(t)` to create this representation. */ -data class Value(val expected: T) : GroupWithNullableEntries, +data class Value internal constructor(val expected: T) : GroupWithNullableEntries, GroupWithoutNullableEntries { override fun toList() = listOf(expected) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt index 43b8c16ab..12f68efba 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/Values.kt @@ -15,7 +15,7 @@ import ch.tutteli.atrium.domain.builders.utils.VarArgHelper * Note, [Values] will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0) */ //TODO remove `out` with Kotlin 1.4 (most likely with Atrium 1.0.0) -class Values( +class Values internal constructor( override val expected: T, override val otherExpected: Array ) : GroupWithoutNullableEntries, GroupWithNullableEntries, VarArgHelper { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt index fadaf71d8..8627efa1e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/Feature.kt @@ -15,4 +15,4 @@ import kotlin.reflect.KProperty1 * @since 0.11.0 */ -data class Feature(val description: String, val extractor: (T) -> R) +data class Feature internal constructor(val description: String, val extractor: (T) -> R) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt index be092d45d..b220e414e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/FeatureWithCreator.kt @@ -18,7 +18,7 @@ import kotlin.reflect.KProperty1 * * @since 0.11.0 */ -data class FeatureWithCreator( +data class FeatureWithCreator internal constructor( val description: String, val extractor: (T) -> R, val assertionCreator: Expect.() -> Unit diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt index a62365c5e..b0c4feef2 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/feature/MetaFeatureOptionWithCreator.kt @@ -16,7 +16,7 @@ import ch.tutteli.atrium.domain.creating.MetaFeature * * @since 0.11.0 */ -data class MetaFeatureOptionWithCreator( +data class MetaFeatureOptionWithCreator internal constructor( val provider: MetaFeatureOption.(T) -> MetaFeature, val assertionCreator: Expect.() -> Unit ) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt index edc161327..2767bee16 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/Order.kt @@ -9,7 +9,7 @@ import ch.tutteli.atrium.domain.builders.utils.Group * * Notice, most probably the type parameter G will be removed in the future, will be fixed to [Group]. */ -class Order>( +class Order> internal constructor( val firstGroup: G, val secondGroup: G, val otherExpectedGroups: Array diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt index a38502d50..4a26b57c8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/map/KeyWithValueCreator.kt @@ -8,7 +8,10 @@ import ch.tutteli.atrium.creating.Expect * * Use the function `keyValue(x) { ... }` to create this representation. */ -data class KeyWithValueCreator(val key: K, val valueAssertionCreatorOrNull: (Expect.() -> Unit)?) { +data class KeyWithValueCreator internal constructor( + val key: K, + val valueAssertionCreatorOrNull: (Expect.() -> Unit)? +) { fun toPair(): Pair.() -> Unit)?> = key to valueAssertionCreatorOrNull override fun toString(): String = "KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})" diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt index 50cc8019e..4e632370b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderCreators.kt @@ -101,5 +101,5 @@ inline infix fun > CheckerOption ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, rest) + return this the values(first, *rest) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt index 7867533c8..f5a116b49 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInAnyOrderOnlyCreators.kt @@ -120,5 +120,5 @@ inline infix fun > Builder ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, rest) + return this the values(first, *rest) } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt index 84860e5a6..921105e6e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableContainsInOrderOnlyCreators.kt @@ -112,5 +112,5 @@ inline infix fun > Builder ): Expect { val (first, rest) = toVarArg(expectedIterable) - return this the Values(first, rest) + return this the values(first, *rest) } diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt index 8a8fa4dde..f8043478a 100644 --- a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/creating/path/PathWithCreator.kt @@ -12,4 +12,4 @@ import ch.tutteli.atrium.creating.Expect * * @since 0.11.0 */ -data class PathWithCreator(val path: String, val assertionCreator: Expect.() -> Unit) +data class PathWithCreator internal constructor(val path: String, val assertionCreator: Expect.() -> Unit) From d63dbd49d3ad7f9ac90412c4e85991a3a77a9014 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Sat, 4 Apr 2020 16:34:25 +0200 Subject: [PATCH 130/142] Update end year of copyright --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index fd1d5d16b..74a0faa17 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Atrium © Copyright Robert Stoll 2017, 2019 +Atrium © Copyright Robert Stoll 2017, 2020 EUROPEAN UNION PUBLIC LICENCE v. 1.2 EUPL © the European Union 2007, 2016 From a0458c7ad6060eb351037664f2b1235e452b04c8 Mon Sep 17 00:00:00 2001 From: Ivan Fedorov Date: Sat, 4 Apr 2020 18:08:16 +0300 Subject: [PATCH 131/142] add chronoLocalDateTimeAssertion to infix API (#314) --- .../jdk8/chronoLocalDateTimeAssertions.kt | 73 ++++++++++++++++++ .../jdk8/ChronoLocalDateTimeAssertionSpec.kt | 75 +++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateTimeAssertions.kt create mode 100644 apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateTimeAssertionSpec.kt diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateTimeAssertions.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateTimeAssertions.kt new file mode 100644 index 000000000..2a94385d9 --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/chronoLocalDateTimeAssertions.kt @@ -0,0 +1,73 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.domain.builders.chronoLocalDateTime +import java.time.chrono.ChronoLocalDate +import java.time.chrono.ChronoLocalDateTime + +/** + * Expects that the subject of the assertion (a [ChronoLocalDateTime]) + * is before the [expected] [ChronoLocalDateTime]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.isBefore(expected: ChronoLocalDateTime<*>): Expect = + addAssertion(ExpectImpl.chronoLocalDateTime.isBefore(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDateTime]) + * is before or equal the [expected] [ChronoLocalDateTime]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.isBeforeOrEqual( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isBeforeOrEquals(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDateTime]) + * is after the [expected] [ChronoLocalDateTime]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.isAfter( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isAfter(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDateTime]) + * is after or equal the [expected] [ChronoLocalDateTime]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.isAfterOrEqual( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isAfterOrEquals(this, expected)) + +/** + * Expects that the subject of the assertion (a [ChronoLocalDateTime]) + * is equal to the [expected] [ChronoLocalDateTime]. + * + * @return An [Expect] for the current subject of the assertion. + * @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct. + * + * @since 0.11.0 + */ +infix fun > Expect.isEqual( + expected: ChronoLocalDateTime<*> +): Expect = addAssertion(ExpectImpl.chronoLocalDateTime.isEqual(this, expected)) diff --git a/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateTimeAssertionSpec.kt b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateTimeAssertionSpec.kt new file mode 100644 index 000000000..8db4f832d --- /dev/null +++ b/apis/infix-en_GB/extensions/jdk8/atrium-api-infix-en_GB-jdk8-jvm/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/jdk8/ChronoLocalDateTimeAssertionSpec.kt @@ -0,0 +1,75 @@ +package ch.tutteli.atrium.api.infix.en_GB.jdk8 + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.specs.fun1 +import ch.tutteli.atrium.specs.notImplemented +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.chrono.ChronoLocalDate +import java.time.chrono.ChronoLocalDateTime + +class ChronoLocalDateTimeAssertionSpec : ch.tutteli.atrium.specs.integration.ChronoLocalDateTimeAssertionSpec( + fun1(Expect>::isBefore), + fun1(Expect>::isBeforeOrEqual), + fun1(Expect>::isAfter), + fun1(Expect>::isAfterOrEqual), + fun1(Expect>::isEqual) +) { + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + val chronoLocalDateTime: ChronoLocalDateTime<*> = notImplemented() + var a1: Expect> = notImplemented() + var a2: Expect> = notImplemented() + var a3: Expect> = notImplemented() + var a4: Expect = notImplemented() + + a1 = a1 isBefore LocalDateTime.now() + a1 = a1 isBeforeOrEqual LocalDateTime.now() + a1 = a1 isAfter LocalDateTime.now() + a1 = a1 isAfterOrEqual LocalDateTime.now() + a1 = a1 isEqual LocalDateTime.now() + + a2 = a2 isBefore LocalDateTime.now() + a2 = a2 isBeforeOrEqual LocalDateTime.now() + a2 = a2 isAfter LocalDateTime.now() + a2 = a2 isAfterOrEqual LocalDateTime.now() + a2 = a2 isEqual LocalDateTime.now() + + a3 = a3 isBefore LocalDateTime.now() + a3 = a3 isBeforeOrEqual LocalDateTime.now() + a3 = a3 isAfter LocalDateTime.now() + a3 = a3 isAfterOrEqual LocalDateTime.now() + a3 = a3 isEqual LocalDateTime.now() + + a4 = a4 isBefore LocalDateTime.now() + a4 = a4 isBeforeOrEqual LocalDateTime.now() + a4 = a4 isAfter LocalDateTime.now() + a4 = a4 isAfterOrEqual LocalDateTime.now() + a4 = a4 isEqual LocalDateTime.now() + + a1 = a1 isBefore chronoLocalDateTime + a1 = a1 isBeforeOrEqual chronoLocalDateTime + a1 = a1 isAfter chronoLocalDateTime + a1 = a1 isAfterOrEqual chronoLocalDateTime + a1 = a1 isEqual chronoLocalDateTime + + a2 = a2 isBefore chronoLocalDateTime + a2 = a2 isBeforeOrEqual chronoLocalDateTime + a2 = a2 isAfter chronoLocalDateTime + a2 = a2 isAfterOrEqual chronoLocalDateTime + a2 = a2 isEqual chronoLocalDateTime + + a3 = a3 isBefore chronoLocalDateTime + a3 = a3 isBeforeOrEqual chronoLocalDateTime + a3 = a3 isAfter chronoLocalDateTime + a3 = a3 isAfterOrEqual chronoLocalDateTime + a3 = a3 isEqual chronoLocalDateTime + + a4 = a4 isBefore chronoLocalDateTime + a4 = a4 isBeforeOrEqual chronoLocalDateTime + a4 = a4 isAfter chronoLocalDateTime + a4 = a4 isAfterOrEqual chronoLocalDateTime + a4 = a4 isEqual chronoLocalDateTime + } +} From 1c97c672f754854d190f54933d0811be63fcf9cd Mon Sep 17 00:00:00 2001 From: assaflei Date: Sat, 4 Apr 2020 22:15:23 +0300 Subject: [PATCH 132/142] moved from misc jvm translating and reporting --- .../robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt | 0 .../reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt | 0 .../atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt | 0 .../translating/TranslationSupplierBasedTranslatorSpec.kt | 0 .../atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename core/robstoll-lib/{atrium-core-robstoll-lib-jvm => atrium-core-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt (100%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt (100%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt (100%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt (100%) rename misc/specs/{atrium-specs-jvm => atrium-specs-common}/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt (100%) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt similarity index 100% rename from core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt rename to core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/translating/LocaleOrderDeciderSpec.kt diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt similarity index 100% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/EmptyNameAndSubjectAssertionGroupFormatterSpec.kt diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt similarity index 100% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/LocaleOrderDeciderSpec.kt diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt similarity index 100% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslationSupplierBasedTranslatorSpec.kt diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt similarity index 100% rename from misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/reporting/translating/TranslatorErrorCaseSpec.kt From 162a34270dafbc50b74e2048cab5c01bcb2073c5 Mon Sep 17 00:00:00 2001 From: assaflei Date: Sat, 4 Apr 2020 23:16:53 +0300 Subject: [PATCH 133/142] moved classes from atrium-core-robstoll-lib-jvm to atrium-core-robstoll-lib-common --- .../core/robstoll/lib/checking/FeatureAssertionCheckerSpec.kt | 0 .../core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt | 0 .../atrium/core/robstoll/lib/reporting/OnlyFailureReporterSpec.kt | 0 .../core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename core/robstoll-lib/{atrium-core-robstoll-lib-jvm => atrium-core-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/FeatureAssertionCheckerSpec.kt (100%) rename core/robstoll-lib/{atrium-core-robstoll-lib-jvm => atrium-core-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt (100%) rename core/robstoll-lib/{atrium-core-robstoll-lib-jvm => atrium-core-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/OnlyFailureReporterSpec.kt (100%) rename core/robstoll-lib/{atrium-core-robstoll-lib-jvm => atrium-core-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt (100%) diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/FeatureAssertionCheckerSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/FeatureAssertionCheckerSpec.kt similarity index 100% rename from core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/FeatureAssertionCheckerSpec.kt rename to core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/FeatureAssertionCheckerSpec.kt diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt similarity index 100% rename from core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt rename to core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/checking/ThrowingAssertionCheckerSpec.kt diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/OnlyFailureReporterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/OnlyFailureReporterSpec.kt similarity index 100% rename from core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/OnlyFailureReporterSpec.kt rename to core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/OnlyFailureReporterSpec.kt diff --git a/core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt b/core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt similarity index 100% rename from core/robstoll-lib/atrium-core-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt rename to core/robstoll-lib/atrium-core-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/core/robstoll/lib/reporting/TextMethodCallFormatterSpec.kt From ffc44b01db80b49cd26e502fe0646422789a6ec9 Mon Sep 17 00:00:00 2001 From: Ivan Fedorov Date: Sun, 5 Apr 2020 00:24:30 +0300 Subject: [PATCH 134/142] add bundles for new infix API (issue #236) --- .../atrium-infix-en_GB-android/build.gradle | 18 +++++ .../atrium-infix-en_GB-common/build.gradle | 13 ++++ .../src/test/kotlin/SmokeTest.kt | 71 +++++++++++++++++++ .../atrium-infix-en_GB-js/build.gradle | 13 ++++ .../tutteli/atrium/infix/en_GB/dependOnMe.kt | 15 ++++ .../atrium/infix/en_GB/JsNameAmbiguityTest.kt | 25 +++++++ .../src/test/kotlin/testSetup.kt | 4 ++ .../atrium-infix-en_GB-jvm/build.gradle | 16 +++++ .../src/module/module-info.java | 7 ++ .../src/test/kotlin/custom/SmokeSpec.kt | 43 +++++++++++ .../src/test/kotlin/module-info.java | 9 +++ .../build.gradle | 10 +++ .../src/test/kotlin/custom/SmokeSpec.kt | 50 +++++++++++++ .../src/test/kotlin/module-info.java | 10 +++ .../build.gradle | 11 +++ .../src/test/kotlin/custom/SmokeSpec.kt | 50 +++++++++++++ .../src/test/kotlin/module-info.java | 10 +++ settings.gradle | 1 + 18 files changed, 376 insertions(+) create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-android/build.gradle create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-js/build.gradle create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-js/src/main/kotlin/ch/tutteli/atrium/infix/en_GB/dependOnMe.kt create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/ch/tutteli/atrium/infix/en_GB/JsNameAmbiguityTest.kt create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/testSetup.kt create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/module/module-info.java create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt create mode 100644 bundles/infix-en_GB/atrium-infix-en_GB-smoke-test/src/test/kotlin/module-info.java create mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle create mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt create mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java create mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/build.gradle create mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt create mode 100644 bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-android/build.gradle b/bundles/infix-en_GB/atrium-infix-en_GB-android/build.gradle new file mode 100644 index 000000000..fe21f751f --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-android/build.gradle @@ -0,0 +1,18 @@ +description = 'Represents a convenience module which merely bundles dependencies for Android.' + +dependencies { + api prefixedProject('verbs-android') + api prefixedProject('api-infix-en_GB-android') + api prefixedProject('translations-en_GB-android') + api prefixedProject('domain-builders-android') + api prefixedProject('domain-api-android') + api prefixedProject('core-api-android') + + runtimeOnly prefixedProject('domain-robstoll-android') + runtimeOnly prefixedProject('core-robstoll-android') + + //TODO remove once all specs are with spek2 where they are set via spek plugin + spekDep(delegate) +} + +srcAndResourcesFromJvmProject(project) diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle b/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle new file mode 100644 index 000000000..89e3094f8 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-common/build.gradle @@ -0,0 +1,13 @@ +description = 'Represents a convenience module which merely bundles dependencies as common module.' + +dependencies { + api prefixedProject('verbs-common') + api prefixedProject('api-infix-en_GB-common') + api prefixedProject('translations-en_GB-common') + api prefixedProject('domain-builders-common') + api prefixedProject('domain-api-common') + api prefixedProject('core-api-common') + + runtimeOnly prefixedProject('domain-robstoll-common') + runtimeOnly prefixedProject('core-robstoll-common') +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt b/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt new file mode 100644 index 000000000..763baff50 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt @@ -0,0 +1,71 @@ +import ch.tutteli.atrium.api.infix.en_GB.* +import ch.tutteli.atrium.api.verbs.AssertionVerb +import ch.tutteli.atrium.api.verbs.assert +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic.IS +import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE +import kotlin.test.Test + +class SmokeTest { + + @Test + fun toBe_canBeUsed() { + assertThat(1) toBe 1 + } + + @Test + fun assertionFunctionWithoutI18nCanBeUsed() { + assertThat(2) tobe even + } + + @Test + fun assertionFunctionWithI18nCanBeUsed() { + assertThat(4) isMultipleOf 2 + } + + @Test + fun assertAnExceptionOccurred() { + assertThat { + throw IllegalArgumentException() + }.toThrow() + } + + @Test + fun assertAnExceptionWithAMessageOccurred() { + assertThat { + throw IllegalArgumentException("oho... hello btw") + }.toThrow { + it messageContains "hello" + } + } + + @Test + fun assertNotToThrow() { + assertThat { + + }.notToThrow() + } +} + +@Suppress("ClassName") +object even + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = + createAndAddAssertion(IS, RawString.create("an even number")) { it % 2 == 0 } + +infix fun Expect.isMultipleOf(base: Int): Expect = addAssertion(isMultipleOf(this, base)) + +private fun isMultipleOf(expect: Expect, base: Int): Assertion = + ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-js/build.gradle b/bundles/infix-en_GB/atrium-infix-en_GB-js/build.gradle new file mode 100644 index 000000000..6a50e2861 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-js/build.gradle @@ -0,0 +1,13 @@ +description = 'Represents a convenience module which merely bundles dependencies for the JS platform.' + +dependencies { + api prefixedProject('verbs-js') + api prefixedProject('api-infix-en_GB-js') + api prefixedProject('translations-en_GB-js') + api prefixedProject('domain-builders-js') + api prefixedProject('domain-api-js') + api prefixedProject('core-api-js') + + implementation prefixedProject('domain-robstoll-js') + implementation prefixedProject('core-robstoll-js') +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-js/src/main/kotlin/ch/tutteli/atrium/infix/en_GB/dependOnMe.kt b/bundles/infix-en_GB/atrium-infix-en_GB-js/src/main/kotlin/ch/tutteli/atrium/infix/en_GB/dependOnMe.kt new file mode 100644 index 000000000..24c0ea737 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-js/src/main/kotlin/ch/tutteli/atrium/infix/en_GB/dependOnMe.kt @@ -0,0 +1,15 @@ +package ch.tutteli.atrium.infix.en_GB + +import ch.tutteli.atrium.core.robstoll.dependOn_atrium_core_robstoll +import ch.tutteli.atrium.domain.robstoll.dependOn_atrium_domain_robstoll + +/** + * Dummy function in order that other modules can define a dependency on atrium-infix-en_GB-js + * + * Moreover it has the side effect that a dependency on core-robstoll and domain-robstoll is established. + * This is necessary, as it has only a loosely coupled dependency (via serviceLoader). + */ +fun dependOnAtrium() { + dependOn_atrium_core_robstoll() + dependOn_atrium_domain_robstoll() +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/ch/tutteli/atrium/infix/en_GB/JsNameAmbiguityTest.kt b/bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/ch/tutteli/atrium/infix/en_GB/JsNameAmbiguityTest.kt new file mode 100644 index 000000000..5a43fe4d0 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/ch/tutteli/atrium/infix/en_GB/JsNameAmbiguityTest.kt @@ -0,0 +1,25 @@ +package ch.tutteli.atrium.infix.en_GB + +import ch.tutteli.atrium.api.infix.en_GB.asEntries +import ch.tutteli.atrium.api.infix.en_GB.* +import ch.tutteli.atrium.api.verbs.expect +import kotlin.test.Test + +/** + * As there are bugs related to JsName in Kotlin we should test each to be sure that it works also during runtime. + */ +class JsNameAmbiguityTest { + + @Test + fun toBeNullable() { + expect(null as Int?) toBe null + expect(1 as Int?) toBe 1 + } + + @Test + fun isKeyValueNullable() { + expect(mapOf(1 to null as Int?)).asEntries(o).containsExactly { + it isKeyValue (1 to null) + } + } +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/testSetup.kt b/bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/testSetup.kt new file mode 100644 index 000000000..8b1a8c5a8 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-js/src/test/kotlin/testSetup.kt @@ -0,0 +1,4 @@ +import ch.tutteli.atrium.infix.en_GB.dependOnAtrium + +@Suppress("unused") +private val establishDependencyToAtrium = dependOnAtrium() diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle new file mode 100644 index 000000000..b8296a9b4 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle @@ -0,0 +1,16 @@ +description = 'Represents a convenience module which merely bundles dependencies for the JVM platform.' + +dependencies { + api prefixedProject('verbs-jvm') + api prefixedProject('api-infix-en_GB-jvm') + api prefixedProject('translations-en_GB-jvm') + api prefixedProject('domain-builders-jvm') + api prefixedProject('domain-api-jvm') + api prefixedProject('core-api-jvm') + + runtimeOnly prefixedProject('domain-robstoll-jvm') + runtimeOnly prefixedProject('core-robstoll-jvm') + + //TODO remove once all specs are with spek2 where they are set via spek plugin + spekDep(delegate) +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/module/module-info.java b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/module/module-info.java new file mode 100644 index 000000000..4ef639ee2 --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/module/module-info.java @@ -0,0 +1,7 @@ +module ch.tutteli.atrium.infix.en_GB { + requires transitive ch.tutteli.atrium.verbs; + requires transitive ch.tutteli.atrium.api.infix.en_GB; + requires transitive ch.tutteli.atrium.domain.builders; + requires transitive ch.tutteli.atrium.translations.en_GB; + requires kotlin.stdlib; +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt new file mode 100644 index 000000000..f0538334a --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/src/test/kotlin/custom/SmokeSpec.kt @@ -0,0 +1,43 @@ +package custom + +import ch.tutteli.atrium.api.infix.en_GB.toBe +import ch.tutteli.atrium.api.verbs.assertThat +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic +import org.spekframework.spek2.Spek + +object SmokeSpec : Spek({ + test("see if `toBe` can be used") { + assertThat(1) toBe 1 + } + + test("see if own assertion function without i18n can be used") { + assertThat(2) tobe even + } + + test("see if own assertion function with i18n can be used") { + assertThat(4) isMultipleOf 2 + } +}) + +@Suppress("ClassName") +object even + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } + +infix fun Expect.isMultipleOf(base: Int) = addAssertion(isMultipleOf(this, base)) + +fun isMultipleOf(expect: Expect, base: Int): Assertion = + ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-smoke-test/src/test/kotlin/module-info.java b/bundles/infix-en_GB/atrium-infix-en_GB-smoke-test/src/test/kotlin/module-info.java new file mode 100644 index 000000000..1f819aa6e --- /dev/null +++ b/bundles/infix-en_GB/atrium-infix-en_GB-smoke-test/src/test/kotlin/module-info.java @@ -0,0 +1,9 @@ +module ch.tutteli.atrium.infix.en_GB.smoke { + // test dependencies are usually defined in build.gradle via --patch-module but that's quite cumbersome and I did + // not get it running in 10 minutes so I am using this, the effect should be the same, the kotlin compiler checks if + // I am using symbols from packages I do not require etc. + + requires ch.tutteli.atrium.infix.en_GB; + requires kotlin.stdlib; + requires spek.dsl.jvm; +} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle new file mode 100644 index 000000000..07db9d74a --- /dev/null +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/build.gradle @@ -0,0 +1,10 @@ +description = "Represents a JDK >= 9 smoke test for atrium-infix-en_GB with jdk8 extension" + +sourceCompatibility = JavaVersion.current() +targetCompatibility = JavaVersion.current() + +dependencies { + //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead + testImplementation prefixedProject('infix-en_GB-jvm') + testImplementation prefixedProject('api-infix-en_GB-jdk8-jvm') +} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt new file mode 100644 index 000000000..a00b8780a --- /dev/null +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/custom/SmokeSpec.kt @@ -0,0 +1,50 @@ +package custom + +import ch.tutteli.atrium.api.infix.en_GB.jdk8.notTo +import ch.tutteli.atrium.api.infix.en_GB.exist +import ch.tutteli.atrium.api.infix.en_GB.toBe +import ch.tutteli.atrium.api.verbs.assert +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe +import java.nio.file.Paths + +object SmokeSpec : Spek({ + test("see if `toBe` can be used") { + assert(1) toBe 1 + } + + test("see if `Path.existsNot` can be used") { + assert(Paths.get("nonExisting")) notTo exist + } + + test("see if own assertion function without i18n can be used") { + assert(2) tobe even + } + + test("see if own assertion function with i18n can be used") { + assert(4) isMultipleOf 2 + } +}) + +@Suppress("ClassName") +object even + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } + +infix fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) + +fun _isMultipleOf(expect: Expect, base: Int): Assertion = + ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java new file mode 100644 index 000000000..0ff4f7a4d --- /dev/null +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-jdk8/src/test/kotlin/module-info.java @@ -0,0 +1,10 @@ +module ch.tutteli.atrium.infix.en_GB.jdk8.smoke { + // test dependencies are usually defined in build.gradle via --patch-module but that's quite cumbersome and I did + // not get it running in 10 minutes so I am using this, the effect should be the same, the kotlin compiler checks if + // I am using symbols from packages I do not require etc. + + requires ch.tutteli.atrium.infix.en_GB; + requires ch.tutteli.atrium.api.infix.en_GB.jdk8; + requires kotlin.stdlib; + requires spek.dsl.jvm; +} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/build.gradle b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/build.gradle new file mode 100644 index 000000000..d5bfa324b --- /dev/null +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/build.gradle @@ -0,0 +1,11 @@ +description = "Represents a JDK >= 9 smoke test for atrium-infix-en_GB with kotlin_1_3 extension" + +sourceCompatibility = JavaVersion.current() +targetCompatibility = JavaVersion.current() + +dependencies { + //I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead + testImplementation prefixedProject('infix-en_GB-jvm') + testImplementation prefixedProject('api-infix-en_GB-kotlin_1_3-jvm') + testRuntimeOnly prefixedProject('domain-robstoll-kotlin_1_3-jvm') +} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt new file mode 100644 index 000000000..485335d59 --- /dev/null +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/custom/SmokeSpec.kt @@ -0,0 +1,50 @@ +@file:Suppress("JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" /* TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed */) + +package custom + +import ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3.toBe +import ch.tutteli.atrium.api.infix.en_GB.toBe +import ch.tutteli.atrium.api.infix.en_GB.success +import ch.tutteli.atrium.api.verbs.expect +import ch.tutteli.atrium.assertions.Assertion +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.domain.builders.ExpectImpl +import ch.tutteli.atrium.reporting.RawString +import ch.tutteli.atrium.reporting.translating.StringBasedTranslatable +import ch.tutteli.atrium.translations.DescriptionBasic +import org.spekframework.spek2.Spek + +object SmokeSpec : Spek({ + test("see if `toBe` can be used") { + expect(1) toBe 1 + } + + test("see if `Result.isSuccess` can be used") { + expect(Result.success(1)) toBe success + } + + test("see if own assertion function without i18n can be used") { + expect(2) tobe even + } + + test("see if own assertion function with i18n can be used") { + expect(4) isMultipleOf 2 + } +}) + +@Suppress("ClassName") +object even + +infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = + createAndAddAssertion(DescriptionBasic.IS, RawString.create("an even number")) { it % 2 == 0 } + +infix fun Expect.isMultipleOf(base: Int): Expect = addAssertion(_isMultipleOf(this, base)) + +fun _isMultipleOf(expect: Expect, base: Int): Assertion = + ExpectImpl.builder.createDescriptive(expect, DescriptionIntAssertions.IS_MULTIPLE_OF, base) { + it % base == 0 + } + +enum class DescriptionIntAssertions(override val value: String) : StringBasedTranslatable { + IS_MULTIPLE_OF("is multiple of") +} diff --git a/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java new file mode 100644 index 000000000..d806926d9 --- /dev/null +++ b/bundles/infix-en_GB/extensions/atrium-infix-en_GB-smoke-test-kotlin_1_3/src/test/kotlin/module-info.java @@ -0,0 +1,10 @@ +module ch.tutteli.atrium.infix.en_GB.kotlin_1_3.smoke { + // test dependencies are usually defined in build.gradle via --patch-module but that's quite cumbersome and I did + // not get it running in 10 minutes so I am using this, the effect should be the same, the kotlin compiler checks if + // I am using symbols from packages I do not require etc. + + requires ch.tutteli.atrium.infix.en_GB; + requires ch.tutteli.atrium.api.infix.en_GB.kotlin_1_3; + requires kotlin.stdlib; + requires spek.dsl.jvm; +} diff --git a/settings.gradle b/settings.gradle index 3c2e71196..32c138d70 100644 --- a/settings.gradle +++ b/settings.gradle @@ -58,6 +58,7 @@ include { bundles { bundleWithExtensionsAndSmokeTest(delegate, 'fluent-en_GB') + bundleWithExtensionsAndSmokeTest(delegate, 'infix-en_GB') } apis('api-') { From 216c983068920d9bdd1a08ffc77d39c9faf39b52 Mon Sep 17 00:00:00 2001 From: miftahunajat Date: Wed, 8 Apr 2020 20:04:16 +0700 Subject: [PATCH 135/142] modify char sequence Contains Creation, spec, assertion in fluent api --- .../api/fluent/en_GB/charSequenceContainsCreators.kt | 9 +++++++++ .../en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt | 7 ++++++- .../api/fluent/en_GB/CharSequenceContainsSpecBase.kt | 3 +-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt index b65fb99b8..5b4e0364e 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/charSequenceContainsCreators.kt @@ -4,6 +4,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.* import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.IgnoringCaseSearchBehaviour import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour @@ -332,3 +333,11 @@ fun CheckerOption.elementsOf( val (first, rest) = toVarArg(expectedIterable) return values(first, *rest) } + +@JvmName("elementsOfIgnoringCase") +fun CharSequenceContains.Builder.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return values(first, *rest) +} diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index fa359652e..d72546ac1 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -101,7 +101,12 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ a: Any, aX: Array ): Expect = - expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a, *aX)) + if (aX.isEmpty()) { + expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a)) + } else { + expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a, *aX)) + } + private val atLeastButAtMostDescr = { what: String, timesAtLeast: String, timesAtMost: String -> "$contains $what $atLeast $timesAtLeast $butAtMost $timesAtMost" diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt index 88c6d2e45..a250dce86 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsSpecBase.kt @@ -78,7 +78,6 @@ abstract class CharSequenceContainsSpecBase { // and hence these would be a second way to do the same thing //a1.contains.ignoringCase.regex(Regex("a")) //a1.contains.ignoringCase.regex(Regex("a"), Regex("bl")) - //TODO #422 uncomment - //a1.contains.ignoringCase.elementsOf(listOf("a", 2)) + a1.contains.ignoringCase.elementsOf(listOf("a", 2)) } } From eee15c9f237d2a6b432f617c994f72d6af195f7c Mon Sep 17 00:00:00 2001 From: miftahunajat Date: Thu, 9 Apr 2020 15:35:04 +0700 Subject: [PATCH 136/142] resolve #422 add test-case to CharSequenceContainsAtLeastAssertionsSpec --- .../CharSequenceContainsAtLeastAssertionsSpec.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index d72546ac1..c5bd22cdc 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -36,10 +36,10 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ }.toThrow { messageContains("Iterable without elements are not allowed") } } } - describe("ignoringCase.atLeast(1).elementsOf") { + describe("ignoringCase.elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { - expect("test").contains.ignoringCase.atLeast(1).elementsOf(emptyList()) + expect("test").contains.ignoringCase.elementsOf(emptyList()) }.toThrow { messageContains("Iterable without elements are not allowed") } } } @@ -102,12 +102,13 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ aX: Array ): Expect = if (aX.isEmpty()) { - expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a)) + if (atLeast == 1) expect.contains.ignoringCase.elementsOf(listOf(a)) + else expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a)) } else { - expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a, *aX)) + if (atLeast == 1) expect.contains.ignoringCase.elementsOf(listOf(a, *aX)) + else expect.contains.ignoringCase.atLeast(atLeast).elementsOf(listOf(a, *aX)) } - private val atLeastButAtMostDescr = { what: String, timesAtLeast: String, timesAtMost: String -> "$contains $what $atLeast $timesAtLeast $butAtMost $timesAtMost" } From 4fa46812b2da1793d5392c74be7cfeed50bfbf47 Mon Sep 17 00:00:00 2001 From: miftahunajat Date: Thu, 9 Apr 2020 16:33:12 +0700 Subject: [PATCH 137/142] fix #422 revert the copy ignoringCase.atLeast(1).elementsOf spec --- .../en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index c5bd22cdc..d2b46b4fb 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -36,6 +36,13 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ }.toThrow { messageContains("Iterable without elements are not allowed") } } } + describe("ignoringCase.atLeast(1).elementsOf") { + it("passing an empty iterable throws an IllegalArgumentException") { + expect { + expect("test").contains.ignoringCase.atLeast(1).elementsOf(emptyList()) + }.toThrow { messageContains("Iterable without elements are not allowed") } + } + } describe("ignoringCase.elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { From 17070e78d7d9eeefd29576e5af7f0fb76215a8d8 Mon Sep 17 00:00:00 2001 From: miftahunajat Date: Thu, 9 Apr 2020 17:15:39 +0700 Subject: [PATCH 138/142] fix #422 infix api --- .../infix/en_GB/charSequenceContainsCreators.kt | 9 +++++++++ .../CharSequenceContainsAtLeastAssertionsSpec.kt | 14 +++++++++++++- .../infix/en_GB/CharSequenceContainsSpecBase.kt | 3 +-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt index d1179e78c..ac3f8565f 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/charSequenceContainsCreators.kt @@ -7,6 +7,7 @@ import ch.tutteli.atrium.creating.Expect import ch.tutteli.atrium.domain.builders.ExpectImpl import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion import ch.tutteli.atrium.domain.builders.utils.toVarArg +import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.Builder import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains.CheckerOption import ch.tutteli.atrium.domain.creating.charsequence.contains.searchbehaviours.IgnoringCaseSearchBehaviour @@ -380,3 +381,11 @@ infix fun CheckerOption.eleme val (first, rest) = toVarArg(expectedIterable) return this the Values(first, rest) } + +@JvmName("elementsOfIgnoringCase") +infix fun CharSequenceContains.Builder.elementsOf( + expectedIterable: Iterable +): Expect { + val (first, rest) = toVarArg(expectedIterable) + return this the Values(first, rest) +} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt index ee218dd29..0c0948b22 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsAtLeastAssertionsSpec.kt @@ -36,6 +36,13 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ }.toThrow { it messageContains "Iterable without elements are not allowed" } } } + describe("ignoring case elementsOf") { + it("passing an empty iterable throws an IllegalArgumentException") { + expect { + expect("test") contains o ignoring case elementsOf emptyList() + }.toThrow { it messageContains "Iterable without elements are not allowed" } + } + } describe("ignoring case atLeast 1 elementsOf") { it("passing an empty iterable throws an IllegalArgumentException") { expect { @@ -101,7 +108,12 @@ class CharSequenceContainsAtLeastAssertionsSpec : Spek({ a: Any, aX: Array ): Expect = - expect contains o ignoring case atLeast atLeast elementsOf listOf(a, *aX) + if (aX.isEmpty()) { + if (atLeast == 1) expect contains o ignoring case elementsOf listOf(a) + else expect contains o ignoring case atLeast atLeast elementsOf listOf(a) + } else { + if (atLeast == 1) expect contains o ignoring case elementsOf listOf(a, *aX) + else expect contains o ignoring case atLeast atLeast elementsOf listOf(a, *aX) } private val atLeastButAtMostDescr = { what: String, timesAtLeast: String, timesAtMost: String -> "$contains o $what $atLeast $timesAtLeast $butAtMost $timesAtMost" diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt index c6383d442..40ac3128a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/CharSequenceContainsSpecBase.kt @@ -87,8 +87,7 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() { // and hence these would be a second way to do the same thing //a1 contains o ignoring case matchFor Regex("a") //a1 contains o ignoring case matchFor all(Regex("a"), Regex("bl")) - //TODO #422 uncomment - //a1 contains o ignoring case elementsOf listOf("a", 2) + a1 contains o ignoring case elementsOf listOf("a", 2) a1 and { it contains o atLeast 1 value 1 } a1 and { it contains o atMost 2 the values("a", 1) } From cc4b316844b38a81dd3d3f975a0d4e2035322ceb Mon Sep 17 00:00:00 2001 From: Assaf L Date: Fri, 10 Apr 2020 12:15:29 +0300 Subject: [PATCH 139/142] #416 move jvm common (#433) * moved domain charsequence classes * moved jvm to common in domain folder --- .../tutteli}/assertions/LazyThreadUnsafeAssertionGroupSpec.kt | 0 .../tutteli}/assertions/LazyThreadUnsafeBasicAssertionSpec.kt | 0 .../contains/searchers/CharSequenceContainsIndexSearcherSpec.kt | 0 .../contains/searchers/CharSequenceContainsRegexSearcherSpec.kt | 0 domain/robstoll-lib/atrium-domain-robstoll-lib-js/build.gradle | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) rename domain/robstoll-lib/{atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium => atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli}/assertions/LazyThreadUnsafeAssertionGroupSpec.kt (100%) rename domain/robstoll-lib/{atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium => atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli}/assertions/LazyThreadUnsafeBasicAssertionSpec.kt (100%) rename domain/robstoll-lib/{atrium-domain-robstoll-lib-jvm => atrium-domain-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt (100%) rename domain/robstoll-lib/{atrium-domain-robstoll-lib-jvm => atrium-domain-robstoll-lib-common}/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt (100%) diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeAssertionGroupSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/assertions/LazyThreadUnsafeAssertionGroupSpec.kt similarity index 100% rename from domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeAssertionGroupSpec.kt rename to domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/assertions/LazyThreadUnsafeAssertionGroupSpec.kt diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeBasicAssertionSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/assertions/LazyThreadUnsafeBasicAssertionSpec.kt similarity index 100% rename from domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/assertions/LazyThreadUnsafeBasicAssertionSpec.kt rename to domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/assertions/LazyThreadUnsafeBasicAssertionSpec.kt diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt similarity index 100% rename from domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt rename to domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsIndexSearcherSpec.kt diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt b/domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt similarity index 100% rename from domain/robstoll-lib/atrium-domain-robstoll-lib-jvm/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt rename to domain/robstoll-lib/atrium-domain-robstoll-lib-common/src/test/kotlin/ch/tutteli/atrium/creating/charsequence/contains/searchers/CharSequenceContainsRegexSearcherSpec.kt diff --git a/domain/robstoll-lib/atrium-domain-robstoll-lib-js/build.gradle b/domain/robstoll-lib/atrium-domain-robstoll-lib-js/build.gradle index cd7fa2123..336efd556 100644 --- a/domain/robstoll-lib/atrium-domain-robstoll-lib-js/build.gradle +++ b/domain/robstoll-lib/atrium-domain-robstoll-lib-js/build.gradle @@ -14,5 +14,5 @@ dependencies { // TODO remove with 1.0.0 implementation prefixedProject('api-cc-en_GB-js') - testImplementation prefixedProject('verbs-internal-js') + testImplementation prefixedProject('specs-js') } From 47facb86ebfa0340ae7d0a304f05a10738dad1d7 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 10 Apr 2020 22:43:12 +0200 Subject: [PATCH 140/142] add new infix api to cc-infix bundles and to core so that one can easily migrate to the new infix API. Moreover, suppress deprecations in core tests for now as we are going to deprecate the cc-infix. We will remove this suppression once we migrate to the new infix API --- .../atrium-api-cc-infix-en_GB-android/build.gradle | 1 + apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/build.gradle | 1 + bundles/atrium-cc-infix-en_UK-robstoll/build.gradle | 3 ++- .../atrium-cc-infix-en_GB-robstoll-android/build.gradle | 3 +++ .../atrium-cc-infix-en_GB-robstoll-common/build.gradle | 3 +++ .../atrium-cc-infix-en_GB-robstoll-js/build.gradle | 3 +++ .../atrium-cc-infix-en_GB-robstoll-jvm/build.gradle | 3 +++ core/api/atrium-core-api-android/build.gradle | 1 + core/api/atrium-core-api-common/build.gradle | 1 + .../ch/tutteli/atrium/core/polyfills/AtriumPropertyTest.kt | 1 + .../ch/tutteli/atrium/core/polyfills/LoadServicesTest.kt | 1 + .../ch/tutteli/atrium/core/polyfills/LoadSingleServiceTest.kt | 1 + .../ch/tutteli/atrium/core/polyfills/UseSingleServiceTest.kt | 1 + .../test/kotlin/ch/tutteli/atrium/reporting/AtriumErrorSpec.kt | 1 + core/api/atrium-core-api-js/build.gradle | 1 + core/api/atrium-core-api-jvm/build.gradle | 1 + 16 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-android/build.gradle b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-android/build.gradle index 7997dbfbe..fc012fbfc 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-android/build.gradle +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-android/build.gradle @@ -5,6 +5,7 @@ dependencies { api prefixedProject('domain-builders-android') testImplementation prefixedProject('verbs-internal-android') + testImplementation prefixedProject('api-infix-en_GB-android') } srcAndResourcesFromJvmProject(project) diff --git a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/build.gradle b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/build.gradle index 6912f5606..ddeca8877 100644 --- a/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/build.gradle +++ b/apis/cc-infix-en_GB/atrium-api-cc-infix-en_GB-jvm/build.gradle @@ -13,6 +13,7 @@ dependencies { api prefixedProject('domain-builders-jvm') testImplementation prefixedProject('verbs-internal-jvm') + testImplementation prefixedProject('api-infix-en_GB-jvm') } //TODO should not be necessary https://youtrack.jetbrains.com/issue/KT-28124 diff --git a/bundles/atrium-cc-infix-en_UK-robstoll/build.gradle b/bundles/atrium-cc-infix-en_UK-robstoll/build.gradle index be7298910..19cda7c04 100644 --- a/bundles/atrium-cc-infix-en_UK-robstoll/build.gradle +++ b/bundles/atrium-cc-infix-en_UK-robstoll/build.gradle @@ -3,7 +3,7 @@ description = 'Represents a deprecated convenience module which merely bundles d dependencies { api prefixedProject('verbs-jvm') - api prefixedProject('api-cc-infix-en_GB-jvm') + api prefixedProject('api-infix-en_GB-jvm') api prefixedProject('translations-en_GB-jvm') api prefixedProject('domain-builders-jvm') api prefixedProject('domain-api-jvm') @@ -13,6 +13,7 @@ dependencies { runtimeOnly prefixedProject('core-robstoll-jvm') //TODO remove with 1.0.0 + api prefixedProject('api-cc-infix-en_GB-jvm') api prefixedProject('api-cc-infix-en_UK') implementation prefixedProject('assertions') api prefixedProject('core-api-deprecated') diff --git a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-android/build.gradle b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-android/build.gradle index 57d590243..18ea93ca8 100644 --- a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-android/build.gradle +++ b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-android/build.gradle @@ -10,4 +10,7 @@ dependencies { runtimeOnly prefixedProject('domain-robstoll-android') runtimeOnly prefixedProject('core-robstoll-android') + + // here to ease migration; so that ReplaceWith of @Deprecated works + api prefixedProject('api-infix-en_GB-android') } diff --git a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle index dc45fb11c..aede0df06 100644 --- a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle +++ b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-common/build.gradle @@ -10,4 +10,7 @@ dependencies { runtimeOnly prefixedProject('domain-robstoll-common') runtimeOnly prefixedProject('core-robstoll-common') + + // here to ease migration; so that ReplaceWith of @Deprecated works + api prefixedProject('api-infix-en_GB-common') } diff --git a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-js/build.gradle b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-js/build.gradle index fa6e375bc..6097aa6f1 100644 --- a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-js/build.gradle +++ b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-js/build.gradle @@ -11,4 +11,7 @@ dependencies { //TODO should be runtimeOnly but due to https://youtrack.jetbrains.com/issue/KT-27797 it cannot be implementation prefixedProject('domain-robstoll-js') implementation prefixedProject('core-robstoll-js') + + // here to ease migration; so that ReplaceWith of @Deprecated works + api prefixedProject('api-infix-en_GB-js') } diff --git a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-jvm/build.gradle b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-jvm/build.gradle index fa1e532cc..cd59fee21 100644 --- a/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-jvm/build.gradle +++ b/bundles/cc-infix-en_GB-robstoll/atrium-cc-infix-en_GB-robstoll-jvm/build.gradle @@ -10,4 +10,7 @@ dependencies { runtimeOnly prefixedProject('domain-robstoll-jvm') runtimeOnly prefixedProject('core-robstoll-jvm') + + // here to ease migration; so that ReplaceWith of @Deprecated works + api prefixedProject('api-infix-en_GB-jvm') } diff --git a/core/api/atrium-core-api-android/build.gradle b/core/api/atrium-core-api-android/build.gradle index bce8f42d7..70e056563 100644 --- a/core/api/atrium-core-api-android/build.gradle +++ b/core/api/atrium-core-api-android/build.gradle @@ -4,6 +4,7 @@ dependencies { api kbox(), excludeKotlin api kotlinReflect() + testImplementation prefixedProject('api-infix-en_GB-android') testImplementation prefixedProject('api-cc-infix-en_GB-android') testImplementation prefixedProject('specs-android') } diff --git a/core/api/atrium-core-api-common/build.gradle b/core/api/atrium-core-api-common/build.gradle index a8e082ba5..8d2b3fd6c 100644 --- a/core/api/atrium-core-api-common/build.gradle +++ b/core/api/atrium-core-api-common/build.gradle @@ -3,6 +3,7 @@ description = 'API of the core of Atrium as common module' dependencies { api "ch.tutteli.kbox:kbox-common:$kbox_version", excludeKotlin + testImplementation prefixedProject('api-infix-en_GB-common') testImplementation prefixedProject('api-cc-infix-en_GB-common') testImplementation prefixedProject('specs-common') } diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/AtriumPropertyTest.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/AtriumPropertyTest.kt index 75aff49f7..d8d731792 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/AtriumPropertyTest.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/AtriumPropertyTest.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION" /* remove once we have migrated to new infix API */) package ch.tutteli.atrium.core.polyfills import ch.tutteli.atrium.api.cc.infix.en_GB.toBe diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadServicesTest.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadServicesTest.kt index dad8979c3..c381c7ed1 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadServicesTest.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadServicesTest.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION" /* remove once we have migrated to new infix API */) package ch.tutteli.atrium.core.polyfills import ch.tutteli.atrium.api.cc.infix.en_GB.* diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadSingleServiceTest.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadSingleServiceTest.kt index 3ba188cd1..09e1731ea 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadSingleServiceTest.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/LoadSingleServiceTest.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION" /* remove once we have migrated to new infix API */) package ch.tutteli.atrium.core.polyfills import ch.tutteli.atrium.api.cc.infix.en_GB.Values diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/UseSingleServiceTest.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/UseSingleServiceTest.kt index 5bb26341e..cecec33a0 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/UseSingleServiceTest.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/core/polyfills/UseSingleServiceTest.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION" /* remove once we have migrated to new infix API */) package ch.tutteli.atrium.core.polyfills import ch.tutteli.atrium.api.cc.infix.en_GB.Values diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/AtriumErrorSpec.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/AtriumErrorSpec.kt index bd07eac88..2380c1313 100644 --- a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/AtriumErrorSpec.kt +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/AtriumErrorSpec.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION" /* remove once we have migrated to new infix API */) package ch.tutteli.atrium.reporting import ch.tutteli.atrium.api.cc.infix.en_GB.property diff --git a/core/api/atrium-core-api-js/build.gradle b/core/api/atrium-core-api-js/build.gradle index adf762f36..b045cbcbe 100644 --- a/core/api/atrium-core-api-js/build.gradle +++ b/core/api/atrium-core-api-js/build.gradle @@ -3,6 +3,7 @@ description = 'API of the core of Atrium for the JS platform.' dependencies { api "ch.tutteli.kbox:kbox-js:$kbox_version", excludeKotlin + testImplementation prefixedProject('api-infix-en_GB-js') testImplementation prefixedProject('api-cc-infix-en_GB-js') testImplementation prefixedProject('specs-js') } diff --git a/core/api/atrium-core-api-jvm/build.gradle b/core/api/atrium-core-api-jvm/build.gradle index f50672e8e..fb9e6a487 100644 --- a/core/api/atrium-core-api-jvm/build.gradle +++ b/core/api/atrium-core-api-jvm/build.gradle @@ -4,6 +4,7 @@ dependencies { api kbox(), excludeKotlin api kotlinReflect() + testImplementation prefixedProject('api-infix-en_GB-jvm') testImplementation prefixedProject('api-cc-infix-en_GB-jvm') testImplementation prefixedProject('specs-jvm') } From af0c48833a17502325b2a8a518d8f85cba7f7d2c Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 10 Apr 2020 22:53:10 +0200 Subject: [PATCH 141/142] fix ReplaceWith for cc-en_GB Array asIterable, fluent has asList --- .../atrium/api/cc/en_GB/arrayAssertions.kt | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt b/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt index 1e80672c4..3520f501b 100644 --- a/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt +++ b/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/arrayAssertions.kt @@ -17,10 +17,10 @@ import kotlin.jvm.JvmName @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) fun Assert>.asIterable(): Assert> = @@ -38,10 +38,10 @@ fun Assert>.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) fun Assert>.asIterable(assertionCreator: Assert>.() -> Unit): Assert> = @@ -59,10 +59,10 @@ fun Assert>.asIterable(assertionCreator: Assert>.() @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("byteArrAsIterable") @@ -81,10 +81,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("byteArrAsIterable") @@ -103,10 +103,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() -> @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("charArrAsIterable") @@ -125,10 +125,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("charArrAsIterable") @@ -147,10 +147,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() -> @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("shortArrAsIterable") @@ -169,10 +169,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("shortArrAsIterable") @@ -191,10 +191,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() - @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("intArrAsIterable") @@ -212,10 +212,10 @@ fun Assert.asIterable(): Assert> = ExpectImpl.changeSubj @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("intArrAsIterable") @@ -234,10 +234,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() -> Un @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("longArrAsIterable") @@ -256,10 +256,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("longArrAsIterable") @@ -278,10 +278,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() -> @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("floatArrAsIterable") @@ -300,10 +300,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("floatArrAsIterable") @@ -322,10 +322,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() - @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("doubleArrAsIterable") @@ -344,10 +344,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("doubleArrAsIterable") @@ -366,10 +366,10 @@ fun Assert.asIterable(assertionCreator: Assert>.() @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert()", + "this.asExpect().asList().asAssert()", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("boolArrAsIterable") @@ -388,10 +388,10 @@ fun Assert.asIterable(): Assert> = @Deprecated( "Switch from Assert to Expect; will be removed with 1.0.0", ReplaceWith( - "this.asExpect().asIterable().asAssert(assertionCreator)", + "this.asExpect().asList().asAssert(assertionCreator)", "ch.tutteli.atrium.domain.builders.migration.asExpect", "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.asIterable" + "ch.tutteli.atrium.api.fluent.en_GB.asList" ) ) @JvmName("boolArrAsIterable") From a85c44d2db5c2679d929a0455bf990f13423fed4 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 10 Apr 2020 22:54:09 +0200 Subject: [PATCH 142/142] remove deprecation for in cc-en_GB --- .../ch/tutteli/atrium/api/cc/en_GB/anyAssertions.kt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/anyAssertions.kt b/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/anyAssertions.kt index b022fdf6c..32ac01e50 100644 --- a/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/anyAssertions.kt +++ b/apis/cc-en_GB/atrium-api-cc-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/cc/en_GB/anyAssertions.kt @@ -164,14 +164,5 @@ val AssertionPlant.and: AssertionPlant get() = this * * @return This plant to support a fluent API. */ -@Deprecated( - "Switch from Assert to Expect; will be removed with 1.0.0", - ReplaceWith( - "this.asExpect().and(assertionCreator).asAssert()", - "ch.tutteli.atrium.domain.builders.migration.asExpect", - "ch.tutteli.atrium.domain.builders.migration.asAssert", - "ch.tutteli.atrium.api.fluent.en_GB.and" - ) -) infix fun AssertionPlant.and(assertionCreator: Assert.() -> Unit) = addAssertionsCreatedBy(assertionCreator)