From 3b4d8c0c0b71db160c0d031f34274977446e815a Mon Sep 17 00:00:00 2001 From: Den Shabalin Date: Thu, 31 Oct 2013 13:50:10 +0100 Subject: 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. --- .../scalacheck/quasiquotes/TypecheckedProps.scala | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/files/scalacheck/quasiquotes/TypecheckedProps.scala (limited to 'test/files/scalacheck/quasiquotes/TypecheckedProps.scala') 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 -- cgit v1.2.3