diff --git a/modules/cats/shared/src/test/scala/eu/timepit/refined/cats/SyntaxSpec.scala b/modules/cats/shared/src/test/scala/eu/timepit/refined/cats/SyntaxSpec.scala index af4e4742b..2367624dc 100644 --- a/modules/cats/shared/src/test/scala/eu/timepit/refined/cats/SyntaxSpec.scala +++ b/modules/cats/shared/src/test/scala/eu/timepit/refined/cats/SyntaxSpec.scala @@ -3,8 +3,7 @@ package eu.timepit.refined.cats import _root_.cats.data.{NonEmptyList, Validated} import eu.timepit.refined.W import eu.timepit.refined.api.{Refined, RefinedTypeOps} -import eu.timepit.refined.numeric.{Interval, Positive} -import eu.timepit.refined.refineMV +import eu.timepit.refined.numeric.Interval import eu.timepit.refined.types.numeric.PosInt import org.scalacheck.Prop._ import org.scalacheck.Properties @@ -45,12 +44,12 @@ class SyntaxSpec extends Properties("syntax") { property("NonEmptyList refinedSize (1)") = secure { import syntax._ - NonEmptyList.of("one").refinedSize ?= refineMV[Positive](1) + NonEmptyList.of("one").refinedSize ?= PosInt.unsafeFrom(1) } property("NonEmptyList refinedSize (> 1)") = secure { import syntax._ - NonEmptyList.of("one", "two", "three").refinedSize ?= refineMV[Positive](3) + NonEmptyList.of("one", "two", "three").refinedSize ?= PosInt.unsafeFrom(3) } } diff --git a/modules/eval/shared/src/test/scala/eu/timepit/refined/EvalValidateSpec.scala b/modules/eval/shared/src/test/scala/eu/timepit/refined/EvalValidateSpec.scala index 8f6da8c94..c4f220b1e 100644 --- a/modules/eval/shared/src/test/scala/eu/timepit/refined/EvalValidateSpec.scala +++ b/modules/eval/shared/src/test/scala/eu/timepit/refined/EvalValidateSpec.scala @@ -1,12 +1,10 @@ package eu.timepit.refined -import eu.timepit.refined.TestUtils.wellTyped import eu.timepit.refined.api.Validate import eu.timepit.refined.eval.Eval import org.scalacheck.Prop._ import org.scalacheck.Properties import scala.tools.reflect.ToolBoxError -import shapeless.test.illTyped class EvalValidateSpec extends Properties("EvalValidate") { @@ -21,24 +19,11 @@ class EvalValidateSpec extends Properties("EvalValidate") { Validate[Int, IsEven].showExpr(0) ?= "(x: Int) => x % 2 == 0" } - property("Eval.refineMV") = wellTyped { - refineMV[IsEven](2) - illTyped("refineMV[IsEven](3)", "Predicate.*fail.*") - } - property("Eval.refineV.no parameter type") = { val v = Validate[List[Int], Eval[W.`"_.headOption.fold(false)(_ > 0)"`.T]] forAll((l: List[Int]) => v.isValid(l) ?= l.headOption.fold(false)(_ > 0)) } - property("Eval.refineMV.scope") = wellTyped { - val two = 2 - illTyped( - """refineMV[Eval[W.`"(x: Int) => x >= two"`.T]](2)""", - "exception during macro expansion.*" - ) - } - property("Eval.refineV.scope") = secure { val two = 2 throws(classOf[ToolBoxError])(refineV[Eval[W.`"(x: Int) => x >= two"`.T]](two)) diff --git a/modules/pureconfig/shared/src/test/scala/eu/timepit/refined/pureconfig/RefTypeConfigConvertSpec.scala b/modules/pureconfig/shared/src/test/scala/eu/timepit/refined/pureconfig/RefTypeConfigConvertSpec.scala index bb33ef7d3..c5ecbf70a 100644 --- a/modules/pureconfig/shared/src/test/scala/eu/timepit/refined/pureconfig/RefTypeConfigConvertSpec.scala +++ b/modules/pureconfig/shared/src/test/scala/eu/timepit/refined/pureconfig/RefTypeConfigConvertSpec.scala @@ -1,9 +1,7 @@ package eu.timepit.refined.pureconfig import com.typesafe.config.{ConfigOriginFactory, ConfigValueType} -import eu.timepit.refined.api.Refined -import eu.timepit.refined.auto._ -import eu.timepit.refined.numeric.Positive +import eu.timepit.refined.types.numeric.PosInt import org.scalacheck.Prop._ import org.scalacheck.Properties import pureconfig._ @@ -12,12 +10,11 @@ import pureconfig.generic.auto._ class RefTypeConfigConvertSpec extends Properties("RefTypeConfigConvert") { - type PosInt = Int Refined Positive case class Config(value: PosInt) property("load success") = secure { loadConfigWithValue("1") ?= - Right(Config(1)) + Right(Config(PosInt.unsafeFrom(1))) } property("load failure (predicate)") = secure { @@ -75,7 +72,7 @@ class RefTypeConfigConvertSpec extends Properties("RefTypeConfigConvert") { } property("roundtrip success") = secure { - val config = Config(1) + val config = Config(PosInt.unsafeFrom(1)) val configValue = ConfigConvert[Config].to(config) ConfigConvert[Config].from(configValue) ?= Right(config) diff --git a/modules/scodec/shared/src/test/scala/eu/timepit/refined/scodec/RefTypeCodecSpec.scala b/modules/scodec/shared/src/test/scala/eu/timepit/refined/scodec/RefTypeCodecSpec.scala index daeaa83d9..e5fc27309 100644 --- a/modules/scodec/shared/src/test/scala/eu/timepit/refined/scodec/RefTypeCodecSpec.scala +++ b/modules/scodec/shared/src/test/scala/eu/timepit/refined/scodec/RefTypeCodecSpec.scala @@ -1,24 +1,19 @@ package eu.timepit.refined.scodec -import eu.timepit.refined.TestUtils._ -import eu.timepit.refined.api.Refined -import eu.timepit.refined.auto._ -import eu.timepit.refined.numeric.Positive +import eu.timepit.refined.types.numeric.PosInt import org.scalacheck.Prop._ import org.scalacheck.Properties import scodec._ import scodec.bits._ import scodec.codecs.int8 -import shapeless.test.illTyped class RefTypeCodecSpec extends Properties("RefTypeCodec") { - type PosInt = Int Refined Positive - implicit val intCodec = int8 + implicit val intCodec: Codec[Int] = int8 property("decode success") = secure { Codec[PosInt].decode(bin"00000101") ?= - Attempt.successful(DecodeResult(5: PosInt, BitVector.empty)) + Attempt.successful(DecodeResult(PosInt.unsafeFrom(5), BitVector.empty)) } property("decode failure") = secure { @@ -27,14 +22,10 @@ class RefTypeCodecSpec extends Properties("RefTypeCodec") { } property("encode success") = secure { - Codec[PosInt].encode(5) ?= + Codec[PosInt].encode(PosInt.unsafeFrom(5)) ?= Attempt.successful(bin"00000101") } - property("encode failure") = wellTyped { - illTyped("""Codec[PosInt].encode(-5)""", "Predicate failed.*") - } - property("sizeBound") = secure { Codec[PosInt].sizeBound ?= intCodec.sizeBound } diff --git a/modules/scopt/shared/src/test/scala/eu/timepit/refined/scopt/RefTypeRedSpec.scala b/modules/scopt/shared/src/test/scala/eu/timepit/refined/scopt/RefTypeReadSpec.scala similarity index 76% rename from modules/scopt/shared/src/test/scala/eu/timepit/refined/scopt/RefTypeRedSpec.scala rename to modules/scopt/shared/src/test/scala/eu/timepit/refined/scopt/RefTypeReadSpec.scala index a6ce78c21..a0719f36a 100644 --- a/modules/scopt/shared/src/test/scala/eu/timepit/refined/scopt/RefTypeRedSpec.scala +++ b/modules/scopt/shared/src/test/scala/eu/timepit/refined/scopt/RefTypeReadSpec.scala @@ -1,15 +1,12 @@ package eu.timepit.refined.scopt -import eu.timepit.refined.api.Refined -import eu.timepit.refined.auto._ -import eu.timepit.refined.numeric.Positive +import eu.timepit.refined.types.numeric.PosInt import org.scalacheck.Prop._ import org.scalacheck.Properties import scopt._ class RefTypeReadSpec extends Properties("RefTypeRead") { - type PosInt = Int Refined Positive case class Config(foo: PosInt) val parser = new OptionParser[Config]("tests") { @@ -20,7 +17,7 @@ class RefTypeReadSpec extends Properties("RefTypeRead") { property("load success") = secure { loadConfigWithValue("10") =? - Some(Config(10)) + Some(Config(PosInt.unsafeFrom(10))) } property("load failure (predicate)") = secure { @@ -34,5 +31,5 @@ class RefTypeReadSpec extends Properties("RefTypeRead") { } def loadConfigWithValue(value: String): Option[Config] = - parser.parse(Array("-f", value), Config(1)) + parser.parse(Array("-f", value), Config(PosInt.unsafeFrom(1))) }