well redesigned class vals and vars, classScope introduced for class functions

This commit is contained in:
sergeych committed 2025-08-06 11:46:17 +03:00
1 parent 4165da5e81
commit 63b2808109
7 files changed
+125 -11

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import kotlinx.coroutines.test.runTest
import net.sergeych.lyng.eval
import kotlin.test.Test
class OOTest {
@Test
fun testClassProps() = runTest {
eval("""
import lyng.time
class Point(x,y) {
static val origin = Point(0,0)
static var center = origin
}
assertEquals(Point(0,0), Point.origin)
assertEquals(Point(0,0), Point.center)
Point.center = Point(1,2)
assertEquals(Point(0,0), Point.origin)
assertEquals(Point(1,2), Point.center)
""".trimIndent())
}
@Test
fun testClassMethods() = runTest {
eval("""
import lyng.time
class Point(x,y) {
private static var data = null
}
assertEquals(Point(0,0), Point(0,0) )
""".trimIndent())
}
}