summaryrefslogtreecommitdiff
path: root/test/files/run/t6989
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-02-05 00:19:05 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-02-05 21:34:25 +0100
commitb43ae58f312e4769de5a6942b4cb820cd609f31b (patch)
treec1c6241ad28a01082605286245c9a99ade728efb /test/files/run/t6989
parent02ed5fb3bc8d792872223ceecfd8fd0ae089d923 (diff)
downloadscala-b43ae58f312e4769de5a6942b4cb820cd609f31b.tar.gz
scala-b43ae58f312e4769de5a6942b4cb820cd609f31b.tar.bz2
scala-b43ae58f312e4769de5a6942b4cb820cd609f31b.zip
introduces an exhaustive java-to-scala test
Originally composed to accommodate pull request feedback, this test has uncovered a handful of bugs in FromJavaClassCompleter, namely: * SI-7071 non-public ctors get lost * SI-7072 inner classes are read incorrectly I'm leaving the incorrect results of FromJavaClassCompleters in the check file, so that we get notified when something changes there.
Diffstat (limited to 'test/files/run/t6989')
-rw-r--r--test/files/run/t6989/JavaClass_1.java42
-rw-r--r--test/files/run/t6989/Test_2.scala37
2 files changed, 66 insertions, 13 deletions
diff --git a/test/files/run/t6989/JavaClass_1.java b/test/files/run/t6989/JavaClass_1.java
index 61253dfe6f..eb26a08700 100644
--- a/test/files/run/t6989/JavaClass_1.java
+++ b/test/files/run/t6989/JavaClass_1.java
@@ -1,7 +1,41 @@
package foo;
-class JavaClass_1 {
- private int x = 0;
- protected String y = "";
- public float z = 0.0f;
+// Originally composed to accommodate pull request feedback, this test has
+// uncovered a handful of bugs in FromJavaClassCompleter, namely:
+// * SI-7071 non-public ctors get lost
+// * SI-7072 inner classes are read incorrectly
+
+// I'm leaving the incorrect results of FromJavaClassCompleters in the check
+// file, so that we get notified when something changes there.
+
+class PackagePrivateJavaClass {
+ private int privateField = 0;
+ protected int protectedField = 1;
+ public int publicField = 2;
+
+ private static int privateStaticField = 3;
+ protected static int protectedStaticField = 4;
+ public static int publicStaticField = 5;
+
+ private void privateMethod() {}
+ protected void protectedMethod() {}
+ public void publicMethod() {}
+
+ private static void privateStaticMethod() {}
+ protected static void protectedStaticMethod() {}
+ public static void publicStaticMethod() {}
+
+ private PackagePrivateJavaClass() {}
+ protected PackagePrivateJavaClass(int x) {}
+ public PackagePrivateJavaClass(int x, int y) {}
+}
+
+public class JavaClass_1 {
+ private class PrivateJavaClass {}
+ private static class PrivateStaticJavaClass {}
+ protected class ProtectedJavaClass {}
+ private static class ProtectedStaticJavaClass {}
+ public class PublicJavaClass {}
+ public static class PublicStaticJavaClass {}
+ private static int staticField = 0;
} \ No newline at end of file
diff --git a/test/files/run/t6989/Test_2.scala b/test/files/run/t6989/Test_2.scala
index ba88e5cce3..e48e82422d 100644
--- a/test/files/run/t6989/Test_2.scala
+++ b/test/files/run/t6989/Test_2.scala
@@ -1,21 +1,40 @@
import scala.reflect.runtime.universe._
+// Originally composed to accommodate pull request feedback, this test has
+// uncovered a handful of bugs in FromJavaClassCompleter, namely:
+// * SI-7071 non-public ctors get lost
+// * SI-7072 inner classes are read incorrectly
+
+// I'm leaving the incorrect results of FromJavaClassCompleters in the check
+// file, so that we get notified when something changes there.
+
package object foo {
- def test(sym: Symbol) = {
+ def testAll(): Unit = {
+ test(typeOf[foo.PackagePrivateJavaClass].typeSymbol)
+ test(typeOf[foo.PackagePrivateJavaClass].typeSymbol.companionSymbol)
+ test(typeOf[foo.JavaClass_1].typeSymbol)
+ test(typeOf[foo.JavaClass_1].typeSymbol.companionSymbol)
+ }
+
+ def test(sym: Symbol): Unit = {
+ printSymbolDetails(sym)
+ if (sym.isClass || sym.isModule) {
+ sym.typeSignature.declarations.toList.sortBy(_.name.toString) foreach test
+ }
+ }
+
+ def printSymbolDetails(sym: Symbol): Unit = {
+ def stableSignature(sym: Symbol) = sym.typeSignature match {
+ case ClassInfoType(_, _, _) => "ClassInfoType(...)"
+ case tpe => tpe.toString
+ }
println("============")
- println(sym)
+ println(s"sym = $sym, signature = ${stableSignature(sym)}, owner = ${sym.owner}")
println(s"isPrivate = ${sym.isPrivate}")
println(s"isProtected = ${sym.isProtected}")
println(s"isPublic = ${sym.isPublic}")
println(s"privateWithin = ${sym.privateWithin}")
}
-
- def testAll() = {
- test(typeOf[foo.JavaClass_1].typeSymbol)
- test(typeOf[foo.JavaClass_1].declaration(newTermName("x")))
- test(typeOf[foo.JavaClass_1].declaration(newTermName("y")))
- test(typeOf[foo.JavaClass_1].declaration(newTermName("z")))
- }
}
object Test extends App {