Skip to content

Commit

Permalink
tests: add tests for pc info
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Mar 4, 2024
1 parent f1608f8 commit 0609886
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/cross/src/test/scala/tests/pc/InfoSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package tests.pc

import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.PcSymbolKind
import scala.meta.pc.PcSymbolProperty

import tests.BasePCSuite
import scala.meta.pc.PcSymbolInformation

class InfoSuite extends BasePCSuite {

def getInfo(symbol: String): PcSymbolInformation = {
val result = presentationCompiler.info(symbol).get()
assert(result.isPresent(), s"no info returned for symbol $symbol")
assertNoDiff(result.get().symbol(), symbol)
result.get()
}

test("list") {
val info = getInfo("scala/collection/immutable/List#")
assert(info.properties().contains(PcSymbolProperty.ABSTRACT))
assert(info.parents().contains("scala/collection/immutable/LinearSeq#"))
}

test("empty-list-constructor") {
val info = getInfo("scala/collection/immutable/List.empty().")
assertNoDiff(info.classOwner(), "scala/collection/immutable/List.")
assertEquals(info.kind(), PcSymbolKind.METHOD)
}

test("assert") {
val info = getInfo("scala/Predef.assert().")
assertEquals(info.kind(), PcSymbolKind.METHOD)
assertNoDiff(info.classOwner(), "scala/Predef.")
assertEquals(
info.alternativeSymbols().asScala.mkString("\n"),
"scala/Predef.assert(+1)."
)
}

test("flatMap") {
val info = getInfo("scala/collection/immutable/List#flatMap().")
assertEquals(info.kind(), PcSymbolKind.METHOD)
assertNoDiff(info.classOwner(), "scala/collection/immutable/List#")
val correctOverridden =
if (scalaVersion.startsWith("2.12") || scalaVersion.startsWith("2.11")) {
"""|scala/collection/TraversableLike#flatMap().
|scala/collection/GenTraversableLike#flatMap().
|scala/collection/generic/FilterMonadic#flatMap().
|""".stripMargin
} else {
"""|scala/collection/StrictOptimizedIterableOps#flatMap().
|scala/collection/IterableOps#flatMap().
|scala/collection/IterableOnceOps#flatMap().
|""".stripMargin
}
assertNoDiff(
info.overriddenSymbols().asScala.mkString("\n"),
correctOverridden
)
}
}

0 comments on commit 0609886

Please sign in to comment.