Skip to content

Commit

Permalink
refactor: Remove Java's BigInt/BigDecimal constraints (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore authored Jun 24, 2023
1 parent 7de3848 commit 7532257
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
24 changes: 0 additions & 24 deletions main/src/io/github/iltotore/iron/constraint/numeric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,6 @@ object numeric:
inline given [V <: Int | Long]: GreaterConstraint[BigInt, V] with
override inline def test(value: BigInt): Boolean = value > BigInt(longValue[V])

inline given jBigDecimalDouble[V <: Float | Double]: GreaterConstraint[java.math.BigDecimal, V] with
override inline def test(value: java.math.BigDecimal): Boolean =
value.compareTo(java.math.BigDecimal.valueOf(doubleValue[V])) > 0

inline given jBigDecimalLong[V <: Int | Long]: GreaterConstraint[java.math.BigDecimal, V] with
override inline def test(value: java.math.BigDecimal): Boolean =
value.compareTo(java.math.BigDecimal.valueOf(longValue[V])) > 0

inline given jBigInteger[V <: Int | Long]: GreaterConstraint[java.math.BigInteger, V] with
override inline def test(value: java.math.BigInteger): Boolean =
value.compareTo(java.math.BigInteger.valueOf(longValue[V])) > 0

given [V1, V2](using V1 > V2 =:= true): (Greater[V1] ==> Greater[V2]) = Implication()

given [V1, V2](using V1 > V2 =:= true): (StrictEqual[V1] ==> Greater[V2]) = Implication()
Expand Down Expand Up @@ -191,18 +179,6 @@ object numeric:
inline given [V <: Int | Long]: LessConstraint[BigInt, V] with
override inline def test(value: BigInt): Boolean = value < BigInt(longValue[V])

inline given jBigDecimalDouble[V <: Float | Double]: LessConstraint[java.math.BigDecimal, V] with
override inline def test(value: java.math.BigDecimal): Boolean =
value.compareTo(java.math.BigDecimal.valueOf(doubleValue[V])) < 0

inline given jBigDecimalLong[V <: Int | Long]: LessConstraint[java.math.BigDecimal, V] with
override inline def test(value: java.math.BigDecimal): Boolean =
value.compareTo(java.math.BigDecimal.valueOf(longValue[V])) < 0

inline given jBigInteger[V <: Int | Long]: LessConstraint[java.math.BigInteger, V] with
override inline def test(value: java.math.BigInteger): Boolean =
value.compareTo(java.math.BigInteger.valueOf(longValue[V])) < 0

given [V1, V2](using V1 < V2 =:= true): (Less[V1] ==> Less[V2]) = Implication()

given [V1, V2](using V1 < V2 =:= true): (StrictEqual[V1] ==> Less[V2]) = Implication()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ object NumericSuite extends TestSuite:
test - BigDecimal(1).assertRefine[Greater[0]]
test - BigInt(0).assertNotRefine[Greater[0]]
test - BigInt(1).assertRefine[Greater[0]]
test - java.math.BigDecimal("0").assertNotRefine[Greater[0]]
test - java.math.BigDecimal("1").assertRefine[Greater[0]]
test - java.math.BigInteger("0").assertNotRefine[Greater[0]]
test - java.math.BigInteger("1").assertRefine[Greater[0]]
}

test("greaterEqual") {
Expand All @@ -34,10 +30,6 @@ object NumericSuite extends TestSuite:
test - BigDecimal(-1).assertRefine[Less[0]]
test - BigInt(0).assertNotRefine[Less[0]]
test - BigInt(-1).assertRefine[Less[0]]
test - java.math.BigDecimal("0").assertNotRefine[Less[0]]
test - java.math.BigDecimal("-1").assertRefine[Less[0]]
test - java.math.BigInteger("0").assertNotRefine[Less[0]]
test - java.math.BigInteger("-1").assertRefine[Less[0]]
}

test("lessEqual") {
Expand Down

0 comments on commit 7532257

Please sign in to comment.