summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-07-08 20:21:33 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-07-08 21:20:28 +0200
commit7553b0afa9e4a071c7ea1cd51effd57030b66be6 (patch)
tree0bdbf723ecf823e07c942c922d73a9ad768363c2 /test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
parent17719231c615c06eb83f4109f53bfdd948a6fdb1 (diff)
downloadscala-7553b0afa9e4a071c7ea1cd51effd57030b66be6.tar.gz
scala-7553b0afa9e4a071c7ea1cd51effd57030b66be6.tar.bz2
scala-7553b0afa9e4a071c7ea1cd51effd57030b66be6.zip
tests for quasiquotes
Introduces an extensive ScalaCheck-based test suite for recently implemented quasiquotes. Provides tools for syntactic tree comparison and verifying compilation error messages.
Diffstat (limited to 'test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
new file mode 100644
index 0000000000..6ab699d4f0
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
@@ -0,0 +1,29 @@
+import org.scalacheck._
+import Prop._
+import Gen._
+import Arbitrary._
+
+import scala.reflect.runtime.universe._
+import Flag._
+
+object TypeDeconstructionProps extends QuasiquoteProperties("type deconstruction") {
+ property("ident(type name)") = forAll { (name: TypeName) =>
+ val t = Ident(name)
+ val tq"$t1" = t
+ t1 ≈ t
+ }
+
+ property("applied type tree") = forAll { (name1: TypeName, name2: TypeName) =>
+ val tq"$a[$b]" = AppliedTypeTree(Ident(name1), List(Ident(name2)))
+ a ≈ Ident(name1) && b ≈ Ident(name2)
+ }
+
+ property("tuple type") = test {
+ val tq"(..$empty)" = tq"scala.Unit"
+ assert(empty.isEmpty)
+ val tq"(..$ts)" = tq"(t1, t2)"
+ assert(ts ≈ List(tq"t1", tq"t2"))
+ val tq"($head, ..$tail)" = tq"(t0, t1, t2)"
+ assert(head ≈ tq"t0" && tail ≈ List(tq"t1", tq"t2"))
+ }
+} \ No newline at end of file