Skip to content

Commit

Permalink
[WIP] Port TraverseSuite to Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Aug 29, 2021
1 parent b4200bf commit fdb59f1
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions core/src/test/scala-3/cats/derived/TraverseSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cats
package derived

import cats.laws.discipline.{SerializableTests, TraverseTests}

class TraverseSuite extends KittensSuite {
import TestDefns.*
import TraverseSuite.*

def testTraverse(context: String)(implicit
iList: Traverse[IList],
tree: Traverse[Tree],
genericAdt: Traverse[GenericAdt],
optList: Traverse[OptList],
listSnoc: Traverse[ListSnoc],
andChar: Traverse[AndChar],
interleaved: Traverse[Interleaved]
): Unit = {
checkAll(s"$context.Traverse[IList]", TraverseTests[IList].traverse[Int, Double, String, Long, Option, Option])
checkAll(s"$context.Traverse[Tree]", TraverseTests[Tree].traverse[Int, Double, String, Long, Option, Option])
checkAll(
s"$context.Traverse[GenericAdt]",
TraverseTests[GenericAdt].traverse[Int, Double, String, Long, Option, Option]
)
checkAll(s"$context.Traverse[OptList]", TraverseTests[OptList].traverse[Int, Double, String, Long, Option, Option])
checkAll(
s"$context.Traverse[ListSnoc]",
TraverseTests[ListSnoc].traverse[Int, Double, String, Long, Option, Option]
)
checkAll(s"$context.Traverse[AndChar]", TraverseTests[AndChar].traverse[Int, Double, String, Long, Option, Option])
checkAll(
s"$context.Traverse[Interleaved]",
TraverseTests[Interleaved].traverse[Int, Double, String, Long, Option, Option]
)
checkAll(s"$context.Traverse is Serializable", SerializableTests.serializable(Traverse[Tree]))
}

{
import auto.traverse.given
testTraverse("auto")
}

{
import semiInstances._
testTraverse("semiauto")
}
}

object TraverseSuite {
import TestDefns._

type OptList[A] = Option[List[A]]
type ListSnoc[A] = List[Snoc[A]]
type AndChar[A] = (A, Char)

object semiInstances {
implicit val iList: Traverse[IList] = semiauto.traverse
implicit val tree: Traverse[Tree] = semiauto.traverse
implicit val genericAdt: Traverse[GenericAdt] = semiauto.traverse
implicit val optList: Traverse[OptList] = semiauto.traverse
implicit val listSnoc: Traverse[ListSnoc] = semiauto.traverse
implicit val andChar: Traverse[AndChar] = semiauto.traverse
implicit val interleaved: Traverse[Interleaved] = semiauto.traverse
}
}

0 comments on commit fdb59f1

Please sign in to comment.