diff options
author | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-02-11 15:01:03 +0100 |
---|---|---|
committer | Denys Shabalin <denys.shabalin@typesafe.com> | 2014-02-11 15:12:00 +0100 |
commit | aceb0f31e84fe04244f5899f3d82630a5f56f835 (patch) | |
tree | 761eeba1c08425e4a7faae07f2ccf0c91097b03e /test/files/scalacheck | |
parent | d4f5abf9002fd617e871d1f20fdcf531b38b26e1 (diff) | |
download | scala-aceb0f31e84fe04244f5899f3d82630a5f56f835.tar.gz scala-aceb0f31e84fe04244f5899f3d82630a5f56f835.tar.bz2 scala-aceb0f31e84fe04244f5899f3d82630a5f56f835.zip |
Tweak parser entry point for pq
Previously pq used pattern1 which required parens to be used in
alternative pattern. This commit tweaks it to allow pq"a | b"
syntax. Also adds some tests for alternative syntax.
Diffstat (limited to 'test/files/scalacheck')
-rw-r--r-- | test/files/scalacheck/quasiquotes/PatternConstructionProps.scala | 6 | ||||
-rw-r--r-- | test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala index 582e915258..ca4c8609ac 100644 --- a/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/PatternConstructionProps.scala @@ -29,4 +29,8 @@ object PatternConstructionProps extends QuasiquoteProperties("pattern constructi property("splice into casedef") = forAll { (pat: Tree, cond: Tree, body: Tree) => cq"$pat if $cond => $body" ≈ CaseDef(pat, cond, body) } -}
\ No newline at end of file + + property("splice into alternative") = forAll { (first: Tree, rest: List[Tree]) => + pq"$first | ..$rest" ≈ Alternative(first :: rest) + } +} diff --git a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala index c8e66c7ef5..ad3266bcec 100644 --- a/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/PatternDeconstructionProps.scala @@ -36,4 +36,9 @@ object PatternDeconstructionProps extends QuasiquoteProperties("pattern deconstr val cq"$pat0 if $cond0 => $body0" = cq"$pat if $cond => $body" pat0 ≈ pat && cond0 ≈ cond && body0 ≈ body } + + property("extract alternative") = forAll { (first: Tree, rest: List[Tree]) => + val pq"$first1 | ..$rest1" = pq"$first | ..$rest" + first1 ≈ first && rest1 ≈ rest + } } |