Skip to content

Commit cbbb510

Browse files
authored
Run the functional tests, to ensure they're correct (#444)
Run the functional tests, to ensure they're correct
2 parents 8778a79 + fb23c17 commit cbbb510

File tree

161 files changed

+952
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+952
-89
lines changed

core/src/main/scala/com/typesafe/tools/mima/lib/analyze/method/MethodChecker.scala

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private[analyze] object MethodChecker {
1313

1414
/** Analyze incompatibilities that may derive from new methods in `newclazz`. */
1515
private def checkNew(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
16-
checkEmulatedConcreteMethodsProblems(oldclazz, newclazz) :::
16+
(if (newclazz.isClass) Nil else checkEmulatedConcreteMethodsProblems(oldclazz, newclazz)) :::
1717
checkDeferredMethodsProblems(oldclazz, newclazz) :::
1818
checkInheritedNewAbstractMethodProblems(oldclazz, newclazz)
1919
}
@@ -108,30 +108,28 @@ private[analyze] object MethodChecker {
108108
methods.groupBy(_.parametersDesc).values.collect { case method :: _ => method }.toList
109109

110110
private def checkEmulatedConcreteMethodsProblems(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
111-
if (oldclazz.isClass && newclazz.isClass) Nil else {
112-
for {
113-
newmeth <- newclazz.emulatedConcreteMethods.iterator
114-
if !oldclazz.hasStaticImpl(newmeth)
115-
problem <- {
116-
if (oldclazz.lookupMethods(newmeth).exists(_.descriptor == newmeth.descriptor)) {
117-
// a static implementation for the same method existed already, therefore
118-
// class that mixed-in the trait already have a forwarder to the implementation
119-
// class. Mind that, despite no binary incompatibility arises, program's
120-
// semantic may be severely affected.
121-
None
122-
} else {
123-
// this means that the method is brand new and therefore the implementation
124-
// has to be injected
125-
Some(ReversedMissingMethodProblem(newmeth))
126-
}
111+
for {
112+
newmeth <- newclazz.emulatedConcreteMethods.iterator
113+
if !oldclazz.hasStaticImpl(newmeth)
114+
problem <- {
115+
if (oldclazz.lookupMethods(newmeth).exists(_.descriptor == newmeth.descriptor)) {
116+
// a static implementation for the same method existed already, therefore
117+
// classes that mixed-in the trait already have a forwarder to the implementation
118+
// class. Mind that, despite no binary incompatibility arises, program's
119+
// semantic may be severely affected.
120+
None
121+
} else {
122+
// this means that the method is brand new
123+
// and therefore the implementation has to be injected
124+
Some(ReversedMissingMethodProblem(newmeth))
127125
}
128-
} yield problem
129-
}.toList
130-
}
126+
}
127+
} yield problem
128+
}.toList
131129

132130
private def checkDeferredMethodsProblems(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
133131
for {
134-
newmeth <- newclazz.deferredMethods
132+
newmeth <- newclazz.deferredMethods.iterator
135133
problem <- oldclazz.lookupMethods(newmeth).find(_.descriptor == newmeth.descriptor) match {
136134
case None => Some(ReversedMissingMethodProblem(newmeth))
137135
case Some(oldmeth) =>
@@ -140,7 +138,7 @@ private[analyze] object MethodChecker {
140138
else None
141139
}
142140
} yield problem
143-
}
141+
}.toList
144142

145143
private def checkInheritedNewAbstractMethodProblems(oldclazz: ClassInfo, newclazz: ClassInfo): List[Problem] = {
146144
def allInheritedTypes(clazz: ClassInfo) = clazz.superClasses ++ clazz.allInterfaces

functional-tests/src/main/scala/com/typesafe/tools/mima/lib/CollectProblemsTest.scala

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.tools.nsc.classpath.AggregateClassPath
1111
object CollectProblemsTest {
1212

1313
// Called via reflection from TestsPlugin
14-
def runTest(testClasspath: Array[File], testName: String, oldJarOrDir: File, newJarOrDir: File, baseDir: File, scalaVersion: String): Unit = {
14+
def runTest(testClasspath: Array[File], testName: String, oldJarOrDir: File, newJarOrDir: File, baseDir: File, oracleFile: File): Unit = {
1515
val testClassPath = aggregateClassPath(testClasspath)
1616
val classpath = AggregateClassPath.createAggregate(testClassPath, Config.baseClassPath)
1717
val mima = new MiMaLib(classpath)
@@ -25,16 +25,6 @@ object CollectProblemsTest {
2525
val problems = mima.collectProblems(oldJarOrDir, newJarOrDir).filter(problemFilter)
2626

2727
// load oracle
28-
val oracleFile = {
29-
val p = new File(baseDir, "problems.txt")
30-
val p211 = new File(baseDir, "problems-2.11.txt")
31-
val p212 = new File(baseDir, "problems-2.12.txt")
32-
scalaVersion.take(4) match {
33-
case "2.11" => if (p211.exists()) p211 else if (p212.exists()) p212 else p
34-
case "2.12" => if (p212.exists()) p212 else p
35-
case _ => p
36-
}
37-
}
3828
val source = Source.fromFile(oracleFile)
3929
val expectedProblems = try source.getLines.filter(!_.startsWith("#")).toList finally source.close()
4030

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
println(Usage.use(new A {}))
4+
}
5+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
abstract class A
1+
abstract class A
2+
3+
object Usage {
4+
def use(a: A) = ()
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
abstract class A {
22
def foo(): Unit
33
}
4+
5+
object Usage {
6+
def use(a: A) = a.foo()
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
println(new A {}.foo(new A {}))
4+
println(new C)
5+
println(new D)
6+
7+
println(new E { def bar(): E = new E { def bar() = this } }.bar())
8+
println(new F)
9+
}
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
println(new A {}.foo(new A {}))
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
println(new A { def foo = () }.foo)
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
println(new A {}.foo(new A {}))
4+
}
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
println(Usage.use(new A {}))
4+
println(Usage.use(new B {}))
5+
}
6+
}

0 commit comments

Comments
 (0)