- fixed bug in compiler (rare)

- added lyng.io.fs (multiplatform)
- CLI tools now have access to the filesystem
This commit is contained in:
sergeych committed 2025-11-29 00:51:01 +01:00
1 parent 41746f22e5
commit 438e48959e
28 files changed
+2137 -6

No files matched your search

@@ -3667,6 +3667,48 @@ class ScriptTest {
}
@Test
fun testIterableMinMax() = runTest {
eval("""
import lyng.stdlib
assertEquals( -100, (1..100).toList().minOf { -it } )
assertEquals( -1, (1..100).toList().maxOf { -it } )
""".trimIndent()
)
}
@Test
fun testParserOverflow() = runTest {
try {
eval(
"""
fun Iterable.minByWithIndex( lambda ) {
val i = iterator()
var index = 0
if( !i.hasNext() ) return null
var value = i.next()
var n = 1
while( i.hasNext() ) {
val x = lambda(i.next())
if( x < value ) {
index = n
value = x
}
n++
}
index => value
}
""".trimIndent()
)
// If it compiles fine, great. The test passes implicitly.
} catch (e: ScriptError) {
// The important part: no StackOverflowError anymore, but a meaningful ScriptError
// is thrown. Accept any ScriptError as a valid outcome.
println(e.message)
}
}
// @Test
// fun namedArgsProposal() = runTest {
// eval("""