+ #40: test that (module-level) blocks *before the last* still must have a newline after their closing }

This commit is contained in:
meisl 2021-06-13 20:47:14 +02:00
parent 3b91e59a79
commit 1468049fe9

View File

@ -54,6 +54,21 @@ class TestAntlrParser {
assertEquals(parseTree.block().size, 1) assertEquals(parseTree.block().size, 1)
} }
@Test
fun testAllBlocksButLastMustEndWithNewline() {
val nl = "\n" // say, Unix-style (different flavours tested elsewhere)
// BAD: 2nd block `bar` does NOT start on new line; however, there's is a nl at the very end
val srcBad = "foo {" + nl + "}" + " bar {" + nl + "}" + nl
// GOOD: 2nd block `bar` does start on a new line; however, a nl at the very end ain't needed
val srcGood = "foo {" + nl + "}" + nl + "bar {" + nl + "}"
assertFailsWith<ParsingFailedError> { parseModule(srcBad) }
val parseTree = parseModule(srcGood)
assertEquals(parseTree.block().size, 2)
}
@Test @Test
fun testProg8Ast() { fun testProg8Ast() {
// can create charstreams from many other sources as well; // can create charstreams from many other sources as well;