fix #5 loop optimization

fixed arguments modifying bug
added samples and samplebooks w/tests
This commit is contained in:
sergeych committed 2025-06-03 10:44:42 +04:00
1 parent 53eb1bc5e7
commit 512dda5984
14 files changed
+311 -53

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import kotlinx.datetime.Clock
import net.sergeych.lyng.Context
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.io.path.extension
import kotlin.test.Test
suspend fun executeSampleTests(fileName: String) {
val sample = withContext(Dispatchers.IO) {
Files.readString(Paths.get(fileName))
}
runBlocking {
val c = Context()
for( i in 1..1) {
val start = Clock.System.now()
c.eval(sample)
val time = Clock.System.now() - start
println("$time: $fileName")
// delay(100)
}
}
}
class SamplesTest {
@Test
fun testSamples() = runBlocking {
for (s in Files.list(Paths.get("../docs/samples"))) {
if (s.extension == "lyng") executeSampleTests(s.toString())
}
}
}