From 0200375e670b5dcc865c8636faf00ae5e767a81b Mon Sep 17 00:00:00 2001 From: Denys Shabalin Date: Mon, 27 Jan 2014 18:38:39 +0100 Subject: Addresses feedback from Jason 1. Adds tests for new synthetic unit stripping. 2. Marks implementation-specific parts of Holes as private. 3. Trims description of iterated method a bit. 4. Provides a bit more clear wrapper for q interpolator. 5. Refactors SyntacticBlock, adds documentation. 6. Makes q"{ ..$Nil }" return q"" to be consist with extractor. --- .../quasiquotes/TermConstructionProps.scala | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala index 7bbd7a85b3..54187d68c2 100644 --- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala @@ -116,7 +116,7 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { def blockInvariant(quote: Tree, trees: List[Tree]) = quote ≈ (trees match { - case Nil => q"()" + case Nil => q"" case _ :+ last if !last.isTerm => Block(trees, q"()") case head :: Nil => head case init :+ last => Block(init, last) @@ -268,4 +268,27 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { val t = q"{ a; b }; c; d" assertEqAst(q"f(...$t)", "f(a, b)(c)(d)") } + + property("remove synthetic unit") = test { + val q"{ ..$stats1 }" = q"{ def x = 2 }" + assert(stats1 ≈ List(q"def x = 2")) + val q"{ ..$stats2 }" = q"{ class X }" + assert(stats2 ≈ List(q"class X")) + val q"{ ..$stats3 }" = q"{ type X = Int }" + assert(stats3 ≈ List(q"type X = Int")) + val q"{ ..$stats4 }" = q"{ val x = 2 }" + assert(stats4 ≈ List(q"val x = 2")) + } + + property("don't remove user-defined unit") = test { + val q"{ ..$stats }" = q"{ def x = 2; () }" + assert(stats ≈ List(q"def x = 2", q"()")) + } + + property("empty-tree as block") = test { + val q"{ ..$stats1 }" = q" " + assert(stats1.isEmpty) + val stats2 = List.empty[Tree] + assert(q"{ ..$stats2 }" ≈ q"") + } } -- cgit v1.2.3