Skip to content

Input arrays support #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Input arrays support #285

wants to merge 3 commits into from

Conversation

CaelmBleidd
Copy link
Member

@CaelmBleidd CaelmBleidd commented Jun 3, 2025

The following changes were made:

  1. New matchers for tests supporting executions number checker
  2. Support for arrays as parameters
  3. Register fake objects creation to support their restoration during model resolving
  4. Reading by negative indices and indices out of range are prohibited. We'll treat this operation as an error

check(fakeObject.isFakeObject())

val fakeType = fakeObject.getFakeType(finalStateMemory)
return@map when {

Check warning

Code scanning / detekt

Braces do not comply with the specified policy Warning test

Inconsistent braces, make sure all branches either have or don't have braces.
invariants = invariants,
extractValuesToCheck = { r -> r.before.parameters + r.returnValue },
expectedTypesForExtractedValues = arrayOf(
typeTransformer(T1::class), typeTransformer(T2::class), typeTransformer(R::class)

Check warning

Code scanning / detekt

Reports incorrect argument list wrapping Warning test

Argument should be on a separate line (unless all arguments can fit a single line)
invariants = invariants,
extractValuesToCheck = { r -> r.before.parameters + r.returnValue },
expectedTypesForExtractedValues = arrayOf(
typeTransformer(T1::class), typeTransformer(T2::class), typeTransformer(R::class)

Check warning

Code scanning / detekt

Reports incorrect argument list wrapping Warning test

Argument should be on a separate line (unless all arguments can fit a single line)
@@ -139,6 +199,30 @@
)
}

protected inline fun <reified T1 : TsTestValue, reified T2 : TsTestValue, reified T3 : TsTestValue, reified R : TsTestValue> checkMatches(

Check warning

Code scanning / detekt

Reports lines with exceeded length Warning test

Exceeded max line length (120)
@@ -139,6 +199,30 @@
)
}

protected inline fun <reified T1 : TsTestValue, reified T2 : TsTestValue, reified T3 : TsTestValue, reified R : TsTestValue> checkMatches(

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning test

Line detected, which is longer than the defined maximum line length in the code style.
@@ -163,6 +247,31 @@
)
}

protected inline fun <reified T1 : TsTestValue, reified T2 : TsTestValue, reified T3 : TsTestValue, reified T4 : TsTestValue, reified R : TsTestValue> checkMatches(

Check warning

Code scanning / detekt

Reports lines with exceeded length Warning test

Exceeded max line length (120)
@@ -163,6 +247,31 @@
)
}

protected inline fun <reified T1 : TsTestValue, reified T2 : TsTestValue, reified T3 : TsTestValue, reified T4 : TsTestValue, reified R : TsTestValue> checkMatches(

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning test

Line detected, which is longer than the defined maximum line length in the code style.
@@ -20,6 +20,11 @@
matcherFailedMessage = { _ -> "No analysis results received" }
) { it > 0 }

val noResultsExpected = AnalysisResultsNumberMatcher(
description = "No executions expected",
matcherFailedMessage = { it -> "Expected no analysis results, but $it executions were found" }

Check warning

Code scanning / detekt

Declaring lambda parameters as `it` is redundant. Warning test

This explicit usage of it as the lambda parameter name can be omitted.
@CaelmBleidd CaelmBleidd force-pushed the caelmbleidd/input_arrays branch from ac893b9 to 163e637 Compare June 6, 2025 14:12
@CaelmBleidd CaelmBleidd requested a review from Lipen June 6, 2025 14:12
@CaelmBleidd CaelmBleidd marked this pull request as ready for review June 6, 2025 14:12
)

// If we want to get length from a fake object, we assume that it is an array.
scope.assert(fakeType.refTypeExpr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why assert and not pathConstraints += ...?

@@ -809,7 +901,12 @@ class TsExprResolver(
blockOnFalseState = allocateException(EtsStringType) // TODO incorrect exception type
)

val arrayType = EtsArrayType(EtsUnknownType, 1) // TODO: expr.type
val arrayType = expr.type as EtsArrayType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast might fail.

Copy link
Member

@Lipen Lipen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid 🪨

@@ -76,6 +87,33 @@
return TsTest(method, before, after, result, trace = emptyList())
}

private fun prepareForResolve(state: TsState) {
state.lValuesToAllocatedFakeObjects.forEach { (lValue, fakeObject) ->
when (lValue) {

Check warning

Code scanning / detekt

Braces do not comply with the specified policy Warning test

Inconsistent braces, make sure all branches either have or don't have braces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants