diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-07-08 20:21:33 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-07-08 21:20:28 +0200 |
commit | 7553b0afa9e4a071c7ea1cd51effd57030b66be6 (patch) | |
tree | 0bdbf723ecf823e07c942c922d73a9ad768363c2 /test/files/scalacheck/quasiquotes/LiftableProps.scala | |
parent | 17719231c615c06eb83f4109f53bfdd948a6fdb1 (diff) | |
download | scala-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/LiftableProps.scala')
-rw-r--r-- | test/files/scalacheck/quasiquotes/LiftableProps.scala | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/LiftableProps.scala b/test/files/scalacheck/quasiquotes/LiftableProps.scala new file mode 100644 index 0000000000..510ab99068 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/LiftableProps.scala @@ -0,0 +1,84 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object LiftableProps extends QuasiquoteProperties("liftable") { + property("splice byte") = test { + val c: Byte = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice short") = test { + val c: Short = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice char") = test { + val c: Char = 'c' + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice int") = test { + val c: Int = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice long") = test { + val c: Long = 0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice float") = test { + val c: Float = 0.0f + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice double") = test { + val c: Double = 0.0 + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice boolean") = test { + val c: Boolean = false + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice string") = test { + val c: String = "s" + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("splice unit") = test { + val c: Unit = () + assert(q"$c" ≈ Literal(Constant(c))) + } + + property("lift symbol") = test { + val s = rootMirror.staticClass("scala.Int") + assert(q"$s" ≈ Ident(s)) + } + + property("lift type") = test { + val tpe = rootMirror.staticClass("scala.Int").toType + assert(q"$tpe" ≈ TypeTree(tpe)) + } + + property("lift type tag") = test { + val tag = TypeTag.Int + assert(q"$tag" ≈ TypeTree(tag.tpe)) + } + + property("lift weak type tag") = test { + val tag = WeakTypeTag.Int + assert(q"$tag" ≈ TypeTree(tag.tpe)) + } + + property("lift constant") = test { + val const = Constant(0) + assert(q"$const" ≈ q"0") + } +}
\ No newline at end of file |