summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
diff options
context:
space:
mode:
authorDenys Shabalin <denys.shabalin@typesafe.com>2014-02-01 19:25:16 +0100
committerDenys Shabalin <denys.shabalin@typesafe.com>2014-02-02 18:19:47 +0100
commitffc3203c3688b6fc5f47f4043bf3a0090de9d985 (patch)
treee64965cedf021c14144c4f51fb055a60ecf66342 /test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
parent1a3de955b824aa4d946467c5b207133b6839b17d (diff)
downloadscala-ffc3203c3688b6fc5f47f4043bf3a0090de9d985.tar.gz
scala-ffc3203c3688b6fc5f47f4043bf3a0090de9d985.tar.bz2
scala-ffc3203c3688b6fc5f47f4043bf3a0090de9d985.zip
SI-8173 add support for patterns like init :+ last to quasiquotes
Adds support for patterns like: val q"{ ..$init; $last }" = q"{ a; b; c }" // init == List(q"a", q"b") // last == q"c" Which under the hood get compiled as `:+` patterns: SyntacticBlock(init :+ last)
Diffstat (limited to 'test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala32
1 files changed, 26 insertions, 6 deletions
diff --git a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
index 499f5d6d8e..44f110a3d5 100644
--- a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
@@ -13,23 +13,43 @@ object TypeDeconstructionProps extends QuasiquoteProperties("type deconstruction
a ≈ Ident(name1) && b ≈ Ident(name2)
}
- property("tuple type") = test {
+ property("tuple type (1)") = test {
val tq"(..$empty)" = tq"_root_.scala.Unit"
assert(empty.isEmpty)
+ }
+
+ property("tuple type (2)") = test {
val tq"(..$ts)" = tq"(t1, t2)"
assert(ts ≈ List(tq"t1", tq"t2"))
+ }
+
+ property("tuple type (3)") = test {
val tq"($head, ..$tail)" = tq"(t0, t1, t2)"
- assert(head ≈ tq"t0" && tail ≈ List(tq"t1", tq"t2"))
+ assert(head ≈ tq"t0")
+ assert(tail ≈ List(tq"t1", tq"t2"))
+ }
+
+ property("tuple type (4)") = test {
+ val tq"(..$init, $last)" = tq"(t0, t1, t2)"
+ assert(init ≈ List(tq"t0", tq"t1"))
+ assert(last ≈ tq"t2")
}
property("refined type") = test {
val tq"T { ..$stats }" = tq"T { def foo; val x: Int; type Y = String }"
- assert(stats ≈ (q"def foo" :: q"val x: Int" :: q"type Y = String" :: Nil))
+ assert(stats ≈ List(q"def foo", q"val x: Int", q"type Y = String"))
}
- property("function type") = test {
+ property("function type (1)") = test {
val tq"..$argtpes => $restpe" = tq"(A, B) => C"
- assert(argtpes ≈ (tq"A" :: tq"B" :: Nil))
+ assert(argtpes ≈ List(tq"A", tq"B"))
assert(restpe ≈ tq"C")
}
-} \ No newline at end of file
+
+ property("function type (2)") = test {
+ val tq"(..$argtpes, $arglast) => $restpe" = tq"(A, B, C) => D"
+ assert(argtpes ≈ List(tq"A", tq"B"))
+ assert(arglast ≈ tq"C")
+ assert(restpe ≈ tq"D")
+ }
+}