Fix multiline list parsing and expose actionable HTTP failures
This commit is contained in:
1 parent
8b0d847776
commit
66ab7db3d8
11 files changed
+131
-12
No files matched your search
@@ -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]") }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user