plugin and formatter improvements
This commit is contained in:
1 parent
f848d79d39
commit
0759346e4b
5 files changed
+152
-35
No files matched your search
@@ -528,4 +528,52 @@ class MiniAstTest {
|
||||
assertTrue(xParam.contains("first line of x"), "should contain first line")
|
||||
assertTrue(xParam.contains("second line of x"), "should contain second line")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun enum_minidocs_and_semicolon_robustness() = runTest {
|
||||
val code = """
|
||||
/** Enum doc */
|
||||
enum E { A };
|
||||
|
||||
/** Next doc */
|
||||
class C {}
|
||||
""".trimIndent()
|
||||
val (_, sink) = compileWithMini(code)
|
||||
val mini = sink.build()
|
||||
assertNotNull(mini)
|
||||
|
||||
val en = mini.declarations.filterIsInstance<MiniEnumDecl>().firstOrNull { it.name == "E" }
|
||||
assertNotNull(en)
|
||||
assertNotNull(en.doc)
|
||||
assertEquals("Enum doc", en.doc.summary)
|
||||
|
||||
val cl = mini.declarations.filterIsInstance<MiniClassDecl>().firstOrNull { it.name == "C" }
|
||||
assertNotNull(cl)
|
||||
assertNotNull(cl.doc)
|
||||
assertEquals("Next doc", cl.doc.summary)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun empty_enum_support() = runTest {
|
||||
val code = "enum E {}"
|
||||
val (_, sink) = compileWithMini(code)
|
||||
val mini = sink.build()
|
||||
assertNotNull(mini)
|
||||
assertTrue(mini.declarations.any { it.name == "E" && it is MiniEnumDecl })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun modifiers_with_comment_robustness() = runTest {
|
||||
val code = """
|
||||
class X {
|
||||
static /** doc */ fun f() {}
|
||||
}
|
||||
""".trimIndent()
|
||||
val (_, sink) = compileWithMini(code)
|
||||
val mini = sink.build()
|
||||
assertNotNull(mini)
|
||||
val cls = mini.declarations.filterIsInstance<MiniClassDecl>().firstOrNull { it.name == "X" }
|
||||
assertNotNull(cls)
|
||||
assertTrue(cls.members.any { it.name == "f" })
|
||||
}
|
||||
}
|
||||
@@ -882,6 +882,22 @@ class LyngFormatterTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val cfg = LyngFormatConfig(indentSize = 4, continuationIndentSize = 4)
|
||||
val out = LyngFormatter.reindent(src, cfg)
|
||||
assertEquals(expected, out)
|
||||
}
|
||||
@Test
|
||||
fun multlinedShortFunIndentation() {
|
||||
val src = """
|
||||
static fun create(walletId, trId, amount) =
|
||||
Cells.createNew(Commission(amount) => ["commission", "w:" + walletId, "tr:" + trId, createdTag(), "pending"])
|
||||
""".trimIndent()
|
||||
|
||||
val expected = """
|
||||
static fun create(walletId, trId, amount) =
|
||||
Cells.createNew(Commission(amount) => ["commission", "w:" + walletId, "tr:" + trId, createdTag(), "pending"])
|
||||
""".trimIndent()
|
||||
|
||||
val cfg = LyngFormatConfig(indentSize = 4, continuationIndentSize = 4)
|
||||
val out = LyngFormatter.reindent(src, cfg)
|
||||
assertEquals(expected, out)
|
||||
|
||||
Reference in new issue
Block a user