From 376b2b0cadf9a39aca67ca4c73368f461153b79a Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Sun, 6 Mar 2022 11:53:35 +0900 Subject: [PATCH] enable some Scala 3 tests (#208) --- build.sbt | 16 +++++---------- .../net/ceedubs/ficus/Issue82Spec.scala | 0 .../net/ceedubs/ficus/ExampleSpec.scala | 0 .../net/ceedubs/ficus/Examples.scala | 0 .../net/ceedubs/ficus/FicusConfigSpec.scala | 6 +++--- .../net/ceedubs/ficus/Scala3Compat.scala | 3 +++ .../readers/ArbitraryTypeReaderSpec.scala | 16 +++++++-------- .../ficus/readers/CaseClassReadersSpec.scala | 16 +++++++-------- ...aseInsensitiveEnumerationReadersSpec.scala | 0 .../ficus/readers/ChronoUnitReaderSpec.scala | 0 .../ficus/readers/ConfigReaderSpec.scala | 10 +++++----- .../readers/ISOZonedDateTimeReaderSpec.scala | 0 .../ficus/readers/LocalDateReaderSpec.scala | 0 .../ficus/readers/PeriodReaderSpec.scala | 0 .../net/ceedubs/ficus/Scala3Compat.scala | 9 +++++++++ .../net/ceedubs/ficus/ConfigSerializer.scala | 14 +++++++------ src/test/scala/net/ceedubs/ficus/Spec.scala | 2 +- .../ficus/readers/AnyValReadersSpec.scala | 14 ++++++------- .../ficus/readers/BigNumberReadersSpec.scala | 20 +++++++++---------- .../ficus/readers/CollectionReadersSpec.scala | 4 ++-- .../ficus/readers/ConfigValueReaderSpec.scala | 12 +++++------ .../ficus/readers/DurationReadersSpec.scala | 20 +++++++++---------- .../ficus/readers/EitherReadersSpec.scala | 12 +++++------ .../readers/EnumerationReadersSpec.scala | 4 ++-- .../HyphenNameMapperNoDigitsSpec.scala | 4 ++-- .../ficus/readers/HyphenNameMapperSpec.scala | 4 ++-- .../ficus/readers/OptionReadersSpec.scala | 2 +- .../ficus/readers/StringReaderSpec.scala | 2 +- .../ficus/readers/SymbolReaderSpec.scala | 2 +- .../ceedubs/ficus/readers/TryReaderSpec.scala | 4 ++-- .../ceedubs/ficus/readers/URLReaderSpec.scala | 5 ++--- .../ficus/readers/ValueReaderSpec.scala | 2 +- 32 files changed, 105 insertions(+), 98 deletions(-) rename src/test/{scala-2.13+ => scala-2.13}/net/ceedubs/ficus/Issue82Spec.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/ExampleSpec.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/Examples.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/FicusConfigSpec.scala (94%) create mode 100644 src/test/scala-2/net/ceedubs/ficus/Scala3Compat.scala rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala (95%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala (92%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/CaseInsensitiveEnumerationReadersSpec.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/ConfigReaderSpec.scala (86%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/ISOZonedDateTimeReaderSpec.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/LocalDateReaderSpec.scala (100%) rename src/test/{scala => scala-2}/net/ceedubs/ficus/readers/PeriodReaderSpec.scala (100%) create mode 100644 src/test/scala-3/net/ceedubs/ficus/Scala3Compat.scala diff --git a/build.sbt b/build.sbt index b8145e6..2c147ae 100644 --- a/build.sbt +++ b/build.sbt @@ -55,6 +55,7 @@ lazy val root = project description := "A Scala-friendly wrapper companion for Typesafe config", startYear := Some(2013), scalacOptions ++= Seq( + "-language:implicitConversions", "-feature", "-deprecation", "-unchecked", @@ -106,12 +107,12 @@ lazy val root = project libraryDependencies ++= (if (scalaVersion.value.startsWith("2.10")) Seq("org.specs2" %% "specs2-core" % "3.10.0" % Test, "org.specs2" %% "specs2-scalacheck" % "3.10.0" % Test) - else + else if (Set("2.11", "2.12", "2.13").contains(scalaBinaryVersion.value)) Seq("org.specs2" %% "specs2-core" % "4.8.3" % Test, "org.specs2" %% "specs2-scalacheck" % "4.8.3" % Test) - .map(_ cross CrossVersion.for3Use2_13)) ++ + else + Seq("org.specs2" %% "specs2-core" % "5.0.0" % Test, "org.specs2" %% "specs2-scalacheck" % "5.0.0" % Test)) ++ Seq( - "org.scalacheck" %% "scalacheck" % "1.14.1" % Test cross CrossVersion.for3Use2_13, - "com.typesafe" % "config" % "1.3.4" + "com.typesafe" % "config" % "1.3.4" ) ++ (if (Set("2.10", "2.11", "2.12").contains(scalaBinaryVersion.value)) Seq( @@ -136,13 +137,6 @@ lazy val root = project toPath != "application.conf" } }, - Test / sources := { - if (scalaBinaryVersion.value == "3") { - Nil // TODO - } else { - (Test / sources).value - } - }, Publish.settings, releaseCrossBuild := true, mimaPreviousArtifacts := diff --git a/src/test/scala-2.13+/net/ceedubs/ficus/Issue82Spec.scala b/src/test/scala-2.13/net/ceedubs/ficus/Issue82Spec.scala similarity index 100% rename from src/test/scala-2.13+/net/ceedubs/ficus/Issue82Spec.scala rename to src/test/scala-2.13/net/ceedubs/ficus/Issue82Spec.scala diff --git a/src/test/scala/net/ceedubs/ficus/ExampleSpec.scala b/src/test/scala-2/net/ceedubs/ficus/ExampleSpec.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/ExampleSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/ExampleSpec.scala diff --git a/src/test/scala/net/ceedubs/ficus/Examples.scala b/src/test/scala-2/net/ceedubs/ficus/Examples.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/Examples.scala rename to src/test/scala-2/net/ceedubs/ficus/Examples.scala diff --git a/src/test/scala/net/ceedubs/ficus/FicusConfigSpec.scala b/src/test/scala-2/net/ceedubs/ficus/FicusConfigSpec.scala similarity index 94% rename from src/test/scala/net/ceedubs/ficus/FicusConfigSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/FicusConfigSpec.scala index 1d3467d..8d37706 100644 --- a/src/test/scala/net/ceedubs/ficus/FicusConfigSpec.scala +++ b/src/test/scala-2/net/ceedubs/ficus/FicusConfigSpec.scala @@ -22,12 +22,12 @@ class FicusConfigSpec extends Spec { cfg.as[Boolean]("myValue") must beTrue } - def readAValue = prop { b: Boolean => + def readAValue = prop { (b: Boolean) => val cfg = ConfigFactory.parseString(s"myValue = $b") cfg.as[Boolean]("myValue") must beEqualTo(b) } - def getAsSome = prop { b: Boolean => + def getAsSome = prop { (b: Boolean) => val cfg = ConfigFactory.parseString(s"myValue = $b") cfg.getAs[Boolean]("myValue") must beSome(b) } @@ -60,7 +60,7 @@ class FicusConfigSpec extends Spec { cfg.getOrElse("myValue", default) must beEqualTo(124.toByte) } - def acceptAConfigKey = prop { b: Boolean => + def acceptAConfigKey = prop { (b: Boolean) => val cfg = ConfigFactory.parseString(s"myValue = $b") val key: ConfigKey[Boolean] = SimpleConfigKey("myValue") cfg(key) must beEqualTo(b) diff --git a/src/test/scala-2/net/ceedubs/ficus/Scala3Compat.scala b/src/test/scala-2/net/ceedubs/ficus/Scala3Compat.scala new file mode 100644 index 0000000..8277433 --- /dev/null +++ b/src/test/scala-2/net/ceedubs/ficus/Scala3Compat.scala @@ -0,0 +1,3 @@ +package net.ceedubs.ficus + +trait Scala3Compat diff --git a/src/test/scala/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala similarity index 95% rename from src/test/scala/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala index 92b805b..65ad718 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala +++ b/src/test/scala-2/net/ceedubs/ficus/readers/ArbitraryTypeReaderSpec.scala @@ -30,7 +30,7 @@ class ArbitraryTypeReaderSpec extends Spec { import ArbitraryTypeReaderSpec._ - def instantiateSingleParamApply = prop { foo2: String => + def instantiateSingleParamApply = prop { (foo2: String) => import Ficus.stringValueReader import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"simple { foo2 = ${foo2.asConfigValue} }") @@ -39,7 +39,7 @@ class ArbitraryTypeReaderSpec extends Spec { instance.foo must_== foo2 } - def instantiateSingleParamApplyFromSelf = prop { foo2: String => + def instantiateSingleParamApplyFromSelf = prop { (foo2: String) => import Ficus.stringValueReader import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"simple { foo2 = ${foo2.asConfigValue} }") @@ -48,7 +48,7 @@ class ArbitraryTypeReaderSpec extends Spec { instance.foo must_== foo2 } - def instantiateSingleParamConstructor = prop { foo: String => + def instantiateSingleParamConstructor = prop { (foo: String) => import Ficus.stringValueReader import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"singleParam { foo = ${foo.asConfigValue} }") @@ -80,7 +80,7 @@ class ArbitraryTypeReaderSpec extends Spec { (instance.foo must_== foo) and (instance.bar must_== bar) } - def multipleApply = prop { foo: String => + def multipleApply = prop { (foo: String) => import Ficus.stringValueReader import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"withMultipleApply { foo = ${foo.asConfigValue} }") @@ -89,7 +89,7 @@ class ArbitraryTypeReaderSpec extends Spec { instance.foo must_== foo } - def multipleConstructors = prop { foo: String => + def multipleConstructors = prop { (foo: String) => import Ficus.stringValueReader import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"withMultipleConstructors { foo = ${foo.asConfigValue} }") @@ -133,14 +133,14 @@ class ArbitraryTypeReaderSpec extends Spec { arbitraryTypeValueReader[WithOption].value.read(cfg, "withOption").option must_== Some("here") } - def ignoreApplyParamDefault = prop { foo: String => + def ignoreApplyParamDefault = prop { (foo: String) => import Ficus.{optionValueReader, stringValueReader} import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"withDefault { foo = ${foo.asConfigValue} }") arbitraryTypeValueReader[WithDefault].value.read(cfg, "withDefault").foo must_== foo } - def ignoreConstructorParamDefault = prop { foo: String => + def ignoreConstructorParamDefault = prop { (foo: String) => import Ficus.{optionValueReader, stringValueReader} import ArbitraryTypeReader._ val cfg = ConfigFactory.parseString(s"withDefault { foo = ${foo.asConfigValue} }") @@ -172,7 +172,7 @@ class ArbitraryTypeReaderSpec extends Spec { WithReaderInCompanion("from-companion") ==== cfg.as[WithReaderInCompanion]("withReaderInCompanion") } - def useNameMapper = prop { foo: String => + def useNameMapper = prop { (foo: String) => import Ficus.stringValueReader import ArbitraryTypeReader._ implicit val nameMapper: NameMapper = new NameMapper { diff --git a/src/test/scala/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala similarity index 92% rename from src/test/scala/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala index 62215fa..f2b54a4 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala +++ b/src/test/scala-2/net/ceedubs/ficus/readers/CaseClassReadersSpec.scala @@ -54,12 +54,12 @@ class CaseClassReadersSpec extends Spec { cfg.as[SimpleCaseClass]("simple") must_== SimpleCaseClass(bool = false) } - def hydrateSimpleCaseClass = prop { bool: Boolean => + def hydrateSimpleCaseClass = prop { (bool: Boolean) => val cfg = ConfigFactory.parseString(s"simple { bool = $bool }") cfg.as[SimpleCaseClass]("simple") must_== SimpleCaseClass(bool = bool) } - def hydrateSimpleCaseClassFromSelf = prop { bool: Boolean => + def hydrateSimpleCaseClassFromSelf = prop { (bool: Boolean) => val cfg = ConfigFactory.parseString(s"simple { bool = $bool }") cfg.getConfig("simple").as[SimpleCaseClass] must_== SimpleCaseClass(bool = bool) } @@ -74,12 +74,12 @@ class CaseClassReadersSpec extends Spec { cfg.as[MultipleFields]("multipleFields") must_== MultipleFields(string = foo, long = long) } - def withOptionField = prop { s: String => + def withOptionField = prop { (s: String) => val cfg = ConfigFactory.parseString(s"""withOption { option = ${s.asConfigValue} }""") cfg.as[WithOption]("withOption") must_== WithOption(Some(s)) } - def withNestedCaseClass = prop { bool: Boolean => + def withNestedCaseClass = prop { (bool: Boolean) => val cfg = ConfigFactory.parseString(s""" |withNested { | simple { @@ -90,12 +90,12 @@ class CaseClassReadersSpec extends Spec { cfg.as[WithNestedCaseClass]("withNested") must_== WithNestedCaseClass(simple = SimpleCaseClass(bool = bool)) } - def topLevelValueClass = prop { int: Int => + def topLevelValueClass = prop { (int: Int) => val cfg = ConfigFactory.parseString(s"valueClass { int = $int }") cfg.as[ValueClass]("valueClass") must_== ValueClass(int) } - def nestedValueClass = prop { int: Int => + def nestedValueClass = prop { (int: Int) => val cfg = ConfigFactory.parseString(s""" |withNestedValueClass { | valueClass = { @@ -108,12 +108,12 @@ class CaseClassReadersSpec extends Spec { ) } - def companionImplicitTopLevel = prop { int: Int => + def companionImplicitTopLevel = prop { (int: Int) => val cfg = ConfigFactory.parseString(s"value = $int ") cfg.as[CompanionImplicit]("value") must_== CompanionImplicit(int) } - def nestedCompanionImplicit = prop { int: Int => + def nestedCompanionImplicit = prop { (int: Int) => val cfg = ConfigFactory.parseString(s""" |withNestedCompanionImplicit { | value = $int diff --git a/src/test/scala/net/ceedubs/ficus/readers/CaseInsensitiveEnumerationReadersSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/CaseInsensitiveEnumerationReadersSpec.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/readers/CaseInsensitiveEnumerationReadersSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/CaseInsensitiveEnumerationReadersSpec.scala diff --git a/src/test/scala/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/ChronoUnitReaderSpec.scala diff --git a/src/test/scala/net/ceedubs/ficus/readers/ConfigReaderSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/ConfigReaderSpec.scala similarity index 86% rename from src/test/scala/net/ceedubs/ficus/readers/ConfigReaderSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/ConfigReaderSpec.scala index a58aed5..4526acd 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/ConfigReaderSpec.scala +++ b/src/test/scala-2/net/ceedubs/ficus/readers/ConfigReaderSpec.scala @@ -14,7 +14,7 @@ class ConfigReaderSpec extends Spec { implicitly read a ficus config itself $implicitlyReadFicusConfigFromSelf """ - def readConfig = prop { i: Int => + def readConfig = prop { (i: Int) => val cfg = ConfigFactory.parseString(s""" |myConfig { | myValue = $i @@ -23,7 +23,7 @@ class ConfigReaderSpec extends Spec { configValueReader.read(cfg, "myConfig").getInt("myValue") must beEqualTo(i) } - def implicitlyReadConfig = prop { i: Int => + def implicitlyReadConfig = prop { (i: Int) => val cfg = ConfigFactory.parseString(s""" |myConfig { | myValue = $i @@ -32,7 +32,7 @@ class ConfigReaderSpec extends Spec { cfg.as[Config]("myConfig").getInt("myValue") must beEqualTo(i) } - def readFicusConfig = prop { i: Int => + def readFicusConfig = prop { (i: Int) => val cfg = ConfigFactory.parseString(s""" |myConfig { | myValue = $i @@ -41,7 +41,7 @@ class ConfigReaderSpec extends Spec { ficusConfigValueReader.read(cfg, "myConfig").as[Int]("myValue") must beEqualTo(i) } - def implicitlyReadFicusConfig = prop { i: Int => + def implicitlyReadFicusConfig = prop { (i: Int) => val cfg = ConfigFactory.parseString(s""" |myConfig { | myValue = $i @@ -50,7 +50,7 @@ class ConfigReaderSpec extends Spec { cfg.as[FicusConfig]("myConfig").as[Int]("myValue") must beEqualTo(i) } - def implicitlyReadFicusConfigFromSelf = prop { i: Int => + def implicitlyReadFicusConfigFromSelf = prop { (i: Int) => val cfg = ConfigFactory.parseString(s""" |myConfig { | myValue = $i diff --git a/src/test/scala/net/ceedubs/ficus/readers/ISOZonedDateTimeReaderSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/ISOZonedDateTimeReaderSpec.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/readers/ISOZonedDateTimeReaderSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/ISOZonedDateTimeReaderSpec.scala diff --git a/src/test/scala/net/ceedubs/ficus/readers/LocalDateReaderSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/LocalDateReaderSpec.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/readers/LocalDateReaderSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/LocalDateReaderSpec.scala diff --git a/src/test/scala/net/ceedubs/ficus/readers/PeriodReaderSpec.scala b/src/test/scala-2/net/ceedubs/ficus/readers/PeriodReaderSpec.scala similarity index 100% rename from src/test/scala/net/ceedubs/ficus/readers/PeriodReaderSpec.scala rename to src/test/scala-2/net/ceedubs/ficus/readers/PeriodReaderSpec.scala diff --git a/src/test/scala-3/net/ceedubs/ficus/Scala3Compat.scala b/src/test/scala-3/net/ceedubs/ficus/Scala3Compat.scala new file mode 100644 index 0000000..649b5c4 --- /dev/null +++ b/src/test/scala-3/net/ceedubs/ficus/Scala3Compat.scala @@ -0,0 +1,9 @@ +package net.ceedubs.ficus + +import org.specs2._ + +trait Scala3Compat extends Specification { + implicit final class MustEqualExtension[A](a1: A) { + def must_==(a2: A) = a1 must beEqualTo(a2) + } +} diff --git a/src/test/scala/net/ceedubs/ficus/ConfigSerializer.scala b/src/test/scala/net/ceedubs/ficus/ConfigSerializer.scala index c4f47fa..7c14246 100644 --- a/src/test/scala/net/ceedubs/ficus/ConfigSerializer.scala +++ b/src/test/scala/net/ceedubs/ficus/ConfigSerializer.scala @@ -20,11 +20,11 @@ object ConfigSerializer { s"[${elements.mkString(", ")}]" } - implicit val stringSerializer = apply[String](ConfigUtil.quoteString) - implicit val booleanSerializer = fromToString[Boolean] - implicit val intSerializer = fromToString[Int] - implicit val longSerializer = fromToString[Long] - implicit val doubleSerializer = fromToString[Double] + implicit val stringSerializer: ConfigSerializer[String] = apply[String](ConfigUtil.quoteString) + implicit val booleanSerializer: ConfigSerializer[Boolean] = fromToString[Boolean] + implicit val intSerializer: ConfigSerializer[Int] = fromToString[Int] + implicit val longSerializer: ConfigSerializer[Long] = fromToString[Long] + implicit val doubleSerializer: ConfigSerializer[Double] = fromToString[Double] implicit def listSerializer[A: ConfigSerializer]: ConfigSerializer[List[A]] = apply[List[A]](serializeIterable) implicit def serializerForSets[A: ConfigSerializer]: ConfigSerializer[Set[A]] = apply[Set[A]](serializeIterable) @@ -36,7 +36,9 @@ object ConfigSerializer { } def iterableSerializer[A: ConfigSerializer]: ConfigSerializer[Iterable[A]] = apply[Iterable[A]](serializeIterable) - implicit def stringKeyMapSerializer[A](implicit valueSerializer: ConfigSerializer[A]) = + implicit def stringKeyMapSerializer[A](implicit + valueSerializer: ConfigSerializer[A] + ): ConfigSerializer[Map[String, A]] = new ConfigSerializer[Map[String, A]] { def serialize(map: Map[String, A]): String = { val lines = map.toIterable.map( diff --git a/src/test/scala/net/ceedubs/ficus/Spec.scala b/src/test/scala/net/ceedubs/ficus/Spec.scala index f035b4f..339840a 100644 --- a/src/test/scala/net/ceedubs/ficus/Spec.scala +++ b/src/test/scala/net/ceedubs/ficus/Spec.scala @@ -3,4 +3,4 @@ package net.ceedubs.ficus import org.specs2.matcher.MustMatchers import org.specs2.{ScalaCheck, Specification} -trait Spec extends Specification with MustMatchers with ScalaCheck +trait Spec extends Specification with MustMatchers with ScalaCheck with Scala3Compat diff --git a/src/test/scala/net/ceedubs/ficus/readers/AnyValReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/AnyValReadersSpec.scala index 20208d5..7244ffe 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/AnyValReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/AnyValReadersSpec.scala @@ -21,39 +21,39 @@ class AnyValReadersSpec extends Spec with AnyValReaders { read an int as a double $readIntAsDouble """ - def readBoolean = prop { b: Boolean => + def readBoolean = prop { (b: Boolean) => val cfg = ConfigFactory.parseString(s"myValue = $b") booleanValueReader.read(cfg, "myValue") must beEqualTo(b) } - def readInt = prop { i: Int => + def readInt = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") intValueReader.read(cfg, "myValue") must beEqualTo(i) } - def readDoubleAsInt = prop { d: Double => + def readDoubleAsInt = prop { (d: Double) => (d >= Int.MinValue && d <= Int.MaxValue) ==> { val cfg = ConfigFactory.parseString(s"myValue = $d") intValueReader.read(cfg, "myValue") must beEqualTo(d.toInt) } } - def readLong = prop { l: Long => + def readLong = prop { (l: Long) => val cfg = ConfigFactory.parseString(s"myValue = $l") longValueReader.read(cfg, "myValue") must beEqualTo(l) } - def readIntAsLong = prop { i: Int => + def readIntAsLong = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") longValueReader.read(cfg, "myValue") must beEqualTo(i.toLong) } - def readDouble = prop { d: Double => + def readDouble = prop { (d: Double) => val cfg = ConfigFactory.parseString(s"myValue = $d") doubleValueReader.read(cfg, "myValue") must beEqualTo(d) } - def readIntAsDouble = prop { i: Int => + def readIntAsDouble = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") doubleValueReader.read(cfg, "myValue") must beEqualTo(i.toDouble) } diff --git a/src/test/scala/net/ceedubs/ficus/readers/BigNumberReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/BigNumberReadersSpec.scala index b71ee34..0927c20 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/BigNumberReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/BigNumberReadersSpec.scala @@ -23,17 +23,17 @@ class BigNumberReadersSpec extends Spec with BigNumberReaders { detect wrong type on malformed BigInt $readMalformedBigInt """ - def readDoubleAsBigDecimal = prop { d: Double => + def readDoubleAsBigDecimal = prop { (d: Double) => val cfg = ConfigFactory.parseString(s"myValue = $d") bigDecimalReader.read(cfg, "myValue") must beEqualTo(BigDecimal(d)) } - def readLongAsBigDecimal = prop { l: Long => + def readLongAsBigDecimal = prop { (l: Long) => val cfg = ConfigFactory.parseString(s"myValue = $l") bigDecimalReader.read(cfg, "myValue") must beEqualTo(BigDecimal(l)) } - def readIntAsBigDecimal = prop { i: Int => + def readIntAsBigDecimal = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") bigDecimalReader.read(cfg, "myValue") must beEqualTo(BigDecimal(i)) } @@ -54,14 +54,14 @@ class BigNumberReadersSpec extends Spec with BigNumberReaders { } */ - def readBigDecimalAsStringBigDecimal = prop { b: BigDecimal => + def readBigDecimalAsStringBigDecimal = prop { (b: BigDecimal) => scala.util.Try(BigDecimal(b.toString)).toOption.isDefined ==> { val cfg = ConfigFactory.parseString(s"myValue = ${b.toString}") bigDecimalReader.read(cfg, "myValue") must beEqualTo(BigDecimal(b.toString)) } } - def readBigIntAsStringBigDecimal = prop { b: BigInt => + def readBigIntAsStringBigDecimal = prop { (b: BigInt) => scala.util.Try(BigDecimal(b.toString)).toOption.isDefined ==> { val cfg = ConfigFactory.parseString(s"myValue = ${b.toString}") bigDecimalReader.read(cfg, "myValue") must beEqualTo(BigDecimal(b.toString)) @@ -74,31 +74,31 @@ class BigNumberReadersSpec extends Spec with BigNumberReaders { bigDecimalReader.read(cfg, "myValue") must throwA[WrongType] } - def readBigIntAsBigDecimal = prop { b: BigInt => + def readBigIntAsBigDecimal = prop { (b: BigInt) => scala.util.Try(BigDecimal(b)).toOption.isDefined ==> { val cfg = ConfigFactory.parseString(s"myValue = $b") bigDecimalReader.read(cfg, "myValue") must beEqualTo(BigDecimal(b)) } } - def readIntAsBigInt = prop { i: Int => + def readIntAsBigInt = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") bigIntReader.read(cfg, "myValue") must beEqualTo(BigInt(i)) } - def readLongAsBigInt = prop { l: Long => + def readLongAsBigInt = prop { (l: Long) => val cfg = ConfigFactory.parseString(s"myValue = $l") bigIntReader.read(cfg, "myValue") must beEqualTo(BigInt(l)) } - def readBigIntAsBigInt = prop { b: BigInt => + def readBigIntAsBigInt = prop { (b: BigInt) => scala.util.Try(BigInt(b.toString)).toOption.isDefined ==> { val cfg = ConfigFactory.parseString(s"myValue = $b") bigIntReader.read(cfg, "myValue") must beEqualTo(BigInt(b.toString)) } } - def readBigIntAsStringBigInt = prop { b: BigInt => + def readBigIntAsStringBigInt = prop { (b: BigInt) => scala.util.Try(BigInt(b.toString)).toOption.isDefined ==> { val cfg = ConfigFactory.parseString(s"myValue = ${b.toString}") bigIntReader.read(cfg, "myValue") must beEqualTo(BigInt(b.toString)) diff --git a/src/test/scala/net/ceedubs/ficus/readers/CollectionReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/CollectionReadersSpec.scala index 6c915e2..c40f595 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/CollectionReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/CollectionReadersSpec.scala @@ -31,7 +31,7 @@ class CollectionReadersSpec extends Spec with CollectionReaders { } def readStringMap = { - def reads[A: Arbitrary: ValueReader: ConfigSerializer] = prop { map: Map[String, A] => + def reads[A: Arbitrary: ValueReader: ConfigSerializer] = prop { (map: Map[String, A]) => val cfg = ConfigFactory.parseString(s"myValue = ${map.asConfigValue}") mapValueReader[A].read(cfg, "myValue") must beEqualTo(map) } @@ -70,7 +70,7 @@ class CollectionReadersSpec extends Spec with CollectionReaders { ) = { def reads[V](implicit arb: Arbitrary[C[V]], serializer: ConfigSerializer[C[V]], reader: ValueReader[C[V]]) = - prop { values: C[V] => + prop { (values: C[V]) => val cfg = ConfigFactory.parseString(s"myValue = ${values.asConfigValue}") reader.read(cfg, "myValue") must beEqualTo(values) } diff --git a/src/test/scala/net/ceedubs/ficus/readers/ConfigValueReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/ConfigValueReaderSpec.scala index 3898982..7179fe7 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/ConfigValueReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/ConfigValueReaderSpec.scala @@ -15,42 +15,42 @@ class ConfigValueReaderSpec extends Spec with ConfigValueReader { read an object $readObject """ - def readBoolean = prop { b: Boolean => + def readBoolean = prop { (b: Boolean) => val cfg = ConfigFactory.parseString(s"myValue = $b") val read = configValueValueReader.read(cfg, "myValue") read.valueType must beEqualTo(ConfigValueType.BOOLEAN) read.unwrapped() must beEqualTo(b) } - def readInt = prop { i: Int => + def readInt = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") val read = configValueValueReader.read(cfg, "myValue") read.valueType must beEqualTo(ConfigValueType.NUMBER) read.unwrapped() must beEqualTo(int2Integer(i)) } - def readDouble = prop { d: Double => + def readDouble = prop { (d: Double) => val cfg = ConfigFactory.parseString(s"myValue = $d") val read = configValueValueReader.read(cfg, "myValue") read.valueType must beEqualTo(ConfigValueType.NUMBER) read.unwrapped() must beEqualTo(double2Double(d)) } - def readString = prop { s: String => + def readString = prop { (s: String) => val cfg = ConfigFactory.parseString(s"myValue = ${s.asConfigValue}") val read = configValueValueReader.read(cfg, "myValue") read.valueType must beEqualTo(ConfigValueType.STRING) read.unwrapped() must beEqualTo(s) } - def readObject = prop { i: Int => + def readObject = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = { i = $i }") val read = configValueValueReader.read(cfg, "myValue") read.valueType must beEqualTo(ConfigValueType.OBJECT) read.unwrapped() must beEqualTo(cfg.getValue("myValue").unwrapped()) } - def readList = prop { i: Int => + def readList = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = [ $i ]") val read = configValueValueReader.read(cfg, "myValue") read.valueType must beEqualTo(ConfigValueType.LIST) diff --git a/src/test/scala/net/ceedubs/ficus/readers/DurationReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/DurationReadersSpec.scala index 6df141a..66f7123 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/DurationReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/DurationReadersSpec.scala @@ -21,35 +21,35 @@ class DurationReadersSpec extends Spec with DurationReaders { read negative infinite values $readNegativeInf """ - def readMillis[T](reader: ValueReader[T]) = prop { i: Int => + def readMillis[T](reader: ValueReader[T]) = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") - reader.read(cfg, "myValue") must beEqualTo(i millis) + reader.read(cfg, "myValue") must beEqualTo(i.millis) } - def readMinutes[T](reader: ValueReader[T]) = Prop.forAll(Gen.choose(-1.5e8.toInt, 1.5e8.toInt)) { i: Int => + def readMinutes[T](reader: ValueReader[T]) = Prop.forAll(Gen.choose(-1.5e8.toInt, 1.5e8.toInt)) { (i: Int) => val cfg = ConfigFactory.parseString("myValue = \"" + i + " minutes\"") - reader.read(cfg, "myValue") must beEqualTo(i minutes) + reader.read(cfg, "myValue") must_== i.minutes } - def readDaysUnit[T](reader: ValueReader[T]) = Prop.forAll(Gen.choose(-106580, 106580)) { i: Int => + def readDaysUnit[T](reader: ValueReader[T]) = Prop.forAll(Gen.choose(-106580, 106580)) { (i: Int) => val str = i.toString + " day" + (if (i == 1) "" else "s") val cfg = ConfigFactory.parseString(s"""myValue = "$str" """) - reader.read(cfg, "myValue").toString must beEqualTo(str) + reader.read(cfg, "myValue").toString == str } def readPositiveInf = { val positiveInf = List("Inf", "PlusInf", "\"+Inf\"") - positiveInf.forall { s: String => + positiveInf.forall { (s: String) => val cfg = ConfigFactory.parseString(s"myValue = $s") - durationReader.read(cfg, "myValue") should be(Duration.Inf) + durationReader.read(cfg, "myValue") == Duration.Inf } } def readNegativeInf = { val negativeInf = List("-Inf", "MinusInf") - negativeInf.forall { s: String => + negativeInf.forall { (s: String) => val cfg = ConfigFactory.parseString(s"myValue = $s") - durationReader.read(cfg, "myValue") should be(Duration.MinusInf) + durationReader.read(cfg, "myValue") == Duration.MinusInf } } } diff --git a/src/test/scala/net/ceedubs/ficus/readers/EitherReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/EitherReadersSpec.scala index 5729b2e..1dabee0 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/EitherReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/EitherReadersSpec.scala @@ -27,32 +27,32 @@ class EitherReadersSpec handle complex types $handleComplexTypes """ - def readRightSideString = prop { a: String => + def readRightSideString = prop { (a: String) => val cfg = a.toConfigValue.atKey("x") eitherReader[String, String].read(cfg, "x") must beEqualTo(Right(a)) } - def fallbackToLeftSideOnMissingKey = prop { a: String => + def fallbackToLeftSideOnMissingKey = prop { (a: String) => eitherReader[Option[String], String].read(ConfigFactory.empty(), "x") must beEqualTo(Left(None)) } - def fallbackToLeftSideOnBadRightValue = prop { a: Int => + def fallbackToLeftSideOnBadRightValue = prop { (a: Int) => val badVal = a.toString + "xx" eitherReader[String, Int].read(badVal.toConfigValue.atKey("x"), "x") must beEqualTo(Left(badVal)) } - def rightAndLeftFailure = prop { a: Int => + def rightAndLeftFailure = prop { (a: Int) => val badVal = a.toString + "xx" tryValueReader(eitherReader[Int, Int]).read(badVal.toConfigValue.atKey("x"), "x") must beAnInstanceOf[Failure[Int]] } - def rightSideTry = prop { a: Int => + def rightSideTry = prop { (a: Int) => val badVal = a.toString + "xx" eitherReader[Int, Try[Int]].read(a.toConfigValue.atKey("x"), "x") must beRight(a) eitherReader[Int, Try[Int]].read(badVal.toConfigValue.atKey("x"), "x") must beRight(beFailedTry[Int]) } - def leftSideTry = prop { a: Int => + def leftSideTry = prop { (a: Int) => val badVal = a.toString + "xx" eitherReader[Try[String], Int].read(badVal.toConfigValue.atKey("x"), "x") must beLeft( beSuccessfulTry[String](badVal) diff --git a/src/test/scala/net/ceedubs/ficus/readers/EnumerationReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/EnumerationReadersSpec.scala index 2613b1b..7ac867d 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/EnumerationReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/EnumerationReadersSpec.scala @@ -19,13 +19,13 @@ class EnumerationReadersSpec extends Spec with EnumerationReader { def successStringMapping = { val cfg = ConfigFactory.parseString("myValue = SECOND") implicit val classTag = ClassTag[StringValueEnum.type](StringValueEnum.getClass) - enumerationValueReader[StringValueEnum.type].read(cfg, "myValue") must be equalTo StringValueEnum.second + enumerationValueReader[StringValueEnum.type].read(cfg, "myValue") must_== StringValueEnum.second } def successIntMapping = { val cfg = ConfigFactory.parseString("myValue = second") implicit val classTag = ClassTag[IntValueEnum.type](IntValueEnum.getClass) - enumerationValueReader[IntValueEnum.type].read(cfg, "myValue") must be equalTo IntValueEnum.second + enumerationValueReader[IntValueEnum.type].read(cfg, "myValue") must_== IntValueEnum.second } def invalidMapping = { diff --git a/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperNoDigitsSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperNoDigitsSpec.scala index 402bef4..1f5d07e 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperNoDigitsSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperNoDigitsSpec.scala @@ -15,9 +15,9 @@ class HyphenNameMapperNoDigitsSpec extends Spec with DataTables { def nonemptyStringListGen = nonEmptyListOf(alphaStr.suchThat(_.length > 1).map(_.toLowerCase)) - implicit def nonemptyStringList = Arbitrary(nonemptyStringListGen) + implicit def nonemptyStringList: Arbitrary[List[String]] = Arbitrary(nonemptyStringListGen) - def hyphenateCorrectly = prop { foos: List[String] => + def hyphenateCorrectly = prop { (foos: List[String]) => val camelCased = (foos.head +: foos.tail.map(_.capitalize)).mkString val hyphenated = foos.mkString("-").toLowerCase diff --git a/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperSpec.scala index 170eab5..1783340 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/HyphenNameMapperSpec.scala @@ -15,9 +15,9 @@ class HyphenNameMapperSpec extends Spec with DataTables { def nonemptyStringListGen = nonEmptyListOf(alphaStr.suchThat(_.length > 1).map(_.toLowerCase)) - implicit def nonemptyStringList = Arbitrary(nonemptyStringListGen) + implicit def nonemptyStringList: Arbitrary[List[String]] = Arbitrary(nonemptyStringListGen) - def hyphenateCorrectly = prop { foos: List[String] => + def hyphenateCorrectly = prop { (foos: List[String]) => val camelCased = (foos.head +: foos.tail.map(_.capitalize)).mkString val hyphenated = foos.mkString("-").toLowerCase diff --git a/src/test/scala/net/ceedubs/ficus/readers/OptionReadersSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/OptionReadersSpec.scala index 7cc8061..7fc552c 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/OptionReadersSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/OptionReadersSpec.scala @@ -10,7 +10,7 @@ class OptionReadersSpec extends Spec with OptionReader with AnyValReaders { return a None for a non-existing value $optionNone """ - def optionSome = prop { i: Int => + def optionSome = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") optionValueReader[Int].read(cfg, "myValue") must beSome(i) } diff --git a/src/test/scala/net/ceedubs/ficus/readers/StringReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/StringReaderSpec.scala index e8c8404..7c670dc 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/StringReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/StringReaderSpec.scala @@ -11,7 +11,7 @@ class StringReaderSpec extends Spec with StringReader { read a String $readString """ - def readString = prop { string: String => + def readString = prop { (string: String) => val cfg = ConfigFactory.parseString(s"myValue = ${string.asConfigValue}") stringValueReader.read(cfg, "myValue") must beEqualTo(string) } diff --git a/src/test/scala/net/ceedubs/ficus/readers/SymbolReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/SymbolReaderSpec.scala index 2e5ffb5..9a7aa05 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/SymbolReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/SymbolReaderSpec.scala @@ -10,7 +10,7 @@ class SymbolReaderSpec extends Spec with SymbolReader { read a Symbol $readSymbol """ - def readSymbol = prop { string: String => + def readSymbol = prop { (string: String) => val cfg = ConfigFactory.parseString(s"myValue = ${string.asConfigValue}") symbolValueReader.read(cfg, "myValue") must beEqualTo(Symbol(string)) } diff --git a/src/test/scala/net/ceedubs/ficus/readers/TryReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/TryReaderSpec.scala index f787a77..4c0ea6d 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/TryReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/TryReaderSpec.scala @@ -14,7 +14,7 @@ class TryReaderSpec extends Spec with TryReader with AnyValReaders { handle an unexpected exception $unexpectedException """ - def successWhenPresent = prop { i: Int => + def successWhenPresent = prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") tryValueReader[Int].read(cfg, "myValue") must beSuccessfulTry[Int].withValue(i) } @@ -32,7 +32,7 @@ class TryReaderSpec extends Spec with TryReader with AnyValReaders { tryValueReader[String].read(cfg, "myValue") must beFailedTry[String].withThrowable[NullPointerException]("oops") } - def unexpectedException = prop { up: Throwable => + def unexpectedException = prop { (up: Throwable) => val cfg = ConfigFactory.parseString("myValue = true") implicit val stringValueReader: ValueReader[String] = new ValueReader[String] { def read(config: Config, path: String): String = throw up diff --git a/src/test/scala/net/ceedubs/ficus/readers/URLReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/URLReaderSpec.scala index c9a5ce6..ed0486b 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/URLReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/URLReaderSpec.scala @@ -5,7 +5,6 @@ import java.net.URL import com.typesafe.config.ConfigException.WrongType import com.typesafe.config.ConfigFactory import net.ceedubs.ficus.Spec -import org.specs2.matcher.MatchResult class URLReaderSpec extends Spec with URLReader with TryReader { def is = s2""" @@ -14,13 +13,13 @@ class URLReaderSpec extends Spec with URLReader with TryReader { detect wrong type on malformed URL (with an unsupported protocol) $readMalformedURL """ - def readValidURL: MatchResult[URL] = { + def readValidURL = { val url = """https://www.google.com""" val cfg = ConfigFactory.parseString(s"myValue = ${"\"" + url + "\""}") javaURLReader.read(cfg, "myValue") must beEqualTo(new URL(url)) } - def readMalformedURL: MatchResult[Any] = { + def readMalformedURL = { val malformedUrl = """foo://bar.com""" val cfg = ConfigFactory.parseString(s"myValue = ${"\"" + malformedUrl + "\""}") javaURLReader.read(cfg, "myValue") must throwA[WrongType] diff --git a/src/test/scala/net/ceedubs/ficus/readers/ValueReaderSpec.scala b/src/test/scala/net/ceedubs/ficus/readers/ValueReaderSpec.scala index 6ddad0e..221050d 100644 --- a/src/test/scala/net/ceedubs/ficus/readers/ValueReaderSpec.scala +++ b/src/test/scala/net/ceedubs/ficus/readers/ValueReaderSpec.scala @@ -16,7 +16,7 @@ class ValueReaderSpec extends Spec { def transformAsFunctor = { val plusOneReader = ValueReader[Int].map(_ + 1) - prop { i: Int => + prop { (i: Int) => val cfg = ConfigFactory.parseString(s"myValue = $i") plusOneReader.read(cfg, "myValue") must beEqualTo(i + 1) }