-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: Add inlayHints fallback suite
- Loading branch information
Showing
5 changed files
with
108 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/slow/src/test/scala/tests/feature/InlayHintsFallbackSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package tests.feature | ||
|
||
import tests.BaseInlayHintsLspSuite | ||
|
||
class InlayHintsFallbackSuite | ||
extends BaseInlayHintsLspSuite( | ||
"inlayHints-fallback", | ||
"3.4.0", | ||
) { | ||
|
||
check( | ||
"all-synthetics", | ||
"""|import scala.concurrent.Future | ||
|case class Location(city: String) | ||
|object Main{ | ||
| def hello()(implicit name: String, from: Location)/*: Unit*/ = { | ||
| println(s"Hello $$name from $${from.city}") | ||
| } | ||
| implicit val andy : String = "Andy" | ||
| | ||
| def greeting()/*: Unit*/ = { | ||
| implicit val boston/*: Location*/ = Location("Boston") | ||
| hello()/*(andy, boston)*/ | ||
| hello()/*(andy, boston)*/; hello()/*(andy, boston)*/ | ||
| } | ||
| | ||
| val ordered/*: String*/ = /*augmentString(*/"acb"/*)*/.sorted/*(Char)*/ | ||
| /*augmentString(*/"foo"/*)*/.map(c/*: Char*/ => c.toInt) | ||
| implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global | ||
| Future{ | ||
| println("") | ||
| }/*(ec)*/ | ||
|} | ||
|""".stripMargin, | ||
config = Some( | ||
"""|"show-implicit-arguments": true, | ||
|"show-implicit-conversions-and-classes": true, | ||
|"show-inferred-type": minimal | ||
|""".stripMargin | ||
), | ||
) | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
tests/unit/src/main/scala/tests/BaseInlayHintsLspSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package tests | ||
|
||
import munit.Location | ||
import munit.TestOptions | ||
import tests.BaseLspSuite | ||
import tests.TestInlayHints | ||
|
||
abstract class BaseInlayHintsLspSuite(name: String, scalaVersion: String) | ||
extends BaseLspSuite(name) { | ||
def check( | ||
name: TestOptions, | ||
expected: String, | ||
config: Option[String] = None, | ||
dependencies: List[String] = Nil, | ||
)(implicit | ||
loc: Location | ||
): Unit = { | ||
val initConfig = config | ||
.map(config => s"""{ | ||
|$config | ||
|} | ||
|""".stripMargin) | ||
.getOrElse("""{ | ||
| "show-implicit-arguments": true, | ||
| "show-implicit-conversions-and-classes": true, | ||
| "show-inferred-type": "true" | ||
|} | ||
|""".stripMargin) | ||
val fileName = "Main.scala" | ||
val code = TestInlayHints.removeInlayHints(expected) | ||
test(name) { | ||
for { | ||
_ <- initialize( | ||
s"""/metals.json | ||
|{"a":{ | ||
| "scalaVersion": "$scalaVersion", | ||
| "libraryDependencies": ${toJsonArray(dependencies)} | ||
|}} | ||
|/a/src/main/scala/a/$fileName | ||
|$code | ||
""".stripMargin | ||
) | ||
_ <- server.didOpen(s"a/src/main/scala/a/$fileName") | ||
_ <- server.didChangeConfiguration(initConfig) | ||
_ <- server.assertInlayHints( | ||
s"a/src/main/scala/a/$fileName", | ||
code, | ||
expected, | ||
workspace, | ||
) | ||
} yield () | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters