Skip to content

Commit

Permalink
Add tests for TypeRepr.isTupleN
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Aug 26, 2021
1 parent c328d74 commit e765d5e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/run-macros/TypeRepr-isTupleN/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.quoted.*

inline def isTupleN[T]: Boolean = ${ isTupleNImpl[T] }

private def isTupleNImpl[T: Type](using Quotes): Expr[Boolean] = {
import quotes.reflect.*
Expr(TypeRepr.of[T].isTupleN)
}
38 changes: 38 additions & 0 deletions tests/run-macros/TypeRepr-isTupleN/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@main def Test = {
assert(isTupleN[Tuple1[Int]])
assert(isTupleN[(Int, Int)])
assert(isTupleN[(Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)])

type Tup = (Int, Int)
assert(isTupleN[Tup])

assert(!isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) // No tuple 23
assert(!isTupleN[Tuple])
assert(!isTupleN[EmptyTuple])
assert(!isTupleN[NonEmptyTuple])
assert(!isTupleN[Int *: Tuple])

assert(!isTupleN[Any])
assert(!isTupleN[Int])
assert(!isTupleN[Object])
assert(!isTupleN[Nothing])
}

0 comments on commit e765d5e

Please sign in to comment.