diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-11-30 14:58:01 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 14:58:01 +1000 |
commit | 0339663cbbd4d22b0758257f2ce078b5a007f316 (patch) | |
tree | 75b5cb23e987dddefb227545d4e1028c487c8b78 /test/files | |
parent | 711e261717c37dcc56e4f67230a4e8b4f5500700 (diff) | |
parent | 31723573b3a25cd27f2b5c1079dfb04c5b10910a (diff) | |
download | scala-0339663cbbd4d22b0758257f2ce078b5a007f316.tar.gz scala-0339663cbbd4d22b0758257f2ce078b5a007f316.tar.bz2 scala-0339663cbbd4d22b0758257f2ce078b5a007f316.zip |
Merge pull request #5562 from retronym/ticket/SD-275
SD-275 Further harden against refs to absentee classes
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/sd275-java/A.java | 5 | ||||
-rw-r--r-- | test/files/run/sd275-java/DeleteMe.java | 4 | ||||
-rw-r--r-- | test/files/run/sd275-java/LeaveMe.java | 3 | ||||
-rw-r--r-- | test/files/run/sd275-java/Test.scala | 39 | ||||
-rw-r--r-- | test/files/run/sd275.scala | 60 |
5 files changed, 111 insertions, 0 deletions
diff --git a/test/files/run/sd275-java/A.java b/test/files/run/sd275-java/A.java new file mode 100644 index 0000000000..b293cf6dab --- /dev/null +++ b/test/files/run/sd275-java/A.java @@ -0,0 +1,5 @@ +package sample; +public class A { + public void irrelevant(p1.p2.p3.DeleteMe arg) {} + public static class A_Inner {} +} diff --git a/test/files/run/sd275-java/DeleteMe.java b/test/files/run/sd275-java/DeleteMe.java new file mode 100644 index 0000000000..ccff2951d0 --- /dev/null +++ b/test/files/run/sd275-java/DeleteMe.java @@ -0,0 +1,4 @@ +package p1.p2.p3; + +public class DeleteMe {} + diff --git a/test/files/run/sd275-java/LeaveMe.java b/test/files/run/sd275-java/LeaveMe.java new file mode 100644 index 0000000000..cb58f0080f --- /dev/null +++ b/test/files/run/sd275-java/LeaveMe.java @@ -0,0 +1,3 @@ +package p1; + +public class LeaveMe {} diff --git a/test/files/run/sd275-java/Test.scala b/test/files/run/sd275-java/Test.scala new file mode 100644 index 0000000000..84187527d2 --- /dev/null +++ b/test/files/run/sd275-java/Test.scala @@ -0,0 +1,39 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def show(): Unit = { + deletePackage("p1/p2/p3") + deletePackage("p1/p2") + + compileCode(""" +package sample + +class Test { + final class Inner extends A.A_Inner { + def foo = 42 + } + + def test = new Inner().foo +} + """) + assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) + } + + def deletePackage(name: String) { + val directory = new File(testOutput.path, name) + for (f <- directory.listFiles()) { + assert(f.getName.endsWith(".class")) + assert(f.delete()) + } + assert(directory.listFiles().isEmpty) + assert(directory.delete()) + } +} diff --git a/test/files/run/sd275.scala b/test/files/run/sd275.scala new file mode 100644 index 0000000000..8cdee3ae15 --- /dev/null +++ b/test/files/run/sd275.scala @@ -0,0 +1,60 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def show(): Unit = { + compileCode(""" +package sample { + + class A1 { + def irrelevant: p1.p2.p3.DeleteMe = null + } + object A1 { + class A1_Inner + } +} + +package p1 { + class LeaveMe + package p2 { + package p3 { + class DeleteMe + } + } +} + """) + assert(filteredInfos.isEmpty, filteredInfos) + deletePackage("p1/p2/p3") + deletePackage("p1/p2") + + compileCode(""" +package sample + +class Test { + final class Inner extends A1.A1_Inner { + def foo = 42 + } + + def test = new Inner().foo +} + """) + assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) // Included a MissingRequirementError before. + } + + def deletePackage(name: String) { + val directory = new File(testOutput.path, name) + for (f <- directory.listFiles()) { + assert(f.getName.endsWith(".class")) + assert(f.delete()) + } + assert(directory.listFiles().isEmpty) + assert(directory.delete()) + } +} |