diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-08-25 16:27:06 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-06 17:09:08 +0200 |
commit | 7a5244027cb7257b3e350a37fc2f48e263c4ca7e (patch) | |
tree | b2356b023a8ea9b8f16d2f266077c86095e95006 /dottydoc/test | |
parent | 1e61c8c4cd7362331cff60245d1a5451f299d674 (diff) | |
download | dotty-7a5244027cb7257b3e350a37fc2f48e263c4ca7e.tar.gz dotty-7a5244027cb7257b3e350a37fc2f48e263c4ca7e.tar.bz2 dotty-7a5244027cb7257b3e350a37fc2f48e263c4ca7e.zip |
Fix type parameters not getting properly typed
Diffstat (limited to 'dottydoc/test')
-rw-r--r-- | dottydoc/test/UsecaseTest.scala | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/dottydoc/test/UsecaseTest.scala b/dottydoc/test/UsecaseTest.scala index d5f338892..9be688297 100644 --- a/dottydoc/test/UsecaseTest.scala +++ b/dottydoc/test/UsecaseTest.scala @@ -52,6 +52,95 @@ class UsecaseTest extends DottyTest { } } + @Test def simpleUsecaseAddedArg = { + val source = new SourceFile( + "DefWithUseCase.scala", + """ + |package scala + | + |trait Test[A] { + | /** Definition with a "disturbing" signature + | * + | * @usecase def foo(a: A): A + | */ + | def foo[B]: A => B + |} + """.stripMargin + ) + + checkSources(source :: Nil) { packages => + packages("scala") match { + case PackageImpl(_, _, List(trt: Trait), _, _) => + val List(foo: Def) = trt.members + + val returnValue = foo.returnValue match { + case ref: TypeReference => ref.title + case _ => + assert( + false, + "Incorrect return value after usecase transformation" + ) + "" + } + + assert( + foo.typeParams.isEmpty, + "Type parameters were not stripped by usecase" + ) + assert(returnValue == "A", "Incorrect return type after usecase") + assert( + foo.paramLists.head.list.head.title == "a", + "Incorrect parameter to function after usecase transformation" + ) + assert(foo.name == "foo", s"Incorrect name after transform: ${foo.name}") + } + } + } + + @Test def simpleTparamUsecase = { + val source = new SourceFile( + "DefWithUseCase.scala", + """ + |package scala + | + |trait Test[A] { + | /** Definition with a "disturbing" signature + | * + | * @usecase def foo[C]: A + | */ + | def foo[B]: A => B + |} + """.stripMargin + ) + + checkSources(source :: Nil) { packages => + packages("scala") match { + case PackageImpl(_, _, List(trt: Trait), _, _) => + val List(foo: Def) = trt.members + + val returnValue = foo.returnValue match { + case ref: TypeReference => ref.title + case _ => + assert( + false, + "Incorrect return value after usecase transformation" + ) + "" + } + + assert( + foo.typeParams.nonEmpty, + "Type parameters were incorrectly stripped by usecase" + ) + + assert(foo.typeParams.head == "C", "Incorrectly switched tparam") + assert(returnValue == "A", "Incorrect return type after usecase") + + assert(foo.name == "foo", s"Incorrect name after transform: ${foo.name}") + } + } + } + @Test def checkIterator = { val sources = "./scala-scala/src/library/scala/collection/Iterator.scala" :: Nil |