Skip to content

Commit

Permalink
selective scalafix silencing and compiler warning silencing where app…
Browse files Browse the repository at this point in the history
…ropriate
  • Loading branch information
vreuter committed Jul 10, 2024
1 parent 937660f commit db8515c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/numeric/src/test/scala/TestNonnegativeInt.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.ac.oeaw.imba.gerlich.gerlib.numeric

import scala.annotation.nowarn
import scala.util.Try
import cats.syntax.all.*
import org.scalacheck.{Arbitrary, Gen}
Expand Down Expand Up @@ -88,17 +89,19 @@ class TestNonnegativeInt
}

test("NonnegativeInt is a transparent type alias for Int :| Not[Negative]") {

import io.github.iltotore.iron.{ :|, autoRefine } // scalafix:ok
assertCompiles {
"val ironRef: Int :| Not[Negative] = 0; val aliased: NonnegativeInt = ironRef"
}
assertCompiles {
"val aliased: NonnegativeInt = NonnegativeInt(0); val ironRef: Int :| Not[Negative] = aliased"
}
}
}: @nowarn

test("NonnegativeInt's predicate is Not[Negative], not GreaterEqual[0]") {

import io.github.iltotore.iron.{ :|, autoRefine } // scalafix:ok
import io.github.iltotore.iron.constraint.any.StrictEqual // scalafix:ok
import io.github.iltotore.iron.constraint.numeric.{ Greater, GreaterEqual} // scalafix:ok
/* With GreaterEqual[0] */
assertCompiles { "val ironRef: Int :| GreaterEqual[0] = 0" }
assertTypeError {
Expand All @@ -110,5 +113,5 @@ class TestNonnegativeInt
assertTypeError {
"val ironRef: Int :| (Greater[0] | StrictEqual[0]) = 0; val aliased: NonnegativeInt = ironRef"
}
}
}: @nowarn
end TestNonnegativeInt

0 comments on commit db8515c

Please sign in to comment.