Skip to content

Commit

Permalink
[fixup!] Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khbminus committed Jul 10, 2024
1 parent 5fe90ba commit 536fc11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,23 @@ 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
}

private fun <T> 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) }
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 536fc11

Please sign in to comment.