Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report has not: duplicate elements for containsNoDuplicateElements #779

Merged
merged 1 commit into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.tutteli.atrium.api.infix.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.containsNoDuplicates
import ch.tutteli.atrium.logic.hasNext
import ch.tutteli.atrium.logic.hasNotNext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class DefaultIterableLikeAssertions : IterableLikeAssertions {
}
createHasElementPlusFixedClaimGroup(
list,
DescriptionBasic.HAS, DescriptionIterableAssertion.DUPLICATE_ELEMENTS,
DescriptionBasic.HAS_NOT, DescriptionIterableAssertion.DUPLICATE_ELEMENTS,
duplicates.isEmpty(),
duplicates
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ abstract class IterableAssertionsSpec(
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()
val hasDescr = DescriptionBasic.HAS.getDefault()
val hasNotDescr = DescriptionBasic.HAS_NOT.getDefault()
val nextElementDescr = DescriptionIterableAssertion.NEXT_ELEMENT.getDefault()
val duplicateElements = DescriptionIterableAssertion.DUPLICATE_ELEMENTS.getDefault()

describeFun(hasNext) {
Expand All @@ -54,7 +54,7 @@ abstract class IterableAssertionsSpec(
it("throws an AssertionError if an iterable does not have next") {
expect {
expect(listOf<Int>() as Iterable<Int>).hasNextFun()
}.toThrow<AssertionError> { messageContains("$hasDescriptionBasic: $nextElement") }
}.toThrow<AssertionError> { messageContains("$hasDescr: $nextElementDescr") }
}
}

Expand All @@ -68,7 +68,7 @@ abstract class IterableAssertionsSpec(
it("throws an AssertionError if an iterable has next element") {
expect {
expect(listOf(1, 2) as Iterable<Int>).hasNotNextFun()
}.toThrow<AssertionError> { messageContains("$hasNotDescriptionBasic: $nextElement") }
}.toThrow<AssertionError> { messageContains("$hasNotDescr: $nextElementDescr") }
}
}

Expand Down Expand Up @@ -144,7 +144,7 @@ abstract class IterableAssertionsSpec(
expect(input).containsNoDuplicatesFun()
}.toThrow<AssertionError> {
message {
contains("$hasDescriptionBasic: $duplicateElements")
contains("$hasNotDescr: $duplicateElements")
contains(index(0, 1), index(1, 2), index(2, 1), index(3, 2), index(5, 4), index(6, 4), index(7, 4))
}
}
Expand Down
8 changes: 8 additions & 0 deletions misc/tools/bc-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@ listOf("0.14.0", "0.15.0").forEach { version ->
)
}

// fix specs, was a wrong implementation and the specs tested the wrong thing
rewriteFile("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAssertionsSpec.kt") {
it.replaceFirst(
"contains(\"\$hasDescriptionBasic: \$duplicateElements\")",
"contains(\"\$hasNotDescriptionBasic: \$duplicateElements\")"
)
}

// deleted AssertionPlant and co. in 0.16.0, hence specs don't make sense any more (it's a bc on core level not API)
file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/checking/").deleteRecursively()
file("src/commonMain/kotlin/main/kotlin/ch/tutteli/atrium/specs/creating/").deleteRecursively()
Expand Down