diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-09-20 13:32:38 +0200 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-10-14 13:30:49 +0200 |
commit | 3a148cd0cd404751095cd1c5aca09ad8923c51ab (patch) | |
tree | 2ad3cbc115fe0ca270d476171b41519c483ba201 /test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala | |
parent | d7aae49f8ff7ccc6c1a588fc116e8c37fdb9e849 (diff) | |
download | scala-3a148cd0cd404751095cd1c5aca09ad8923c51ab.tar.gz scala-3a148cd0cd404751095cd1c5aca09ad8923c51ab.tar.bz2 scala-3a148cd0cd404751095cd1c5aca09ad8923c51ab.zip |
SI-6841 SI-6657 add support for packages into quasiquotes and toolbox
In order to implement this a new parser entry point
`parseStatsOrPackages` that augments current parseStats with ability
to parse "package name { ... }" syntax.
Diffstat (limited to 'test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala')
-rw-r--r-- | test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala index fdfbfe871c..993ef899b0 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala @@ -13,6 +13,7 @@ object DefinitionDeconstructionProps with ObjectDeconstruction with ModsDeconstruction with ValVarDeconstruction + with PackageDeconstruction trait TraitDeconstruction { self: QuasiquoteProperties => property("exhaustive trait matcher") = test { @@ -144,4 +145,27 @@ trait ValVarDeconstruction { self: QuasiquoteProperties => matches("var x = 1") assertThrows[MatchError] { matches("val x = 1") } } +} + +trait PackageDeconstruction { self: QuasiquoteProperties => + property("exhaustive package matcher") = test { + def matches(line: String) { val q"package $name { ..$body }" = parse(line) } + matches("package foo { }") + matches("package foo { class C }") + matches("package foo.bar { }") + matches("package bippy.bongo { object A; object B }") + matches("package bippy { package bongo { object O } }") + } + + property("exhaustive package object matcher") = test { + def matches(line: String) { + val q"package object $name extends { ..$early } with ..$parents { $self => ..$body }" = parse(line) + } + matches("package object foo") + matches("package object foo { def baz }") + matches("package object foo { self => }") + matches("package object foo extends mammy with daddy { def baz }") + matches("package object foo extends { val early = 1 } with daddy") + assertThrows[MatchError] { matches("object foo") } + } }
\ No newline at end of file |