diff options
author | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-01-27 18:38:39 +0100 |
---|---|---|
committer | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-01-27 18:38:39 +0100 |
commit | 0200375e670b5dcc865c8636faf00ae5e767a81b (patch) | |
tree | fc71059e69b0fc96d16459935e1fb3f4370bcd04 /test/files/scalacheck/quasiquotes | |
parent | 30748571d44f604917eeef834a4aa4f7c2c1425e (diff) | |
download | scala-0200375e670b5dcc865c8636faf00ae5e767a81b.tar.gz scala-0200375e670b5dcc865c8636faf00ae5e767a81b.tar.bz2 scala-0200375e670b5dcc865c8636faf00ae5e767a81b.zip |
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.
Diffstat (limited to 'test/files/scalacheck/quasiquotes')
-rw-r--r-- | test/files/scalacheck/quasiquotes/TermConstructionProps.scala | 25 |
1 files changed, 24 insertions, 1 deletions
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"") + } } |