summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/QuasiquoteProperties.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/QuasiquoteProperties.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/QuasiquoteProperties.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
index 6a531071bf..2286bb3a0a 100644
--- a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
+++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
@@ -18,8 +18,8 @@ trait Helpers {
* if no exception has been thrown while executing code
* block. This is useful for simple one-off tests.
*/
- def test[T](block: => T)=
- Prop { (params) =>
+ def test[T](block: => T) =
+ Prop { params =>
block
Result(Prop.Proof)
}
@@ -68,6 +68,18 @@ trait Helpers {
val compile = toolbox.compile(_)
val eval = toolbox.eval(_)
+ def typecheck(tree: Tree) = toolbox.typeCheck(tree)
+
+ def typecheckTyp(tree: Tree) = {
+ val q"type $_ = $res" = typecheck(q"type T = $tree")
+ res
+ }
+
+ def typecheckPat(tree: Tree) = {
+ val q"$_ match { case $res => }" = typecheck(q"((): Any) match { case $tree => }")
+ res
+ }
+
def fails(msg: String, block: String) = {
def result(ok: Boolean, description: String = "") = {
val status = if (ok) Prop.Proof else Prop.False