@@ -20,7 +20,9 @@ import kotlinx.serialization.json.Json
2020import kotlinx.serialization.json.jsonPrimitive
2121import mu.KotlinLogging
2222import org.jacodb.ets.dto.AnyTypeDto
23+ import org.jacodb.ets.dto.AssignStmtDto
2324import org.jacodb.ets.dto.ClassSignatureDto
25+ import org.jacodb.ets.dto.ClosureFieldRefDto
2426import org.jacodb.ets.dto.DecoratorDto
2527import org.jacodb.ets.dto.FieldDto
2628import org.jacodb.ets.dto.FieldSignatureDto
@@ -493,4 +495,49 @@ class EtsFromJsonTest {
493495 assertEquals(" Cat" , cls.fields[0 ].name)
494496 assertEquals(" Dog" , cls.fields[1 ].name)
495497 }
498+
499+ @Test
500+ fun testClosureFieldRefDto () {
501+ val s = """
502+ {
503+ "_": "ClosureFieldRef",
504+ "base": {
505+ "name": "a",
506+ "type": { "_": "UnknownType" }
507+ },
508+ "fieldName": "foo",
509+ "type": { "_": "UnknownType" }
510+ }
511+ """ .trimIndent()
512+ val dto = json.decodeFromString<ValueDto >(s)
513+ logger.info { " dto = $dto " }
514+ assertIs<ClosureFieldRefDto >(dto)
515+ }
516+
517+ @Test
518+ fun testAssignArrayRefDto () {
519+ val s = """
520+ {
521+ "_": "AssignStmt",
522+ "left": {
523+ "_": "Local",
524+ "name": "x",
525+ "type": { "_": "NumberType" }
526+ },
527+ "right": {
528+ "_": "ClosureFieldRef",
529+ "base": {
530+ "name": "a",
531+ "type": { "_": "UnknownType" }
532+ },
533+ "fieldName": "foo",
534+ "type": { "_": "UnknownType" }
535+ }
536+ }
537+ """ .trimIndent()
538+ val dto = json.decodeFromString<StmtDto >(s)
539+ logger.info { " dto = $dto " }
540+ assertIs<AssignStmtDto >(dto)
541+ assertIs<ClosureFieldRefDto >(dto.right)
542+ }
496543}
0 commit comments