summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-10-31 13:50:10 +0100
committerDen Shabalin <den.shabalin@gmail.com>2013-11-12 14:04:42 +0100
commit3b4d8c0c0b71db160c0d031f34274977446e815a (patch)
treee0089da4d0270f1b38e8a10b0cd1d9562bc3b5e6 /test/files/scalacheck/quasiquotes/TypecheckedProps.scala
parent538cc136f5f4595cccf15b4b0f496096ab675c13 (diff)
downloadscala-3b4d8c0c0b71db160c0d031f34274977446e815a.tar.gz
scala-3b4d8c0c0b71db160c0d031f34274977446e815a.tar.bz2
scala-3b4d8c0c0b71db160c0d031f34274977446e815a.zip
add some post-typecheck tests for quasiquotes
Typecheck trees with toolbox and check that they are still matched by corresponding quasiquote. Fix tuples and function types matchers to account for different shape of trees after typing.
Diffstat (limited to 'test/files/scalacheck/quasiquotes/TypecheckedProps.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/TypecheckedProps.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
new file mode 100644
index 0000000000..8e93422e77
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala
@@ -0,0 +1,30 @@
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._, Flag._, build.{Ident => _, _}
+
+object TypecheckedProps extends QuasiquoteProperties("typechecked") {
+ def original(tree: Tree) = tree match {
+ case tt: TypeTree => Some(tt.original)
+ case _ => None
+ }
+ def originals(trees: List[Tree]) = trees.flatMap(original)
+ val int = ScalaDot(TypeName("Int"))
+ val intint = List(int, int)
+
+ property("tuple term") = test {
+ val q"(..$elements)" = typecheck(q"(1, 2)")
+ assert(elements ≈ List(q"1", q"2"))
+ }
+
+ property("tuple type") = test {
+ val tq"(..$els0)" = typecheckTyp(tq"Unit")
+ assert(els0.isEmpty)
+ val tq"(..$els1)" = typecheckTyp(tq"(Int, Int)")
+ assert(originals(els1) ≈ intint)
+ }
+
+ property("function type") = test {
+ val tq"(..$argtpes) => $restpe" = typecheckTyp(tq"(Int, Int) => Int")
+ assert(originals(argtpes) ≈ intint)
+ assert(original(restpe).get ≈ int)
+ }
+} \ No newline at end of file