summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-11 19:22:48 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-18 20:36:17 +0200
commitc8a9329ff9b2a6ea99eef7234c9f84c0bfe0166b (patch)
treeddb01dd1c77344bc1b7768ad7460dd021274faa4 /test/files/scalacheck/quasiquotes/TermConstructionProps.scala
parenta8543ef28f8fc0152208f4eef763344657bf9e5a (diff)
downloadscala-c8a9329ff9b2a6ea99eef7234c9f84c0bfe0166b.tar.gz
scala-c8a9329ff9b2a6ea99eef7234c9f84c0bfe0166b.tar.bz2
scala-c8a9329ff9b2a6ea99eef7234c9f84c0bfe0166b.zip
add syntactic extractor for assignment-like trees
There are three kinds of assign-like trees: 1. Assign(lhs, rhs) // $lhs = $rhs 3. AssignOrNamedArg(lhs, rhs) // $lhs = $rhs 2. Apply(Select(f, nme.update), args :+ rhs) // $f(..$args) = $rhs New syntactic combinator unifies all of them and lets users not to think about these implementations details.
Diffstat (limited to 'test/files/scalacheck/quasiquotes/TermConstructionProps.scala')
-rw-r--r--test/files/scalacheck/quasiquotes/TermConstructionProps.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
index c6cca85c81..753ad1aa59 100644
--- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
@@ -167,4 +167,28 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
val x = q"val x: Int = 1"
assertThrows[IllegalArgumentException] { q"($x) => x" }
}
+
+ property("assign variable") = test {
+ val v = q"v"
+ val value = q"foo"
+ assertEqAst(q"$v = $value", "v = foo")
+ }
+
+ property("assign update 1") = test {
+ val v = q"v"
+ val args = q"1" :: q"2" :: Nil
+ val value = q"foo"
+ assertEqAst(q"$v(..$args) = $value", "v(1, 2) = foo")
+ }
+
+ property("assign update 2") = test {
+ val a = q"v(0)"
+ val value = q"foo"
+ assertEqAst(q"$a = $value", "v(0) = foo")
+ }
+
+ property("assign or named arg") = test {
+ val assignx = q"x = 1"
+ assertEqAst(q"f($assignx)", "f(x = 1)")
+ }
}