From 8cc477f8b6fd81c45fe30ac454c021a9769911ad Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Sun, 7 Jun 2009 11:13:47 +0000 Subject: fixed BeanProperty, added BooleanBeanProperty, ... fixed BeanProperty, added BooleanBeanProperty, added many tests (#1029, #1751, #294, #1942, #1782, #1788, #637). --- test/files/pos/annotations.scala | 50 +++++++++++++++++++++++++++++++++ test/files/pos/t1029/Test_1.scala | 7 +++++ test/files/pos/t1029/Test_2.scala | 3 ++ test/files/pos/t1751/A1_2.scala | 2 ++ test/files/pos/t1751/A2_1.scala | 2 ++ test/files/pos/t1751/SuiteClasses.java | 3 ++ test/files/pos/t1782/ImplementedBy.java | 3 ++ test/files/pos/t1782/Test_1.scala | 10 +++++++ test/files/pos/t1942/A_1.scala | 11 ++++++++ test/files/pos/t1942/Test_2.scala | 3 ++ test/files/pos/t294/Ann.java | 3 ++ test/files/pos/t294/Ann2.java | 3 ++ test/files/pos/t294/Test_1.scala | 7 +++++ test/files/pos/t294/Test_2.scala | 1 + 14 files changed, 108 insertions(+) create mode 100644 test/files/pos/t1029/Test_1.scala create mode 100644 test/files/pos/t1029/Test_2.scala create mode 100644 test/files/pos/t1751/A1_2.scala create mode 100644 test/files/pos/t1751/A2_1.scala create mode 100644 test/files/pos/t1751/SuiteClasses.java create mode 100644 test/files/pos/t1782/ImplementedBy.java create mode 100644 test/files/pos/t1782/Test_1.scala create mode 100644 test/files/pos/t1942/A_1.scala create mode 100644 test/files/pos/t1942/Test_2.scala create mode 100644 test/files/pos/t294/Ann.java create mode 100644 test/files/pos/t294/Ann2.java create mode 100644 test/files/pos/t294/Test_1.scala create mode 100644 test/files/pos/t294/Test_2.scala (limited to 'test/files/pos') diff --git a/test/files/pos/annotations.scala b/test/files/pos/annotations.scala index 9f780c0094..5492d89351 100644 --- a/test/files/pos/annotations.scala +++ b/test/files/pos/annotations.scala @@ -22,5 +22,55 @@ object Test { // bug #1070 trait T { @BeanProperty var field = 1 } + + // annotation on annotation constructor + @(ann @ann(100))(200) def foo() = 300 +} + +// test forward references to getters / setters +class BeanPropertyTests { + @scala.reflect.BeanProperty lazy val lv1 = 0 + + def foo() { + val bp1 = new BeanPropertyTests1 + + println(lv1) + println(getLv1()) + println(bp1.getLv2()) + + println(getV1()) + setV1(10) + bp1.setV2(100) + } + + @scala.reflect.BeanProperty var v1 = 0 + } +class BeanPropertyTests1 { + @scala.reflect.BeanProperty lazy val lv2 = "0" + @scala.reflect.BeanProperty var v2 = 0 +} + +// test mixin of getters / setters, and implementing abstract +// methods using @BeanProperty +class C extends T with BeanF { + def foo() { + setF("doch!") + setG(true) + this.getF() + } +} + +trait T { + @scala.reflect.BeanProperty var f = "nei" + @scala.reflect.BooleanBeanProperty var g = false +} + +trait BeanF { + def getF(): String + def setF(n: String): Unit + + def isG(): Boolean + def setG(nb: Boolean): Unit +} diff --git a/test/files/pos/t1029/Test_1.scala b/test/files/pos/t1029/Test_1.scala new file mode 100644 index 0000000000..e828087f2c --- /dev/null +++ b/test/files/pos/t1029/Test_1.scala @@ -0,0 +1,7 @@ +class ann(a: Array[Int]) extends StaticAnnotation + +object Test1 { + // bug #1029 + @ann(Array(10, 2)) def u = () + val v: String @ann(Array(13, 2)) = "-1" +} diff --git a/test/files/pos/t1029/Test_2.scala b/test/files/pos/t1029/Test_2.scala new file mode 100644 index 0000000000..00589052cb --- /dev/null +++ b/test/files/pos/t1029/Test_2.scala @@ -0,0 +1,3 @@ +object Test { + val t = Test1 +} diff --git a/test/files/pos/t1751/A1_2.scala b/test/files/pos/t1751/A1_2.scala new file mode 100644 index 0000000000..354d5eecd0 --- /dev/null +++ b/test/files/pos/t1751/A1_2.scala @@ -0,0 +1,2 @@ +@SuiteClasses(Array(classOf[A2])) +class A1 diff --git a/test/files/pos/t1751/A2_1.scala b/test/files/pos/t1751/A2_1.scala new file mode 100644 index 0000000000..c768062e43 --- /dev/null +++ b/test/files/pos/t1751/A2_1.scala @@ -0,0 +1,2 @@ +@SuiteClasses(Array()) +class A2 diff --git a/test/files/pos/t1751/SuiteClasses.java b/test/files/pos/t1751/SuiteClasses.java new file mode 100644 index 0000000000..9f09021c5a --- /dev/null +++ b/test/files/pos/t1751/SuiteClasses.java @@ -0,0 +1,3 @@ +public @interface SuiteClasses { + public Class[] value(); +} \ No newline at end of file diff --git a/test/files/pos/t1782/ImplementedBy.java b/test/files/pos/t1782/ImplementedBy.java new file mode 100644 index 0000000000..6aa8b4fa9e --- /dev/null +++ b/test/files/pos/t1782/ImplementedBy.java @@ -0,0 +1,3 @@ +public @interface ImplementedBy { + public Class value(); +} diff --git a/test/files/pos/t1782/Test_1.scala b/test/files/pos/t1782/Test_1.scala new file mode 100644 index 0000000000..de4f0e9886 --- /dev/null +++ b/test/files/pos/t1782/Test_1.scala @@ -0,0 +1,10 @@ +@ImplementedBy(classOf[Provider]) +trait Service { + def someMethod() +} + +class Provider + extends Service +{ + def someMethod() = () +} diff --git a/test/files/pos/t1942/A_1.scala b/test/files/pos/t1942/A_1.scala new file mode 100644 index 0000000000..19a7575a0a --- /dev/null +++ b/test/files/pos/t1942/A_1.scala @@ -0,0 +1,11 @@ +class A { + def foo(x: Int) = 0 + def foo(x: String) = 1 +} + +class ann(x: Int) extends StaticAnnotation + +class t { + val a = new A + @ann(a.foo(1)) def bar = 1 +} diff --git a/test/files/pos/t1942/Test_2.scala b/test/files/pos/t1942/Test_2.scala new file mode 100644 index 0000000000..6c045bbce5 --- /dev/null +++ b/test/files/pos/t1942/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + println(new t) +} diff --git a/test/files/pos/t294/Ann.java b/test/files/pos/t294/Ann.java new file mode 100644 index 0000000000..934ca46297 --- /dev/null +++ b/test/files/pos/t294/Ann.java @@ -0,0 +1,3 @@ +public @interface Ann { + public Ann2[] nested(); +} diff --git a/test/files/pos/t294/Ann2.java b/test/files/pos/t294/Ann2.java new file mode 100644 index 0000000000..958cf1ab76 --- /dev/null +++ b/test/files/pos/t294/Ann2.java @@ -0,0 +1,3 @@ +public @interface Ann2 { + public int value(); +} \ No newline at end of file diff --git a/test/files/pos/t294/Test_1.scala b/test/files/pos/t294/Test_1.scala new file mode 100644 index 0000000000..ff1f34b10e --- /dev/null +++ b/test/files/pos/t294/Test_1.scala @@ -0,0 +1,7 @@ +// also test pickling of java annotations; Test_2.scala will +// read this class file +@Ann(nested = Array(new Ann2(10))) class Test { + @Ann2(100) var ctx: Object = _ + @Ann(nested = Array()) def foo = 10 + @Ann(nested = Array(new Ann2(10), new Ann2(23))) val bam = -3 +} diff --git a/test/files/pos/t294/Test_2.scala b/test/files/pos/t294/Test_2.scala new file mode 100644 index 0000000000..9fb1c6e175 --- /dev/null +++ b/test/files/pos/t294/Test_2.scala @@ -0,0 +1 @@ +class Test2 extends Test -- cgit v1.2.3