From 9d785291985e1db7b04e6ca3150dfb2972517cbc Mon Sep 17 00:00:00 2001 From: Steven Schoen Date: Mon, 5 Aug 2024 14:22:32 -0600 Subject: [PATCH] Use section end logic when checking assertNoFurtherElements --- strikt-core/src/main/kotlin/strikt/assertions/Iterable.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/strikt-core/src/main/kotlin/strikt/assertions/Iterable.kt b/strikt-core/src/main/kotlin/strikt/assertions/Iterable.kt index 1c9e1dc1..a5331ab4 100644 --- a/strikt-core/src/main/kotlin/strikt/assertions/Iterable.kt +++ b/strikt-core/src/main/kotlin/strikt/assertions/Iterable.kt @@ -692,8 +692,8 @@ fun , E> Builder.containsWithOrderingConstraints( } val assertNoFurtherElements = builder.expectsNoFurtherElements || - // Check if the last section has a `last` constraint - allSections.last().elementsWithConstraints.any { it.constraints.any { it == OrderingConstraint.Last } } + // Check if the last section explicitly defines the end element + allSections.last().endDefinedBy is SectionAssertionSpec.EndDefinition.DeclaredElement<*> if (assertNoFurtherElements) { assert("contains no further elements", expected = emptyList()) { if (elementsConsumed == it.count()) {