From fdb7c66cd64246fb60a2daef9899f3c9da963ba2 Mon Sep 17 00:00:00 2001 From: Vince Reuter Date: Mon, 14 Oct 2024 15:08:35 +0200 Subject: [PATCH] fix the test case generation via Arbitrary[PositionName] --- .../src/test/scala/TestImagingInstances.scala | 12 +++++++----- .../src/main/scala/instances/ImagingInstances.scala | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/imaging/src/test/scala/TestImagingInstances.scala b/modules/imaging/src/test/scala/TestImagingInstances.scala index 74e3d78..50912fc 100644 --- a/modules/imaging/src/test/scala/TestImagingInstances.scala +++ b/modules/imaging/src/test/scala/TestImagingInstances.scala @@ -26,9 +26,11 @@ class TestImagingInstances PropertyCheckConfiguration(minSuccessful = 10000) given Arbitrary[PositionName] = - import io.github.iltotore.iron.autoRefine type GoodChar = Char :| PositionNameCharacterConstraint - val goodPunctuation: Set[GoodChar] = Set('-', '.', '_') + val goodPunctuation: Set[GoodChar] = { + import io.github.iltotore.iron.autoRefine + Set('-', '.', '_') + } def genPunct: Gen[GoodChar] = Gen.oneOf(goodPunctuation) def genPosNameChar: Gen[GoodChar] = Gen.oneOf( Arbitrary.arbitrary[Char :| Letter].map(_.asInstanceOf[GoodChar]), @@ -44,13 +46,13 @@ class TestImagingInstances case Nil => !( // Check that the string doesn't encode an integer or decimal. - !raw"-?[0-9]+".r.matches(s) || - !raw"-?[0-9]+\\.?[0-9]*".r.matches(s) + raw"-?[0-9]+".r.matches(s) || + raw"-?[0-9]+\.[0-9]+".r.matches(s) ) case 'E' :: Nil => !( // Check that the string isn't a scientific notation. - raw"-?[0-9]\\.[0-9]+E-?[0-9]{1,3}".r.matches(s) || + raw"-?[0-9]\.[0-9]+E-?[0-9]{1,3}".r.matches(s) || raw"-?[0-9]E-?[0-9]{1,3}".r.matches(s) ) case _ => true diff --git a/modules/testing/src/main/scala/instances/ImagingInstances.scala b/modules/testing/src/main/scala/instances/ImagingInstances.scala index 251f8de..4157c29 100644 --- a/modules/testing/src/main/scala/instances/ImagingInstances.scala +++ b/modules/testing/src/main/scala/instances/ImagingInstances.scala @@ -25,9 +25,11 @@ trait ImagingInstances extends CatsScalacheckInstances: Arbitrary[Char :| Letter], Arbitrary[Char :| Digit] ): Arbitrary[PositionName] = - import io.github.iltotore.iron.autoRefine type GoodChar = Char :| PositionNameCharacterConstraint - val goodPunctuation: Set[GoodChar] = Set('-', '.', '_') + val goodPunctuation: Set[GoodChar] = { + import io.github.iltotore.iron.autoRefine + Set('-', '.', '_') + } def genPunct: Gen[GoodChar] = Gen.oneOf(goodPunctuation) def genPosNameChar: Gen[GoodChar] = Gen.oneOf( Arbitrary.arbitrary[Char :| Letter].map(_.asInstanceOf[GoodChar]), @@ -43,13 +45,13 @@ trait ImagingInstances extends CatsScalacheckInstances: case Nil => !( // Check that the string doesn't encode an integer or decimal. - !raw"-?[0-9]+".r.matches(s) || - !raw"-?[0-9]+\\.?[0-9]*".r.matches(s) + raw"-?[0-9]+".r.matches(s) || + raw"-?[0-9]+\.[0-9]+".r.matches(s) ) case 'E' :: Nil => !( // Check that the string isn't a scientific notation. - raw"-?[0-9]\\.[0-9]+E-?[0-9]{1,3}".r.matches(s) || + raw"-?[0-9]\.[0-9]+E-?[0-9]{1,3}".r.matches(s) || raw"-?[0-9]E-?[0-9]{1,3}".r.matches(s) ) case _ => true