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/PatternConstructionProps.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/PatternConstructionProps.scala')
-rw-r--r-- | test/files/scalacheck/quasiquotes/PatternConstructionProps.scala | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala new file mode 100644 index 0000000000..aee50c9c5f --- /dev/null +++ b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +import scala.reflect.runtime.universe._ +import Flag._ + +object PatternConstructionProps extends QuasiquoteProperties("pattern construction") { + property("splice bind") = forAll { (bind: Bind) => + pq"$bind" ≈ bind + } + + property("splice name into bind") = forAll { (name: TermName) => + pq"$name" ≈ Bind(name, Ident(nme.WILDCARD)) + } + + property("splice name and tree into bind") = forAll { (name: TermName, tree: Tree) => + pq"$name @ $tree" ≈ Bind(name, tree) + } + + property("splice type name into typed") = forAll { (name: TypeName) => + pq"_ : $name" ≈ Typed(Ident(nme.WILDCARD), Ident(name)) + } + + property("splice tree into typed") = forAll { (typ: Tree) => + pq"_ : $typ" ≈ Typed(Ident(nme.WILDCARD), typ) + } + + property("splice into apply") = forAll { (pat: Tree, subpat: Tree) => + pq"$pat($subpat)" ≈ Apply(pat, List(subpat)) + } + + property("splice into casedef") = forAll { (pat: Tree, cond: Tree, body: Tree) => + cq"$pat if $cond => $body" ≈ CaseDef(pat, cond, Block(List(), body)) + } +}
\ No newline at end of file |