summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-02 15:51:56 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-05 14:39:12 +0200
commit901cdc1855e8e80957b18add4991736b9f458d77 (patch)
treeb6ac94c657f262d3a4e398e36b07d042ba4fbfa1 /test/files/scalacheck/quasiquotes/TermConstructionProps.scala
parentf9d5e3d4e8cca61ee75072ab13c2935061a1850e (diff)
downloadscala-901cdc1855e8e80957b18add4991736b9f458d77.tar.gz
scala-901cdc1855e8e80957b18add4991736b9f458d77.tar.bz2
scala-901cdc1855e8e80957b18add4991736b9f458d77.zip
refine block and applied/typeapplied splicing/matching semantics
1. blocks now match single term-level expressions to account for automatic block elimination. E.g. val q"{ ..$stats }" = q"foo" will match into stats = List(q"foo"). This is useful to uniformly deal with blocks on term level. 2. blocks in quasiquotes collapse into single expressions 3. Applied and TypeApplied now have constructors too which helps to unify matching and extraction in quasiquote reifier 4. TypeApplied now matches AppliedTypeTree too 5. Add Syntactic prefix to Applied and TypeApplied
Diffstat (limited to 'test/files/scalacheck/quasiquotes/TermConstructionProps.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/TermConstructionProps.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
index 5a765f7911..599dfd442a 100644
--- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
@@ -88,7 +88,7 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
}
property("splice trees into type apply") = forAll { (fun: TreeIsTerm, types: List[Tree]) =>
- q"$fun[..$types]" ≈ TypeApply(fun, types)
+ q"$fun[..$types]" ≈ (if (types.nonEmpty) TypeApply(fun, types) else fun)
}
property("splice names into import selector") = forAll {
@@ -122,8 +122,10 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
def blockInvariant(quote: Tree, trees: List[Tree]) =
quote ≈ (trees match {
- case Nil => Block(Nil, q"()")
- case _ => Block(trees.init, trees.last)
+ case Nil => q"()"
+ case _ :+ last if !last.isTerm => Block(trees, q"()")
+ case head :: Nil => head
+ case init :+ last => Block(init, last)
})
property("splice list of trees into block (1)") = forAll { (trees: List[Tree]) =>