Skip to content
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

Bugfix/nw23001440/check with inline vars #443

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,9 @@ data class CheckStmt(
val baseString: Expression,
val start: Int = 1,
val wrongCharPosition: AssignableExpression?,
@Derived val dataDefinition: InStatementDataDefinition? = null,
override val position: Position? = null
) : Statement(position) {
) : Statement(position), StatementThatCanDefineData {
override fun execute(interpreter: InterpreterCore) {
var baseString = interpreter.eval(this.baseString).asString().value
if (this.baseString is DataRefExpr) {
Expand All @@ -633,6 +634,8 @@ data class CheckStmt(
}
}
}

override fun dataDefinition(): List<InStatementDataDefinition> = dataDefinition?.let { listOf(it) } ?: emptyList()
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,11 +1335,16 @@ internal fun CsCHECKContext.toAst(conf: ToAstConfiguration): Statement {
val position = toPosition(conf.considerPosition)
val factor1 = this.factor1Context()?.content?.toAst(conf) ?: throw UnsupportedOperationException("CHECK operation requires factor 1: ${this.text} - ${position.atLine()}")
val (expression, startPosition) = this.cspec_fixed_standard_parts().factor2.toIndexedExpression(conf)

val result = this.cspec_fixed_standard_parts().result
val dataDefinition = this.cspec_fixed_standard_parts().toDataDefinition(result.text, position, conf)

return CheckStmt(
factor1,
expression,
startPosition ?: 1,
this.cspec_fixed_standard_parts()?.result?.toAst(conf),
dataDefinition,
position
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,10 @@ open class SmeupInterpreterTest : AbstractTest() {
val expected = listOf<String>("NUM(4)")
assertEquals(expected, "smeup/T10_A45_P02".outputOf(configuration = smeupConfig))
}

@Test
fun executeT10_A45_P03() {
val expected = listOf<String>("NUM(4)")
assertEquals(expected, "smeup/T10_A45_P03".outputOf(configuration = smeupConfig))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
D £DBG_Str S 150 VARYING
D A45_A04 S 4 INZ(' ')
D A45_A10 C '0123456789'

C EVAL A45_A04='201A'
C A45_A10 CHECK A45_A04 A45_N20 1 0
C EVAL £DBG_Str='NUM('+%CHAR(A45_N20)+')'
C £DBG_Str DSPLY
Loading