Migrate runtime locals to frame slots

This commit is contained in:
sergeych committed 2026-02-14 23:25:19 +03:00
1 parent 34678068ac
commit cd145f6a96
27 files changed
+1247 -398

No files matched your search

@@ -4025,6 +4025,37 @@ class ScriptTest {
)
}
@Test
fun moduleFramePersistsAcrossEval() = runTest {
val scope = ModuleScope(Script.defaultImportManager, Pos.builtIn, "test.mod")
scope.eval(
"""
var x = 1
x
""".trimIndent()
)
assertEquals(1, scope.eval("x").toInt())
scope.eval("x = x + 1")
assertEquals(2, scope.eval("x").toInt())
}
@Test
fun moduleExtensionWrapperUsesFrameSlots() = runTest {
val scope = ModuleScope(Script.defaultImportManager, Pos.builtIn, "test.mod.ext")
scope.eval(
"""
fun String.foo() { this + "_m" }
""".trimIndent()
)
assertEquals("a_m", scope.eval("""__ext__String__foo("a")""").toString())
scope.eval(
"""
fun String.foo() { this + "_n" }
""".trimIndent()
)
assertEquals("a_n", scope.eval("""__ext__String__foo("a")""").toString())
}
@Test
fun testThrowReportsSource() = runTest {
try {