list serialization (optimized, homogenous and heterogeneous

This commit is contained in:
sergeych committed 2025-08-03 13:30:41 +03:00
1 parent 12b209c724
commit d7bd159fcb
9 files changed
+164 -31

No files matched your search

+29 -5
View File
@@ -1,4 +1,5 @@
import junit.framework.TestCase.*
import junit.framework.TestCase.assertNotSame
import junit.framework.TestCase.assertSame
import kotlinx.coroutines.test.runTest
import net.sergeych.bintools.encodeToHex
import net.sergeych.lyng.Scope
@@ -9,6 +10,8 @@ import java.nio.file.Files
import java.nio.file.Path
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
class LynonTests {
@Test
@@ -144,6 +147,15 @@ class LynonTests {
assertEquals(1471792L, bin.unpackSigned())
}
@Test
fun testObjStringAndStringKeys() = runTest {
val s = "foo"
val sobj = ObjString("foo")
val map = mutableMapOf(s to 1, sobj to 2)
assertEquals(1, map[s])
assertEquals(2, map[sobj])
}
@Test
fun testCache1() = runTest {
val bout = MemoryBitOutput()
@@ -398,14 +410,12 @@ class LynonTests {
val alphabet = object : Huffman.Alphabet<LynonType> {
override val maxOrdinal = LynonType.entries.size
// val bitSize = sizeInBits(maxOrdinal)
override fun decodeOrdinalTo(bout: BitOutput, ordinal: Int) {
TODO("Not yet implemented")
throw NotImplementedError()
}
override fun get(ordinal: Int): LynonType {
TODO("Not yet implemented")
return LynonType.entries[ordinal]
}
override fun ordinalOf(value: LynonType): Int = value.ordinal
@@ -474,5 +484,19 @@ class LynonTests {
assertEquals(src3, bin.decompressString())
}
@Test
fun testIntList() = runTest {
testScope().eval("""
// testEncode([1,2,3])
// testEncode([-1,-2,-3])
// testEncode([1,-2,-3])
// testEncode([0,1])
// testEncode([0,0,0])
// testEncode(["the", "the", "wall", "the", "wall", "wall"])
testEncode([1,2,3, "the", "wall", "wall"])
""".trimIndent())
}
}