Skip to content

Commit

Permalink
Prefer explicit imports instead of trait mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones committed Nov 13, 2023
1 parent f3335b6 commit 01e6a41
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 50 deletions.
3 changes: 2 additions & 1 deletion cats/src/test/scala/magnolify/cats/BandDerivationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import org.scalacheck.*

import scala.reflect.*

class BandDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
class BandDerivationSuite extends MagnolifySuite {
import BandDerivationSuite.*
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genBand

private def test[T: Arbitrary: ClassTag: Eq: Band]: Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import org.scalacheck.*

import scala.reflect.*

class CommutativeGroupDerivationSuite
extends MagnolifySuite
with magnolify.scalacheck.AutoDerivations {
class CommutativeGroupDerivationSuite extends MagnolifySuite {
import CommutativeGroupDerivationSuite.*
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genCommutativeGroup

private def test[T: Arbitrary: ClassTag: Eq: CommutativeGroup]: Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import org.scalacheck.*

import scala.reflect.*

class CommutativeMonoidDerivationSuite
extends MagnolifySuite
with magnolify.scalacheck.AutoDerivations {
class CommutativeMonoidDerivationSuite extends MagnolifySuite {
import CommutativeMonoidDerivationSuite.*
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genCommutativeMonoid

private def test[T: Arbitrary: ClassTag: Eq: CommutativeMonoid]: Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import org.scalacheck.*

import scala.reflect.*

class CommutativeSemigroupDerivationSuite
extends MagnolifySuite
with magnolify.scalacheck.AutoDerivations {
class CommutativeSemigroupDerivationSuite extends MagnolifySuite {
import CommutativeSemigroupDerivationSuite.*
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genCommutativeSemigroup

private def test[T: Arbitrary: ClassTag: Eq: CommutativeSemigroup]: Unit = {
Expand Down
35 changes: 18 additions & 17 deletions cats/src/test/scala/magnolify/cats/EqDerivationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,30 @@

package magnolify.cats

import cats.Eq._
import cats._
import cats.kernel.laws.discipline._
import magnolify.cats.auto.genEq
import magnolify.cats.TestEq.eqArray
import magnolify.cats.TestEq.eqDuration
import magnolify.cats.TestEq.eqUri
import magnolify.scalacheck.TestArbitrary._
import magnolify.scalacheck.TestCogen._
import magnolify.test.ADT._
import magnolify.test.Simple._
import magnolify.test._
import org.scalacheck._

import scala.reflect._

class EqDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
import cats.*
import cats.kernel.laws.discipline.*
import magnolify.test.*
import magnolify.test.ADT.*
import magnolify.test.Simple.*
import org.scalacheck.*

import scala.reflect.*

class EqDerivationSuite extends MagnolifySuite {
import magnolify.cats.auto.genEq

private def test[T: Arbitrary: ClassTag: Cogen: Eq]: Unit = {
// TODO val eq = ensureSerializable(implicitly[Eq[T]])
val eq = Eq[T]
include(EqTests[T](eq).eqv.all, className[T] + ".")
}

import magnolify.scalacheck.TestArbitrary.*
import magnolify.scalacheck.TestCogen.*
import magnolify.cats.TestEq.eqArray
import magnolify.cats.TestEq.eqDuration
import magnolify.cats.TestEq.eqUri

test[Numbers]
test[Required]
test[Nullable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import org.scalacheck.*

import scala.reflect.*

class GroupDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
class GroupDerivationSuite extends MagnolifySuite {
import GroupDerivationSuite.*
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genGroup

private def test[T: Arbitrary: ClassTag: Eq: Group]: Unit = {
Expand Down
23 changes: 11 additions & 12 deletions cats/src/test/scala/magnolify/cats/HashDerivationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,20 @@

package magnolify.cats

import cats._
import cats.kernel.laws.discipline._
import magnolify.test.ADT._
import magnolify.test.Simple._
import magnolify.test._
import org.scalacheck._

import scala.reflect._
import cats.*
import cats.kernel.laws.discipline.*
import magnolify.test.*
import magnolify.test.ADT.*
import magnolify.test.Simple.*
import org.scalacheck.*

import java.net.URI
import java.time.Duration
import cats.Eq._
import magnolify.scalacheck.TestArbitrary._
import magnolify.scalacheck.TestCogen._
import scala.reflect.*

class HashDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
class HashDerivationSuite extends MagnolifySuite {
import magnolify.cats.auto.genHash
import magnolify.scalacheck.auto.genArbitrary

private def test[T: Arbitrary: ClassTag: Cogen: Hash](exclusions: String*): Unit = {
// TODO val hash = ensureSerializable(implicitly[Hash[T]])
Expand All @@ -43,6 +40,8 @@ class HashDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoD
}
}

import magnolify.scalacheck.TestArbitrary.*
import magnolify.scalacheck.TestCogen.*
// Use `scala.util.hashing.Hashing[T]` for `Array[Int]`, equivalent to `x.##` and `x.hashCode`
implicit val hash: Hash[Array[Int]] = Hash.fromHashing[Array[Int]]
implicit val hashUri: Hash[URI] = Hash.fromUniversalHashCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import cats.kernel.laws.discipline.*
import magnolify.cats.TestEq.*
import magnolify.cats.Types.MiniInt
import magnolify.cats.semiauto.*
import magnolify.scalacheck.TestArbitrary.*
import magnolify.test.*
import magnolify.test.Simple.*
import org.scalacheck.*
Expand All @@ -30,8 +29,9 @@ import java.net.URI
import java.time.Duration
import scala.reflect.*

class MonoidDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
class MonoidDerivationSuite extends MagnolifySuite {
import MonoidDerivationSuite.*
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genMonoid

private def test[T: Arbitrary: ClassTag: Eq: Monoid]: Unit = {
Expand All @@ -40,11 +40,13 @@ class MonoidDerivationSuite extends MagnolifySuite with magnolify.scalacheck.Aut
include(MonoidTests[T](mon).monoid.all, className[T] + ".")
}

import magnolify.scalacheck.TestArbitrary.*
implicit val eqRecord: Eq[Record] = Eq.gen[Record]
implicit val mBool: Monoid[Boolean] = Monoid.instance(false, _ || _)
implicit val mUri: Monoid[URI] =
Monoid.instance(URI.create(""), (x, y) => URI.create(x.toString + y.toString))
implicit val mDuration: Monoid[Duration] = Monoid.instance(Duration.ZERO, _ plus _)
implicit val mDuration: Monoid[Duration] =
Monoid.instance(Duration.ZERO, _ plus _)
implicit val mMiniInt: Monoid[MiniInt] =
Monoid.instance(MiniInt(0), (x, y) => MiniInt(x.i + y.i))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ package magnolify.cats

import cats.*
import cats.kernel.laws.discipline.*
import magnolify.cats.semiauto.*
import magnolify.cats.TestEq.*
import magnolify.cats.Types.MiniInt
import magnolify.cats.auto.genSemigroup
import magnolify.scalacheck.TestArbitrary.*
import magnolify.cats.semiauto.*
import magnolify.test.*
import magnolify.test.Simple.*
import org.scalacheck.*
Expand All @@ -31,15 +28,19 @@ import java.net.URI
import java.time.Duration
import scala.reflect.*

class SemigroupDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
class SemigroupDerivationSuite extends MagnolifySuite {
import SemigroupDerivationSuite.*
import magnolify.cats.auto.genSemigroup
import magnolify.scalacheck.auto.genArbitrary

private def test[T: Arbitrary: ClassTag: Eq: Semigroup]: Unit = {
// TODO val sg = ensureSerializable(implicitly[Semigroup[T]])
val sg = Semigroup[T]
include(SemigroupTests[T](sg).semigroup.all, className[T] + ".")
}

import magnolify.scalacheck.TestArbitrary.*
import magnolify.cats.TestEq.*
implicit val eqRecord: Eq[Record] = Eq.gen[Record]
implicit val sgBool: Semigroup[Boolean] = Semigroup.instance(_ ^ _)
implicit val sgUri: Semigroup[URI] =
Expand Down
5 changes: 3 additions & 2 deletions cats/src/test/scala/magnolify/cats/ShowDerivationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import cats.Show
import cats.laws.discipline.{ContravariantTests, MiniInt}
import cats.laws.discipline.arbitrary.*
import cats.laws.discipline.eq.*
import magnolify.scalacheck.TestArbitrary.*
import magnolify.test.*
import magnolify.test.ADT.*
import magnolify.test.Simple.*
Expand All @@ -30,7 +29,8 @@ import java.net.URI
import java.time.Duration
import scala.reflect.*

class ShowDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoDerivations {
class ShowDerivationSuite extends MagnolifySuite {
import magnolify.scalacheck.auto.genArbitrary
import magnolify.cats.auto.genShow

private def test[T: Arbitrary: ClassTag: Show]: Unit = {
Expand All @@ -48,6 +48,7 @@ class ShowDerivationSuite extends MagnolifySuite with magnolify.scalacheck.AutoD
}
}

import magnolify.scalacheck.TestArbitrary.*
implicit val showArray: Show[Array[Int]] = Show.fromToString
implicit val showUri: Show[URI] = Show.fromToString
implicit val showDuration: Show[Duration] = Show.fromToString
Expand Down

0 comments on commit 01e6a41

Please sign in to comment.