summaryrefslogtreecommitdiff
path: root/test/files/run/t5733.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-11-28 18:36:47 +0100
committerPaul Phillips <paulp@improving.org>2012-11-29 09:39:21 +0100
commita6941944bf80f660722e9151801776715c3e4ab5 (patch)
treeef0bec6d22cc02af500cc1b88bfd5fd8ded86d22 /test/files/run/t5733.scala
parentdac1488a889ff5952ff85e87ec4acd7d72a74891 (diff)
downloadscala-a6941944bf80f660722e9151801776715c3e4ab5.tar.gz
scala-a6941944bf80f660722e9151801776715c3e4ab5.tar.bz2
scala-a6941944bf80f660722e9151801776715c3e4ab5.zip
Test cases for SI-5726, SI-5733, SI-6320, SI-6551, SI-6722.
All tickets involving selectDynamic fixed by the prior commit. It also fixes SI-6663, but that already has a test case.
Diffstat (limited to 'test/files/run/t5733.scala')
-rw-r--r--test/files/run/t5733.scala53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/files/run/t5733.scala b/test/files/run/t5733.scala
new file mode 100644
index 0000000000..360264e4ed
--- /dev/null
+++ b/test/files/run/t5733.scala
@@ -0,0 +1,53 @@
+import scala.language.dynamics
+
+object A extends Dynamic {
+ var a = "a"
+
+ def selectDynamic(method:String): String = a
+
+ def updateDynamic(method:String)(v:String) { a = v }
+}
+
+class B extends Dynamic {
+ var b = "b"
+
+ def selectDynamic(method:String): String = b
+
+ def updateDynamic(method:String)(v:String) { b = v }
+}
+
+object Test extends App {
+ assert( A.foo == "a" )
+ assert( A.bar == "a" )
+ A.aaa = "aaa"
+ assert( A.bar == "aaa" )
+
+ val b = new B
+ assert( b.foo == "b" )
+ assert( b.bar == "b" )
+ b.bbb = "bbb"
+ assert( b.bar == "bbb" )
+
+ {
+ println("Running ABTest asserts")
+ A.a = "a"
+ (new ABTest).test()
+ }
+
+ println("Done")
+}
+
+class ABTest {
+ def test() {
+ assert( A.foo == "a" )
+ assert( A.bar == "a" )
+ A.aaa = "aaa"
+ assert( A.bar == "aaa" )
+
+ val b = new B
+ assert( b.foo == "b" )
+ assert( b.bar == "b" )
+ b.bbb = "bbb"
+ assert( b.bar == "bbb" )
+ }
+}