diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/static-annot.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t6208.scala | 4 | ||||
-rw-r--r-- | test/files/run/static-annot-repl.check | 32 | ||||
-rw-r--r-- | test/files/run/static-annot-repl.scala | 22 | ||||
-rw-r--r-- | test/files/run/static-annot/field.scala | 13 | ||||
-rw-r--r-- | test/files/run/t6236.check | 2 | ||||
-rw-r--r-- | test/files/run/t6236/file_1.scala | 9 | ||||
-rw-r--r-- | test/files/run/t6236/file_2.scala | 10 |
8 files changed, 96 insertions, 2 deletions
diff --git a/test/files/neg/static-annot.scala b/test/files/neg/static-annot.scala index c6c626d42b..c0b5ed30d8 100644 --- a/test/files/neg/static-annot.scala +++ b/test/files/neg/static-annot.scala @@ -45,3 +45,9 @@ class PrivateProtectedLazy { println(PrivateProtectedLazy.baz) println(PrivateProtectedLazy.bam) } + + +class StaticDef { + // this should not crash the compiler + @static def x = 42 +} diff --git a/test/files/pos/t6208.scala b/test/files/pos/t6208.scala new file mode 100644 index 0000000000..dac571346d --- /dev/null +++ b/test/files/pos/t6208.scala @@ -0,0 +1,4 @@ +object Test { + val col = collection.mutable.Queue(1,2,3) + val WORK: collection.mutable.Queue[Int] = col filterNot (_ % 2 == 0) +} diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check new file mode 100644 index 0000000000..d1029a9809 --- /dev/null +++ b/test/files/run/static-annot-repl.check @@ -0,0 +1,32 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import annotation.static +import annotation.static + +scala> @static var x1 = 42 +x1: Int = 42 + +scala> @static val x2 = 43 +x2: Int = 43 + +scala> @static def x3 = 44 +x3: Int + +scala> x1 +res0: Int = 42 + +scala> x2 +res1: Int = 43 + +scala> x3 +res2: Int = 44 + +scala> class Test { + @static def x = 42 +} +defined class Test + +scala>
\ No newline at end of file diff --git a/test/files/run/static-annot-repl.scala b/test/files/run/static-annot-repl.scala new file mode 100644 index 0000000000..1d2e9b2d7e --- /dev/null +++ b/test/files/run/static-annot-repl.scala @@ -0,0 +1,22 @@ + + + +import scala.tools.partest.ReplTest + + + +object Test extends ReplTest { + def code = """ +import annotation.static +@static var x1 = 42 +@static val x2 = 43 +@static def x3 = 44 +x1 +x2 +x3 +class Test { + @static def x = 42 +} +""" + +} diff --git a/test/files/run/static-annot/field.scala b/test/files/run/static-annot/field.scala index a7d8158321..8408a51800 100644 --- a/test/files/run/static-annot/field.scala +++ b/test/files/run/static-annot/field.scala @@ -23,8 +23,10 @@ class Foo trait Check { def checkStatic(cls: Class[_]) { cls.getDeclaredFields.find(_.getName == "bar") match { - case Some(f) => assert(Modifier.isStatic(f.getModifiers), "no static modifier") - case None => assert(false, "no static field bar in class") + case Some(f) => + assert(Modifier.isStatic(f.getModifiers), "no static modifier") + case None => + assert(false, "no static field bar in class") } } @@ -170,6 +172,10 @@ object Foo7 { @static val bar = "string" } class AndHisFriend + + object AndHisLonelyFriend { + @static val bar = "another" + } } @@ -177,6 +183,9 @@ object Test7 extends Check { def test() { checkStatic(classOf[Foo7.AndHisFriend]) assert(Foo7.AndHisFriend.bar == "string") + + checkStatic(Class.forName("Foo7$AndHisLonelyFriend")) + assert(Foo7.AndHisLonelyFriend.bar == "another") } } diff --git a/test/files/run/t6236.check b/test/files/run/t6236.check new file mode 100644 index 0000000000..a0a2e88d0a --- /dev/null +++ b/test/files/run/t6236.check @@ -0,0 +1,2 @@ +353 +353
\ No newline at end of file diff --git a/test/files/run/t6236/file_1.scala b/test/files/run/t6236/file_1.scala new file mode 100644 index 0000000000..92d22799fc --- /dev/null +++ b/test/files/run/t6236/file_1.scala @@ -0,0 +1,9 @@ + + +package p { + object y { + object x { + @scala.annotation.static val foo: Int = 353 + } + } +} diff --git a/test/files/run/t6236/file_2.scala b/test/files/run/t6236/file_2.scala new file mode 100644 index 0000000000..51823004ca --- /dev/null +++ b/test/files/run/t6236/file_2.scala @@ -0,0 +1,10 @@ + + + +object Test { + def main(args: Array[String]): Unit = { + println(p.y.x.foo) + println(p.y.x.foo) + } +} + |