diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-11 17:28:39 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:06 +0100 |
commit | 2d10c87ce537fb42fdb134efcae53dca7305a7b7 (patch) | |
tree | a3629c9a3ad6db3e9d07df8fa8621f8c8211076c /sbt-bridge/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala | |
parent | 34d64f381362b12a595fd26690c7c9b1c26d16f7 (diff) | |
download | dotty-2d10c87ce537fb42fdb134efcae53dca7305a7b7.tar.gz dotty-2d10c87ce537fb42fdb134efcae53dca7305a7b7.tar.bz2 dotty-2d10c87ce537fb42fdb134efcae53dca7305a7b7.zip |
Move sbt-bridge
Diffstat (limited to 'sbt-bridge/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala')
-rw-r--r-- | sbt-bridge/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sbt-bridge/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala b/sbt-bridge/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala new file mode 100644 index 000000000..f5af67e45 --- /dev/null +++ b/sbt-bridge/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala @@ -0,0 +1,45 @@ +/** Adapted from https://github.com/sbt/sbt/blob/0.13/compile/interface/src/test/scala/xsbt/ExtractAPISpecification.scala */ +package xsbt + +import org.junit.runner.RunWith +import xsbti.api.ClassLike +import xsbti.api.Def +import xsbt.api.ShowAPI +import org.specs2.mutable.Specification +import org.specs2.runner.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +class ExtractAPISpecification extends Specification { + + "Existential types in method signatures" should { + "have stable names" in { stableExistentialNames } + } + + def stableExistentialNames: Boolean = { + def compileAndGetFooMethodApi(src: String): Def = { + val compilerForTesting = new ScalaCompilerForUnitTesting + val sourceApi = compilerForTesting.extractApiFromSrc(src) + val FooApi = sourceApi.definitions().find(_.name() == "Foo").get.asInstanceOf[ClassLike] + val fooMethodApi = FooApi.structure().declared().find(_.name == "foo").get + fooMethodApi.asInstanceOf[Def] + } + val src1 = """ + |class Box[T] + |class Foo { + | def foo: Box[_] = null + | + }""".stripMargin + val fooMethodApi1 = compileAndGetFooMethodApi(src1) + val src2 = """ + |class Box[T] + |class Foo { + | def bar: Box[_] = null + | def foo: Box[_] = null + | + }""".stripMargin + val fooMethodApi2 = compileAndGetFooMethodApi(src2) + fooMethodApi1 == fooMethodApi2 + // Fails because xsbt.api is compiled with Scala 2.10 + // SameAPI.apply(fooMethodApi1, fooMethodApi2) + } +} |