diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2017-01-25 14:09:41 +1000 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2017-01-27 09:30:36 -0800 |
commit | bba5f5ad3c23bad8dfc60a6daad546b112678908 (patch) | |
tree | 27ae2bbb4f437e5040a109c1ae67a5981a42d30d /test/scalacheck/scala/reflect/quasiquotes/TypeConstructionProps.scala | |
parent | 33f6c07e872baa4fbd0ef7c76de2260161e7673d (diff) | |
download | scala-bba5f5ad3c23bad8dfc60a6daad546b112678908.tar.gz scala-bba5f5ad3c23bad8dfc60a6daad546b112678908.tar.bz2 scala-bba5f5ad3c23bad8dfc60a6daad546b112678908.zip |
Move scalacheck test suite sources to folders corresponding packaging
Also moves some tests into suitable packaging.
Diffstat (limited to 'test/scalacheck/scala/reflect/quasiquotes/TypeConstructionProps.scala')
-rw-r--r-- | test/scalacheck/scala/reflect/quasiquotes/TypeConstructionProps.scala | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/scalacheck/scala/reflect/quasiquotes/TypeConstructionProps.scala b/test/scalacheck/scala/reflect/quasiquotes/TypeConstructionProps.scala new file mode 100644 index 0000000000..c96018b317 --- /dev/null +++ b/test/scalacheck/scala/reflect/quasiquotes/TypeConstructionProps.scala @@ -0,0 +1,44 @@ +package scala.reflect.quasiquotes + +import org.scalacheck._, Prop._, Gen._, Arbitrary._ +import scala.reflect.runtime.universe._, Flag._, internal.reificationSupport.ScalaDot + +object TypeConstructionProps extends QuasiquoteProperties("type construction") { + property("bare idents contain type names") = test { + tq"x" ≈ Ident(TypeName("x")) + } + + property("unquote type names into AppliedTypeTree") = forAll { (name1: TypeName, name2: TypeName) => + tq"$name1[$name2]" ≈ AppliedTypeTree(Ident(name1), List(Ident(name2))) + } + + property("tuple type") = test { + val empty = List[Tree]() + val ts = List(tq"t1", tq"t2") + assert(tq"(..$empty)" ≈ ScalaDot(TypeName("Unit"))) + assert(tq"(..$ts)" ≈ tq"scala.Tuple2[t1, t2]") + assert(tq"(t0, ..$ts)" ≈ tq"scala.Tuple3[t0, t1, t2]") + } + + property("single-element tuple type") = test { + val ts = q"T" :: Nil + assert(tq"(..$ts)" ≈ ts.head) + } + + property("refined type") = test { + val stats = q"def foo" :: q"val x: Int" :: q"type Y = String" :: Nil + assert(tq"T { ..$stats }" ≈ tq"T { def foo; val x: Int; type Y = String }") + } + + property("function type") = test { + val argtpes = tq"A" :: tq"B" :: Nil + val restpe = tq"C" + assert(tq"..$argtpes => $restpe" ≈ tq"(A, B) => C") + } + + property("empty tq") = test { + val tt: TypeTree = tq"" + assert(tt.tpe == null) + assert(tt.original == null) + } +} |