Fix multiline list parsing and expose actionable HTTP failures

This commit is contained in:
sergeych committed 2026-10-13 02:19:56 +04:00
1 parent 8b0d847776
commit 66ab7db3d8
11 files changed
+131 -12

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = "net.sergeych"
version = "1.5.10"
version = providers.gradleProperty("lyng.version").getOrElse("1.5.10")
// Removed legacy buildscript classpath declarations; plugins are applied via the plugins DSL below
@@ -4021,6 +4021,7 @@ class Compiler(
while (true) {
val t = cc.next()
when (t.type) {
Token.Type.NEWLINE, Token.Type.SINGLE_LINE_COMMENT, Token.Type.MULTILINE_COMMENT -> continue
Token.Type.COMMA -> {
// todo: check commas sequences like [,] [,,] before, after or instead of expressions
}
@@ -0,0 +1,21 @@
import kotlinx.coroutines.test.runTest
import net.sergeych.lyng.Script
import kotlin.test.*
class MultilineListLiteralTest {
@Test fun finalNewlineCommentsAndTrailingCommaAreWhitespace() = runTest {
val scope = Script.newScope()
for (source in listOf(
"[\n \"first\",\n \"second\"\n]",
"[\n \"first\",\n \"second\",\n]",
"[\n // before\n \"first\", /* between */\n \"second\" // after\n]",
)) assertEquals("[first,second]", scope.eval(source).toString(scope).value)
}
@Test fun nestedAndEmptyMultilineListsAndExpressionsRemainValid() = runTest {
val scope = Script.newScope()
assertEquals("[]", scope.eval("[\n]").toString(scope).value)
assertEquals("[[1,2],[3,4]]", scope.eval("[\n [1,2],\n [3,4]\n]").toString(scope).value)
assertEquals("[3,7]", scope.eval("[\n 1+2,\n 3+4\n]").toString(scope).value)
assertFails { scope.eval("[\n @\n]") }
}
}