Skip to content

Commit a5c9ce9

Browse files
Kordyjanromanowski
authored andcommitted
Add a few more mischievous test cases for literal identifiers and slightly improved SignatureTests
1 parent 13550b1 commit a5c9ce9

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

scala3doc-testcases/src/tests/complexNames.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,21 @@ abstract class A:
66
def ++(other: A): A
77
def +:(other: Int): A
88
def :+(other: Int): A
9+
910
// scala3doc has problems with names in backticks
1011
// def `multi word name`: Int
1112
// def `*** name with arbitrary chars ^%`: Int
13+
// def `mischievous(param:Int)`(otherParam: Int): String
14+
// def withMischievousParams(`param: String, param2`: String): String
15+
1216
def complexName_^*(param: String): A
17+
18+
def `completelyUnnecessaryBackticks`: Int //expected: def completelyUnnecessaryBackticks: Int
19+
def `+++:`(other: Int): A //expected: def +++:(other: Int): A
20+
def `:+++`(other: Int): A //expected: def :+++(other: Int): A
21+
22+
def `abc_^^_&&`: A //expected: def abc_^^_&&: A
23+
def `abc_def`: A //expected: def abc_def: A
24+
def `abc_def_++`: A //expected: def abc_def_++: A
25+
// def `++_abc`: A
26+
// def `abc_++_--`: A

scala3doc/test/dotty/dokka/ScaladocTest.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ abstract class ScaladocTest(val name: String):
3434
)
3535

3636
private def tastyFiles =
37-
def collectFiles(dir: File): List[String] = dir.listFiles.toList.flatMap {
37+
def listFilesSafe(dir: File) = Option(dir.listFiles).getOrElse {
38+
throw AssertionError(s"$dir not found. The test name is incorrect or scala3doc-testcases were not recompiled.")
39+
}
40+
def collectFiles(dir: File): List[String] = listFilesSafe(dir).toList.flatMap {
3841
case f if f.isDirectory => collectFiles(f)
3942
case f if f.getName endsWith ".tasty" => f.getAbsolutePath :: Nil
4043
case _ => Nil
@@ -57,12 +60,14 @@ abstract class ScaladocTest(val name: String):
5760

5861
end ScaladocTest
5962

63+
type Validator = () => Unit
64+
6065
/**
6166
* Those assertions map 1-1 to their dokka counterparts. Some of them may be irrelevant in scala3doc.
6267
*/
6368
enum Assertion:
6469
case AfterPluginSetup(fn: DokkaContext => Unit)
65-
case DuringValidation(fn: (() => Unit) => Unit)
70+
case DuringValidation(fn: Validator => Unit)
6671
case AfterDocumentablesCreation(fn: Seq[DModule] => Unit)
6772
case AfterPreMergeDocumentablesTransformation(fn: Seq[DModule] => Unit)
6873
case AfterDocumentablesMerge(fn: DModule => Unit)

scala3doc/test/dotty/dokka/SignatureTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ abstract class SignatureTest(
2929
.flatMap(signaturesFromSources(_, signatureKinds))
3030
.toList
3131
val expectedFromSources: Map[String, List[String]] = allSignaturesFromSources
32-
.collect { case Expected(name, signature) => name -> signature }
33-
.groupMap(_._1)(_._2)
32+
.collect { case e: Expected => e }
33+
.groupMap(_.name)(_.signature)
3434
val unexpectedFromSources: Set[String] = allSignaturesFromSources.collect { case Unexpected(name) => name }.toSet
3535

3636
val actualSignatures: Map[String, Seq[String]] = signaturesFromDocumentation(root).flatMap { signature =>
3737
findName(signature, signatureKinds).map(_ -> signature)
3838
}.groupMap(_._1)(_._2)
3939

40-
val unexpected = unexpectedFromSources.flatMap(actualSignatures.getOrElse(_, Nil))
40+
val unexpected = unexpectedFromSources.flatMap(actualSignatures.get)
4141
val expectedButNotFound = expectedFromSources.flatMap {
4242
case (k, v) => findMissingSingatures(v, actualSignatures.getOrElse(k, Nil))
4343
}

0 commit comments

Comments
 (0)