You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using assertCustom with a Either, zio-prelude fails at runtime,
e.g. the below class compiles fine, but the tests for SimplexOptimalityTolerance fail at runtime with a NoSuchMethodError.
Currently, this means I have to migrate all assertions to be the ones like in the SolutionType.
zio-version: 2.0.18
zio-prelude: 1.0.0-RC21
Exception:
Exception in thread "zio-fiber-464" java.lang.NoSuchMethodError: com.acme.domain.SolverConfig$CPLEX$SimplexOptimalityTolerance$.$anonfun$assertion$1$adapted(Ljava/lang/Object;)Lscala/util/Either;
at com.acme.domain.SolverConfig$CPLEX$SimplexOptimalityTolerance$$anon$4.run(SolverConfig.scala:65)
at com.acme.domain.SolverConfig$CPLEX$SimplexOptimalityTolerance$$anon$4.run(SolverConfig.scala:65)
at com.acme.domain.SolverConfigSpec$.$anonfun$spec$101(SolverConfigSpec.scala:100)
at com.acme.domain.SolverConfigSpec.spec(SolverConfigSpec.scala:99)
types:
importzio.preludeimportzio.prelude.Assertion._sealedtraitSolverConfig[T<:Solver]
objectSolverConfig {
objectCPLEX {
importzio.prelude._/* https://www.gams.com/latest/docs/S_CPLEX.html#CPLEXsolutiontype type of solution (basic or non basic) for an LP or QP 0, 1, 2, default 0*/objectSolutionTypeextendsSubtype[Int] {
overridedefassertion=
assert(Assertion.greaterThanOrEqualTo(0) && lessThanOrEqualTo(2))
}
objectSimplexOptimalityToleranceextendsSubtype[Double] {
overridedefassertion= assertCustom { value: Double=>Either.cond[AssertionError, Unit](value >=1.0e-09&& value <=0.1, (), prelude.AssertionError.Failure("value must be between 1.0e-09 and 0.1"))
}
}
}
}
Test-Code:
packagedomainimportSolverConfig.CPLEXimportSolverConfig.CPLEX._importzio.prelude.Validationimportzio.test._objectSolverConfigSpecextendsZIOSpecDefault {
overridedefspec= suite("SolverConfigSpec")(
suite("CPLEX")(
suite("SolutionType")(
test("fail on -1"){
valst:Validation[String, CPLEX.SolutionType.Type] =SolutionType.make(-1)
assertTrue(st.toEither.isLeft)
},
test("work on 0") {
valst:Validation[String, CPLEX.SolutionType.Type] =SolutionType.make(0)
assertTrue(st.toEither.isRight)
},
test("work on 1") {
valst:Validation[String, CPLEX.SolutionType.Type] =SolutionType.make(1)
assertTrue(st.toEither.isRight)
},
test("work on 2") {
valst:Validation[String, CPLEX.SolutionType.Type] =SolutionType.make(2)
assertTrue(st.toEither.isRight)
},
test("fail on 3") {
valst:Validation[String, CPLEX.SolutionType.Type] =SolutionType.make(3)
assertTrue(st.toEither.isLeft)
}
),
suite("SimplexOptimalityTolerance")(
test("fail on smaller than 1.0e-09"){
valsot:Validation[String, CPLEX.SimplexOptimalityTolerance.Type] =SimplexOptimalityTolerance.make(1.0e-10)
assertTrue(sot.toEither.isLeft)
},
test("work on 1.0e-09"){
valsot:Validation[String, CPLEX.SimplexOptimalityTolerance.Type] =SimplexOptimalityTolerance.make(1.0e-09)
assertTrue(sot.toEither.isRight)
},
test("work on value between 1.0e-09 and 0.1"){
valsot:Validation[String, CPLEX.SimplexOptimalityTolerance.Type] =SimplexOptimalityTolerance.make(0.05)
assertTrue(sot.toEither.isRight)
},
test("work on 0.1"){
valsot:Validation[String, CPLEX.SimplexOptimalityTolerance.Type] =SimplexOptimalityTolerance.make(0.1)
assertTrue(sot.toEither.isRight)
},
test("fail on 0.11"){
valsot:Validation[String, CPLEX.SimplexOptimalityTolerance.Type] =SimplexOptimalityTolerance.make(0.11)
assertTrue(sot.toEither.isLeft)
}
)
)
)
}
The text was updated successfully, but these errors were encountered:
When using
assertCustom
with aEither
, zio-prelude fails at runtime,e.g. the below class compiles fine, but the tests for
SimplexOptimalityTolerance
fail at runtime with aNoSuchMethodError
.Currently, this means I have to migrate all assertions to be the ones like in the SolutionType.
zio-version: 2.0.18
zio-prelude: 1.0.0-RC21
Exception:
types:
Test-Code:
The text was updated successfully, but these errors were encountered: