-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce BaseRangeFormatterSuite for common checker logic
- Loading branch information
Showing
3 changed files
with
48 additions
and
85 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tests/unit/src/main/scala/tests/BaseRangeFormatterSuite.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,44 @@ | ||
package tests | ||
|
||
import munit.Location | ||
import munit.TestOptions | ||
import org.eclipse.lsp4j.FormattingOptions | ||
|
||
abstract class BaseRangeFormatterSuite(name: String) | ||
extends BaseLspSuite(name) { | ||
def check( | ||
name: TestOptions, | ||
testCase: String, | ||
paste: String, | ||
expectedCase: String, | ||
)(implicit loc: Location): Unit = { | ||
val tripleQuote = "\"\"\"" | ||
def unmangle(string: String): String = | ||
string.replaceAll("'''", tripleQuote) | ||
|
||
val testCode = unmangle(testCase) | ||
val base = testCode.replaceAll("(@@)", "") | ||
val expected = unmangle(expectedCase) | ||
test(name) { | ||
for { | ||
_ <- initialize( | ||
s"""/metals.json | ||
|{"a":{}} | ||
|/a/src/main/scala/a/Main.scala | ||
|""".stripMargin + base | ||
) | ||
_ <- server.didOpen("a/src/main/scala/a/Main.scala") | ||
_ <- server.rangeFormatting( | ||
"a/src/main/scala/a/Main.scala", | ||
testCode, // bez @@ | ||
expected, | ||
unmangle(paste), | ||
workspace, | ||
Some(formattingOptions), | ||
) | ||
} yield () | ||
} | ||
} | ||
|
||
val formattingOptions = new FormattingOptions(2, true) | ||
} |
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