Skip to content

Commit 1828c8a

Browse files
committed
Add tests for extensions's signatures
1 parent ed57e32 commit 1828c8a

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ object Build {
361361
// Settings used when compiling dotty with a non-bootstrapped dotty
362362
lazy val commonBootstrappedSettings = commonDottySettings ++ NoBloopExport.settings ++ Seq(
363363
// To enable support of scaladoc and language-server projects you need to change this to true and use sbt as your build server
364-
bspEnabled := false,
364+
// bspEnabled := false,
365365
(Compile / unmanagedSourceDirectories) += baseDirectory.value / "src-bootstrapped",
366366

367367
version := dottyVersion,

scaladoc-testcases/src/tests/extensionParams.scala

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ extension [A](a: A)(using Int)
1010
def f1[B](b: B): (A, B)
1111
= ???
1212

13-
extension [A](a: A)(using Int)
13+
extension [A](a: A)(using String)
1414
def f2(b: A): (A, A)
1515
= ???
1616

17-
extension [A](a: A)(using Int)
17+
extension [A](a: A)(using Number)
1818
def f3(using String)(b: A): (A, A)
1919
= ???
2020

2121
extension (a: Char)(using Int)
2222
def f4(using String)(b: Int): Unit
2323
= ???
2424

25-
extension (a: Char)(using Int)
25+
extension (a: String)(using Int)
2626
def f5[B](using String)(b: B): Unit
2727
= ???
2828

@@ -34,15 +34,15 @@ extension [A <: List[Char]](using String)(using Unit)(a: A)(using Int)(using Num
3434
def f7[B, C](b: B)(c: C): (A, B)
3535
= ???
3636

37-
extension [A <: List[Char]](using String)(using Unit)(a: A)(using Int)(using Number)
37+
extension [A <: List[Char]](using String)(using Number)(a: A)(using Int)(using Unit)
3838
def f8(b: Any)(c: Any): Any
3939
= ???
4040

41-
extension [A <: List[Char]](using String)(using Unit)(a: A)(using Int)(using Number)
41+
extension [A <: List[Char]](using Unit)(using String)(a: A)(using Int)(using Number)
4242
def f9[B, C](using Int)(b: B)(c: C): (A, B)
4343
= ???
4444

45-
extension [A <: List[Char]](using String)(using Unit)(a: A)(using Int)(using Number)
45+
extension [A <: List[Char]](using Number)(using Unit)(a: A)(using Int)(using String)
4646
def f10(using Int)(b: Any)(c: Any): Any
4747
= ???
4848

@@ -53,11 +53,25 @@ extension (using String)(using Unit)(a: Animal)(using Int)(using Number)
5353
def f11(b: Any)(c: Any): Any
5454
= ???
5555

56+
extension (a: Int)
57+
def f13(): Any
58+
= ???
59+
60+
extension (using Unit)(a: Int)
61+
def f14(): Any
62+
= ???
63+
64+
extension (a: Int)(using Unit)
65+
def f15(): Any
66+
= ???
67+
5668
import scala.language.experimental.clauseInterleaving
5769

58-
extension (using String)(using Unit)(a: Animal)(using Int)(using Number)
59-
def f13(b: Any)[T](c: T): T
70+
extension (using String)(using Int)(a: Animal)(using Unit)(using Number)
71+
def f16(b: Any)[T](c: T): T
6072
= ???
61-
def f14[D](b: D)[T](c: T): T
73+
def f17[D](b: D)[T](c: T): T
6274
= ???
6375

76+
77+

scaladoc/test/dotty/tools/scaladoc/signatures/SignatureTest.scala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,18 @@ abstract class SignatureTest(
8282
private def startWithAnyOfThese(c: String*) = c.exists(s.startsWith)
8383
private def compactWhitespaces = whitespaceRegex.replaceAllIn(s, " ")
8484

85+
private var counter = 0
8586
private def findName(signature: String, kinds: Seq[String]): Option[String] =
8687
for
87-
kindMatch <- kinds.flatMap(k => s"\\b$k\\b".r.findFirstMatchIn(signature)).headOption
88+
kindMatch <- kinds.flatMap(k =>s"\\b$k\\b".r.findFirstMatchIn(signature)).headOption
8889
afterKind <- Option(kindMatch.after(0)) // to filter out nulls
89-
nameMatch <- identifierRegex.findFirstMatchIn(afterKind)
90+
nameMatch <- identifierRegex.findFirstMatchIn(
91+
if kindMatch.group(0).contains("extension")
92+
then
93+
signature
94+
else
95+
afterKind
96+
)
9097
yield nameMatch.group(1)
9198

9299
private def signaturesFromSources(source: Source, kinds: Seq[String]): Seq[SignatureRes] =
@@ -110,6 +117,11 @@ abstract class SignatureTest(
110117

111118
def processFile(path: Path): Unit = if filterFunc(path) then
112119
val document = Jsoup.parse(IO.read(path))
120+
val documentable = document.select(".groupHeader").forEach { element =>
121+
val signature = element.select(".groupHeader").eachText.asScala.mkString("")
122+
val all = s"$signature"
123+
signatures += all
124+
}
113125
val content = document.select(".documentableElement").forEach { elem =>
114126
val annotations = elem.select(".annotations").eachText.asScala.mkString("")
115127
val other = elem.select(".header .other-modifiers").eachText.asScala.mkString("")
@@ -122,13 +134,13 @@ abstract class SignatureTest(
122134
val all = s"$annotations$other $sigPrefix$signature".trim()
123135
signatures += all
124136
}
125-
137+
counter = 0
126138

127139
IO.foreachFileIn(output, processFile)
128140
signatures.result
129141

130142
object SignatureTest {
131143
val classlikeKinds = Seq("class", "object", "trait", "enum") // TODO add docs for packages
132-
val members = Seq("type", "def", "val", "var", "given")
144+
val members = Seq("type", "def", "val", "var", "given", "extension")
133145
val all = classlikeKinds ++ members
134146
}

scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PackageObjectSymbolSignatures extends SignatureTest("packageObjectSymbolSi
3939
class MergedPackageSignatures extends SignatureTest("mergedPackage", SignatureTest.all.filterNot(_ == "object"),
4040
sourceFiles = List("mergedPackage1", "mergedPackage2", "mergedPackage3"))
4141

42-
class ExtensionMethodSignature extends SignatureTest("extensionMethodSignatures", SignatureTest.all)
42+
class ExtensionMethodSignature extends SignatureTest("extensionMethodSignatures", SignatureTest.all.filterNot(_ == "extension"))
4343

4444
class ExtensionMethodParamsSignature extends SignatureTest("extensionParams", SignatureTest.all)
4545

0 commit comments

Comments
 (0)