From 0a59b37a8df25eca2d7aabdd053aed1abcd8e66b Mon Sep 17 00:00:00 2001 From: Vince Reuter Date: Sat, 26 Oct 2024 02:05:03 +0200 Subject: [PATCH] condition the test on the necessary precondition --- modules/pan/src/test/scala/TestAtLeast2.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/pan/src/test/scala/TestAtLeast2.scala b/modules/pan/src/test/scala/TestAtLeast2.scala index cb34c61..46f7adb 100644 --- a/modules/pan/src/test/scala/TestAtLeast2.scala +++ b/modules/pan/src/test/scala/TestAtLeast2.scala @@ -56,9 +56,11 @@ class TestAtLeast2 extends AnyFunSuite, ScalaCheckPropertyChecks, should.Matcher test("For sets, AtLeast2 is correct with apply-syntax."): import at.ac.oeaw.imba.gerlich.gerlib.collections.AtLeast2.syntax.* forAll: (xs: NonEmptySet[Int], x: Int) => - val atLeast2 = AtLeast2(xs, x) - atLeast2 `contains` x shouldBe true - atLeast2.size shouldEqual (xs.length + (if xs `contains` x then 0 else 1)) + // The test's principle is invalid if the "extra" element is already in the collection. + whenever(!xs.contains(x)): + val atLeast2 = AtLeast2(xs, x) + atLeast2 `contains` x shouldBe true + atLeast2.size shouldEqual (xs.length + (if xs `contains` x then 0 else 1)) test( ".map on a AtLeast2[C, *] value returns a refined value IF AND ONLY IF a functor is available for the underlying container type and the AtLeast2 syntax is imported"