From 536fc11f695a02734bf313e0fc4eaf63fa628172 Mon Sep 17 00:00:00 2001 From: Sergei Kharitontcev-Beglov Date: Wed, 10 Jul 2024 21:35:04 +0200 Subject: [PATCH] [fixup!] Fixed tests --- .../org/vorpal/research/kex/util/kmetadata.kt | 1 - .../kex/concolic/KotlinNullabilityTest.kt | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/kex-core/src/main/kotlin/org/vorpal/research/kex/util/kmetadata.kt b/kex-core/src/main/kotlin/org/vorpal/research/kex/util/kmetadata.kt index 3cbda7ac3..3be92cc3e 100644 --- a/kex-core/src/main/kotlin/org/vorpal/research/kex/util/kmetadata.kt +++ b/kex-core/src/main/kotlin/org/vorpal/research/kex/util/kmetadata.kt @@ -6,7 +6,6 @@ import org.vorpal.research.kex.ktype.KexArray import org.vorpal.research.kex.ktype.KexPointer import org.vorpal.research.kex.ktype.KexType import org.vorpal.research.kfg.ir.Method -import kotlin.reflect.KType fun Class<*>.getKotlinMetadata(): KotlinClassMetadata { diff --git a/kex-runner/src/test/kotlin/org/vorpal/research/kex/concolic/KotlinNullabilityTest.kt b/kex-runner/src/test/kotlin/org/vorpal/research/kex/concolic/KotlinNullabilityTest.kt index 1963cb470..f61fd7567 100644 --- a/kex-runner/src/test/kotlin/org/vorpal/research/kex/concolic/KotlinNullabilityTest.kt +++ b/kex-runner/src/test/kotlin/org/vorpal/research/kex/concolic/KotlinNullabilityTest.kt @@ -129,11 +129,11 @@ class KotlinNullabilityTest : KexRunnerTest("kotlin-nullability") { var node: Descriptor = list.fields[firstName to nodeType]!! var accumulate: T = initialValue while (node is ObjectDescriptor) { - val itemKey = list.fields.keys.find { (name) -> name == "item" }!! - val item = list.fields[itemKey]!! + val itemKey = node.fields.keys.find { (name) -> name == "item" }!! + val item = node.fields[itemKey]!! accumulate = itemVisitor(item, accumulate) - val nextKey = list.fields.keys.find { (name) -> name == "next" }!! - val next = list.fields[nextKey]!! + val nextKey = node.fields.keys.find { (name) -> name == "next" }!! + val next = node.fields[nextKey]!! node = next } return accumulate @@ -141,11 +141,11 @@ class KotlinNullabilityTest : KexRunnerTest("kotlin-nullability") { private fun foldKexList(list: ObjectDescriptor, initialValue: T, itemVisitor: (Descriptor, T) -> T): T { require(list.klass.klass == "kex/java/util/LinkedList") - val innerField = list.fields.keys.find { (name) -> name == "inner" }!! + val innerField = list.fields.keys.find { (name) -> name == "inner" } ?: return initialValue val inner = list.fields[innerField]!! require(inner is ObjectDescriptor) - val elementDataKey = list.fields.keys.find { (name) -> name == "elementData" }!! - val elementData = list.fields[elementDataKey]!! + val elementDataKey = inner.fields.keys.find { (name) -> name == "elementData" } ?: return initialValue + val elementData = inner.fields[elementDataKey]!! require(elementData is ArrayDescriptor) return (0 until elementData.length) .fold(initialValue) { acc, idx -> itemVisitor(elementData.elements[idx]!!, acc) } @@ -208,6 +208,10 @@ class KotlinNullabilityTest : KexRunnerTest("kotlin-nullability") { return@traverseList } assertTrue(item is ObjectDescriptor) + if (item.fields.isEmpty()) { + nullCount++ + return@traverseList + } val itemValueKey = item.fields.keys.find { (name) -> name == "value" }!! val itemValue = item[itemValueKey]!! if (itemValue is ConstantDescriptor.Null) {