aboutsummaryrefslogtreecommitdiff
path: root/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-05-31 15:23:04 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-06-07 17:10:36 +0200
commit09b2f39731386cd5b3688d5c3badf75d956d4f6d (patch)
treed122fc0e96d6c1cd22d7e0d0b5ee523563d534e7 /bridge/src/test/scala/xsbt/ExtractAPISpecification.scala
parent030ff82070197f0c126f5c0287e076b0f6b6dd8d (diff)
downloaddotty-09b2f39731386cd5b3688d5c3badf75d956d4f6d.tar.gz
dotty-09b2f39731386cd5b3688d5c3badf75d956d4f6d.tar.bz2
dotty-09b2f39731386cd5b3688d5c3badf75d956d4f6d.zip
Make the dotty-bridge sbt project a subproject of dotty
Note that the dotty-bridge tests will not be run automatically by `test` which is short for `dotty/test`, to run the dotty-bridge tests, do in sbt: > dotty-bridge/test > dotty-bridge/scripted Original history: https://github.com/smarter/dotty-bridge/commits/master
Diffstat (limited to 'bridge/src/test/scala/xsbt/ExtractAPISpecification.scala')
-rw-r--r--bridge/src/test/scala/xsbt/ExtractAPISpecification.scala45
1 files changed, 45 insertions, 0 deletions
diff --git a/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala b/bridge/src/test/scala/xsbt/ExtractAPISpecification.scala
new file mode 100644
index 000000000..f5af67e45
--- /dev/null
+++ b/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)
+ }
+}