summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-02 16:01:38 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-05 20:42:09 +0200
commit1352fea1c4ecfa0fd66ff1d5ad6e0ee437b1a59f (patch)
treec66d11c9b21a29a7601fedb4d8ad163dad0fa5cf /test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
parent73a4f172c3b4f2c7d8bf9936898f031d09899cef (diff)
downloadscala-1352fea1c4ecfa0fd66ff1d5ad6e0ee437b1a59f.tar.gz
scala-1352fea1c4ecfa0fd66ff1d5ad6e0ee437b1a59f.tar.bz2
scala-1352fea1c4ecfa0fd66ff1d5ad6e0ee437b1a59f.zip
first-class early def splicing and extraction support
Diffstat (limited to 'test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala45
1 files changed, 43 insertions, 2 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
index 31d230d6fd..d6b60c4351 100644
--- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala
@@ -15,11 +15,32 @@ object DefinitionDeconstructionProps
with ValVarDeconstruction
trait TraitDeconstruction { self: QuasiquoteProperties =>
-
+ property("exhaustive trait matcher") = test {
+ def matches(line: String) {
+ val q"""$mods trait $name[..$targs]
+ extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line)
+ }
+ matches("trait Foo")
+ matches("trait Foo[T]")
+ matches("trait Foo { def bar }")
+ matches("trait Foo extends Bar with Baz")
+ matches("trait Foo { self: Bippy => val x: Int = 1}")
+ matches("trait Foo extends { val early: Int = 1 } with Bar { val late = early }")
+ matches("private[Gap] trait Foo")
+ }
}
trait ObjectDeconstruction { self: QuasiquoteProperties =>
-
+ property("exhaustive object matcher") = test {
+ def matches(line: String) = {
+ val q"""$mods object $name extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line)
+ }
+ matches("object Foo")
+ matches("object Foo extends Bar[T]")
+ matches("object Foo extends { val early: T = v } with Bar")
+ matches("object Foo extends Foo { selfy => body }")
+ matches("private[Bippy] object Foo extends Bar with Baz")
+ }
}
trait ClassDeconstruction { self: QuasiquoteProperties =>
@@ -51,6 +72,26 @@ trait ClassDeconstruction { self: QuasiquoteProperties =>
property("deconstruct bare case class") = test {
val q"$mods class $name(..$args) extends ..$parents" = q"case class Foo(x: Int)"
}
+
+ property("exhaustive class matcher") = test {
+ def matches(line: String) {
+ val q"""$classMods class $name[..$targs] $ctorMods(...$argss)
+ extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line)
+ }
+ matches("class Foo")
+ matches("class Foo[T]")
+ matches("class Foo[T] @annot")
+ matches("class Foo extends Bar with Baz")
+ matches("class Foo { body }")
+ matches("class Foo extends { val early = 0 } with Any")
+ matches("abstract class Foo")
+ matches("private[Baz] class Foo")
+ matches("class Foo(first: A)(second: B)")
+ matches("class Foo(first: A) extends Bar(first) with Baz")
+ matches("class Foo private (first: A) { def bar }")
+ matches("class Foo { self => bar(self) }")
+ matches("case class Foo(x: Int)")
+ }
}
trait ModsDeconstruction { self: QuasiquoteProperties =>