summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-03-01 09:32:20 -0500
committerEugene Burmako <xeno.by@gmail.com>2014-03-01 09:32:20 -0500
commit6b63bb82ab66751a42fac496846384deb932fe00 (patch)
tree132b627320413ccc6af9eeb3949d60d195d61e70 /test/files
parentfabc9f1424824975943241b9bb2c9b7669f805bd (diff)
parentfae2912a60b33f6866a87d30a4e698e433939dc7 (diff)
downloadscala-6b63bb82ab66751a42fac496846384deb932fe00.tar.gz
scala-6b63bb82ab66751a42fac496846384deb932fe00.tar.bz2
scala-6b63bb82ab66751a42fac496846384deb932fe00.zip
Merge pull request #3591 from densh/si/8275
SI-8275 allow to directly extract block contents of the case def
Diffstat (limited to 'test/files')
-rw-r--r--test/files/scalacheck/quasiquotes/TermConstructionProps.scala19
-rw-r--r--test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala24
2 files changed, 37 insertions, 6 deletions
diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
index 10ce1604b1..fd4d2e9c4b 100644
--- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
@@ -103,7 +103,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)
@@ -277,11 +277,18 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
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"")
+ property("empty-tree is not a block") = test {
+ assertThrows[MatchError] {
+ val q"{ ..$stats1 }" = q" "
+ }
+ }
+
+ property("empty block is synthetic unit") = test {
+ val q"()" = q"{}"
+ val q"{..$stats}" = q"{}"
+ assert(stats.isEmpty)
+ assertEqAst(q"{..$stats}", "{}")
+ assertEqAst(q"{..$stats}", "()")
}
property("consistent variable order") = test {
diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
index 7c9b5ead20..e96d1186f7 100644
--- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
@@ -175,4 +175,28 @@ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction
assert(x ≈ q"x")
val q"{ _ * _ }" = q"{ _ * _ }"
}
+
+ property("si-8275 a") = test {
+ val cq"_ => ..$stats" = cq"_ => foo; bar"
+ assert(stats ≈ List(q"foo", q"bar"))
+ }
+
+ property("si-8275 b") = test {
+ val cq"_ => ..$init; $last" = cq"_ => a; b; c"
+ assert(init ≈ List(q"a", q"b"))
+ assert(last ≈ q"c")
+ }
+
+ property("si-8275 c") = test {
+ val cq"_ => ..$stats" = cq"_ =>"
+ assert(stats.isEmpty)
+ assertEqAst(q"{ case _ => ..$stats }", "{ case _ => }")
+ }
+
+ property("can't flatten type into block") = test {
+ assertThrows[IllegalArgumentException] {
+ val tpt = tq"List[Int]"
+ q"..$tpt; ()"
+ }
+ }
}