From d90af8aef55dbd85da4821d1786d313f7a760f7c Mon Sep 17 00:00:00 2001 From: Domenico Date: Wed, 13 Mar 2024 14:15:19 +0100 Subject: [PATCH 01/21] Add unit tests for new ScanStmt logic --- .../evaluation/SmeupInterpreterTest.kt | 12 +++++++++++ .../test/resources/smeup/T10_A35_P08.rpgle | 18 +++++++++++++++++ .../test/resources/smeup/T10_A35_P10.rpgle | 20 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P08.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P10.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index b9a9a76c4..c9ef84148 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -598,6 +598,18 @@ open class SmeupInterpreterTest : AbstractTest() { assertEquals(expected, "smeup/T40_A20_P26".outputOf(configuration = smeupConfig)) } + @Test + fun executeT10_A35_P08() { + val expected = listOf("A35_AR1(2)(123&5) IN45(1)") + assertEquals(expected, "smeup/T10_A35_P08".outputOf(configuration = smeupConfig)) + } + + @Test + fun executeT10_A35_P10() { + val expected = listOf("A35_AR2(01)(5) A35_AR2(02)(6) A35_AR2(03)(0) IN20(1)") + assertEquals(expected, "smeup/T10_A35_P10".outputOf(configuration = smeupConfig)) + } + @Test fun executeT18_A10_P01() { val expected = listOf("Ritorno_Procedura") diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P08.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P08.rpgle new file mode 100644 index 000000000..e37b2aaa5 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P08.rpgle @@ -0,0 +1,18 @@ + D £DBG_Str S 150 VARYING + D A35_AR1 S 70 DIM(10) + D A35_A1 S 6 + D A35_A2 S 1 + D A35_AR2 S 2 0 DIM(5) + D $A S 1 0 + D I S 2 0 + + C EVAL A35_AR1(1)='ABCDEF' + C EVAL A35_AR1(2)='123&5' + C EVAL A35_AR1(3)='TEST&' + C EVAL I = 2 + C '&' SCAN A35_AR1(I):1 45 + C EVAL £DBG_Str= + C 'A35_AR1(2)('+%TRIMR(A35_AR1(2))+') ' + C +'IN45('+%CHAR(*IN45)+')' + + C £DBG_Str DSPLY \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P10.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P10.rpgle new file mode 100644 index 000000000..976940a27 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A35_P10.rpgle @@ -0,0 +1,20 @@ + D £DBG_Str S 150 VARYING + D A35_AR1 S 70 DIM(10) + D A35_A1 S 6 + D A35_A2 S 1 + D A35_AR2 S 2 0 DIM(5) + D $A S 1 0 + D I S 2 0 + + C SETOFF 20 + C EVAL A35_A1='YARRYY' + C EVAL A35_A2='Y' + C EVAL $A=3 + C A35_A2 SCAN A35_A1:$A A35_AR2 20 + C EVAL £DBG_Str= + C 'A35_AR2(01)('+%CHAR(A35_AR2(01))+') ' + C +'A35_AR2(02)('+%CHAR(A35_AR2(02))+') ' + C +'A35_AR2(03)('+%CHAR(A35_AR2(03))+') ' + C +'IN20('+%CHAR(*IN20)+')' + + C £DBG_Str DSPLY \ No newline at end of file From 384e4df2f47a99999f8cd01962bd955f1b47ae3a Mon Sep 17 00:00:00 2001 From: Domenico Date: Wed, 13 Mar 2024 14:15:41 +0100 Subject: [PATCH 02/21] Extend ScanStmt to support expressions after colons --- .../smeup/rpgparser/parsing/ast/statements.kt | 8 +++-- .../rpgparser/parsing/parsetreetoast/misc.kt | 36 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt index 531d89063..611475750 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt @@ -1704,7 +1704,7 @@ data class ScanStmt( val left: Expression, val leftLength: Int?, val right: Expression, - val startPosition: Int, + val startPosition: Expression?, val target: AssignableExpression?, val rightIndicators: WithRightIndicators, @Derived val dataDefinition: InStatementDataDefinition? = null, @@ -1712,13 +1712,15 @@ data class ScanStmt( ) : Statement(position), WithRightIndicators by rightIndicators, StatementThatCanDefineData { override fun execute(interpreter: InterpreterCore) { + val start = startPosition?.let { interpreter.eval(it).asString().value.toInt() } ?: 1 + val stringToSearch = interpreter.eval(left).asString().value.substringOfLength(leftLength) - val searchInto = interpreter.eval(right).asString().value.substring(startPosition - 1) + val searchInto = interpreter.eval(right).asString().value.substring(start - 1) val occurrences = mutableListOf() var index = -1 do { index = searchInto.indexOf(stringToSearch, index + 1) - if (index >= 0) occurrences.add(IntValue((index + startPosition).toLong())) + if (index >= 0) occurrences.add(IntValue((index + start).toLong())) } while (index >= 0) if (occurrences.isEmpty()) { interpreter.setIndicators(this, BooleanValue.FALSE, BooleanValue.FALSE, BooleanValue.FALSE) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index cbc2f9014..fd6dc60c2 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -1316,20 +1316,31 @@ internal fun CsDELETEContext.toAst(conf: ToAstConfiguration): Statement { internal fun CsSCANContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): ScanStmt { val position = toPosition(conf.considerPosition) + val (compareExpression, compareLength) = this.factor1Context().toIndexedExpression(conf) - val (baseExpression, startPosition) = this.cspec_fixed_standard_parts().factor2.toIndexedExpression(conf) + + val factor2 = this.cspec_fixed_standard_parts().factor2 + + val result = this.cspec_fixed_standard_parts().result + val dataDefinition = this.cspec_fixed_standard_parts().toDataDefinition(result.text, position, conf) + val rightIndicators = cspec_fixed_standard_parts().rightIndicators() - val result = this.cspec_fixed_standard_parts().result.text - val dataDefinition = this.cspec_fixed_standard_parts().toDataDefinition(result, position, conf) - val target = when { - result.isNotBlank() -> this.cspec_fixed_standard_parts()!!.result!!.toAst(conf) - else -> null - } + val target = if (result.text.isNotBlank()) result.toAst(conf) else null + + val baseExpression = factor2.factorContent(0).toAst(conf) + // and "B" is the start position to substring, if not specified it returns null + val positionExpression = + if (factor2.factorContent().size > 1) { + factor2.factorContent(1).toAst(conf) + } else { + null + } + return ScanStmt( left = compareExpression, leftLength = compareLength, right = baseExpression, - startPosition = startPosition ?: 1, + startPosition = positionExpression, target = target, rightIndicators = rightIndicators, dataDefinition = dataDefinition, @@ -1378,8 +1389,6 @@ private fun FactorContext.toIndexedExpression(conf: ToAstConfiguration): Pair { - fun String.isLiteral(): Boolean { return (startsWith('\'') && endsWith('\'')) } - val baseStringTokens = this.split(":") val startPosition = when (baseStringTokens.size) { @@ -1389,7 +1398,10 @@ private fun String.toIndexedExpression(position: Position?): Pair StringLiteral(reference.trim('\''), position) + reference.isStringLiteral() -> StringLiteral(reference.trim('\''), position) + reference.contains('(') && reference.endsWith(")") -> { + annidatedReferenceExpression(this, position) + } else -> DataRefExpr(ReferenceByName(reference), position) } to startPosition } @@ -2024,3 +2036,5 @@ private fun List.removeUnnecessaryRecordFormat() dataDef.type is RecordFormatType && this.any { it.type is DataStructureType && it.name.uppercase() == dataDef.name.uppercase() } } } + +private fun String.isStringLiteral(): Boolean = startsWith('\'') && endsWith('\'') \ No newline at end of file From 01571bc21efcc5e1ddfb742dcafcb5d2ba11c951 Mon Sep 17 00:00:00 2001 From: Domenico Date: Thu, 14 Mar 2024 14:22:50 +0100 Subject: [PATCH 03/21] Add unit test T10_A20_P52 --- .../evaluation/SmeupInterpreterTest.kt | 6 ++++ .../test/resources/smeup/T10_A20_P52.rpgle | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T10_A20_P52.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index cbc19d86b..4d3ec749b 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -647,4 +647,10 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("TestProcedura_Ritorno") assertEquals(expected, "smeup/T18_A10_P02".outputOf()) } + + @Test + fun executeT10_A20_P52() { + val expected = listOf("A20_N73(2.272) A20_N70(0) A20_N112(11.11) A20_N110(0) A20_N309(4.889964788)") + assertEquals(expected, "smeup/T10_A20_P52".outputOf(configuration = smeupConfig)) + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A20_P52.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A20_P52.rpgle new file mode 100644 index 000000000..932244957 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A20_P52.rpgle @@ -0,0 +1,28 @@ + D £DBG_Str S 150 VARYING + + D A20_N70 S 20P 0 + D A20_N73 S 20P 3 + D A20_N110 S 11P 0 + D A20_N112 S 11P 2 + D A20_N309 S 30P 9 + + C EXSR SUB_A20_I + C EVAL £DBG_Str='A20_N73('+%CHAR(A20_N73)+')' + C +' A20_N70('+%CHAR(A20_N70)+')' + C +' A20_N112('+%CHAR(A20_N112)+')' + C +' A20_N110('+%CHAR(A20_N110)+')' + C +' A20_N309('+%CHAR(A20_N309)+')' + + C £DBG_Str DSPLY + + *--------------------------------------------------------------------- + C SUB_A20_I BEGSR + * + C SETOFF 22 + C SETON 23 + C N2225 DIV 11 A20_N73 + C N22 MVR A20_N70 + C 23100 DIV 9 A20_N112 + C 23 MVR A20_N110 + C A20_N112 DIV A20_N73 A20_N309 + C ENDSR From 45cc2e92a6f2b77de3b5f1a91f4253147d42111d Mon Sep 17 00:00:00 2001 From: Domenico Date: Thu, 14 Mar 2024 14:23:14 +0100 Subject: [PATCH 04/21] Extend MVR parsing to allow for indicators --- rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 b/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 index c94e52bc6..a6c37a809 100644 --- a/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 +++ b/rpgJavaInterpreter-core/src/main/antlr/RpgParser.g4 @@ -1496,8 +1496,8 @@ csMULT: csMVR: CS_FIXED BlankIndicator - BlankFlag - BlankIndicator + (BlankFlag | NoFlag) + (BlankIndicator | GeneralIndicator) CS_BlankFactor operation=OP_MVR cspec_fixed_standard_parts; From 52db12ec9bfb6ccbc8a7f957aa7356bfec6375b7 Mon Sep 17 00:00:00 2001 From: Domenico Date: Thu, 14 Mar 2024 14:45:17 +0100 Subject: [PATCH 05/21] Cleanup --- .../kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index fd6dc60c2..82fecba6b 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -1328,7 +1328,6 @@ internal fun CsSCANContext.toAst(conf: ToAstConfiguration = ToAstConfiguration() val target = if (result.text.isNotBlank()) result.toAst(conf) else null val baseExpression = factor2.factorContent(0).toAst(conf) - // and "B" is the start position to substring, if not specified it returns null val positionExpression = if (factor2.factorContent().size > 1) { factor2.factorContent(1).toAst(conf) From e79ad489ba2b476a0a5cd5fb68996e701648f6dc Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Fri, 15 Mar 2024 09:18:28 +0100 Subject: [PATCH 06/21] Implemented test --- .../smeup/rpgparser/evaluation/SmeupInterpreterTest.kt | 6 ++++++ .../src/test/resources/smeup/T02_A80_P01.rpgle | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T02_A80_P01.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index 9edd3ab72..943dd8282 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -653,4 +653,10 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("123") assertEquals(expected, "smeup/T02_A80_P03".outputOf()) } + + @Test + fun executeT02_A80_P01() { + val expected = listOf("ABCDEFGHIJ12345") + assertEquals(expected, "smeup/T02_A80_P01".outputOf()) + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T02_A80_P01.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T02_A80_P01.rpgle new file mode 100644 index 000000000..6ae94378e --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T02_A80_P01.rpgle @@ -0,0 +1,10 @@ + D A80_A10 S 10 + D A80_N50 S 5 0 + D £DBG_Str S 50 VARYING + + C CLEAR A80_A10 10 + C CLEAR A80_N50 5 0 + C EVAL A80_A10 = 'ABCDEFGHIJ' + C EVAL A80_N50 = 12345 + C EVAL £DBG_Str=%TRIM(A80_A10)+%CHAR(A80_N50) + C £DBG_Str DSPLY \ No newline at end of file From a58c254110724fbfe2850a2770c84dee7f7738a4 Mon Sep 17 00:00:00 2001 From: Domenico Date: Fri, 15 Mar 2024 12:46:14 +0100 Subject: [PATCH 07/21] Add unit tests --- .../evaluation/SmeupInterpreterTest.kt | 18 ++++++++++++++++++ .../src/test/resources/smeup/T10_A45_P04.rpgle | 12 ++++++++++++ .../src/test/resources/smeup/T10_A45_P05.rpgle | 12 ++++++++++++ .../src/test/resources/smeup/T10_A45_P06.rpgle | 12 ++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P04.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P05.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P06.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index cf332b9c7..b75b247f6 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -660,4 +660,22 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("123") assertEquals(expected, "smeup/T02_A80_P03".outputOf()) } + + @Test + fun executeT10_A45_P04() { + val expected = listOf("IND(0)") + assertEquals(expected, "smeup/T10_A45_P04".outputOf()) + } + + @Test + fun executeT10_A45_P05() { + val expected = listOf("IND(1)") + assertEquals(expected, "smeup/T10_A45_P05".outputOf()) + } + + @Test + fun executeT10_A45_P06() { + val expected = listOf("IND(0)") + assertEquals(expected, "smeup/T10_A45_P06".outputOf()) + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P04.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P04.rpgle new file mode 100644 index 000000000..f2fcff064 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P04.rpgle @@ -0,0 +1,12 @@ + D £DBG_Str S 150 VARYING + + D A45_A10 C '0123456789' + D A45_A04 S 4 INZ(' ') + D A45_N10 S 1 0 + + C SETOFF 40 + C EVAL A45_A04='2019' + C A45_A10 CHECK A45_A04 40 + C EVAL £DBG_Str='IND('+%CHAR(*IN40)+')' + + C £DBG_Str DSPLY \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P05.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P05.rpgle new file mode 100644 index 000000000..b1a963b1f --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P05.rpgle @@ -0,0 +1,12 @@ + D £DBG_Str S 150 VARYING + + D A45_A10 C '0123456789' + D A45_A04 S 4 INZ(' ') + D A45_N10 S 1 0 + + C SETOFF 40 + C EVAL A45_A04='201A' + C A45_A10 CHECK A45_A04 40 + C EVAL £DBG_Str='IND('+%CHAR(*IN40)+')' + + C £DBG_Str DSPLY \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P06.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P06.rpgle new file mode 100644 index 000000000..ac102a928 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T10_A45_P06.rpgle @@ -0,0 +1,12 @@ + D £DBG_Str S 150 VARYING + + D A45_A10 C '0123456789' + D A45_A04 S 4 INZ(' ') + D A45_N10 S 1 0 + + C SETOFF 40 + C EVAL A45_A04='201A' + C A45_A10 CHECK A45_A04 40 + C EVAL £DBG_Str='IND('+%CHAR(*IN40)+')' + + C £DBG_Str DSPLY \ No newline at end of file From 113fb4c6de9978c2c579d34e9cfa7e311dac1ad2 Mon Sep 17 00:00:00 2001 From: Domenico Date: Fri, 15 Mar 2024 12:46:34 +0100 Subject: [PATCH 08/21] Add support for indicators in EQ position --- .../com/smeup/rpgparser/interpreter/values.kt | 4 ++++ .../rpgparser/parsing/parsetreetoast/misc.kt | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/values.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/values.kt index c404b7f31..d9b6cee70 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/values.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/values.kt @@ -314,6 +314,10 @@ data class IntValue(val value: Long) : NumberValue() { return StringValue(render()) } + override fun asBoolean(): BooleanValue { + return BooleanValue(value > 0) + } + operator fun plus(other: IntValue) = IntValue(this.bigDecimal.plus(other.bigDecimal).longValueExact()) operator fun minus(other: IntValue) = IntValue(this.bigDecimal.minus(other.bigDecimal).longValueExact()) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index e9cc0ddf4..831faaaa3 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -1031,10 +1031,10 @@ internal fun ResultTypeContext.toAst(conf: ToAstConfiguration = ToAstConfigurati // what kind of expression is this val position = toPosition(conf.considerPosition) - if (text.contains('.')) { - return handleParsingOfTargets(text, position) + return if (text.contains('.')) { + handleParsingOfTargets(text, position) } else { - return annidatedReferenceExpression(text, position) + annidatedReferenceExpression(text, position) } } @@ -1345,11 +1345,19 @@ internal fun CsCHECKContext.toAst(conf: ToAstConfiguration): Statement { val result = this.cspec_fixed_standard_parts().result val dataDefinition = this.cspec_fixed_standard_parts().toDataDefinition(result.text, position, conf) + val eqIndicator = this.cspec_fixed_standard_parts().resultIndicator(2)?.text + + val wrongCharExpression = when { + result != null && result.text.isNotBlank() -> result.toAst(conf) + !eqIndicator.isNullOrBlank() -> IndicatorExpr(eqIndicator.toIndicatorKey(), position) + else -> null + } + return CheckStmt( factor1, expression, startPosition ?: 1, - this.cspec_fixed_standard_parts()?.result?.toAst(conf), + wrongCharExpression, dataDefinition, position ) From 68e2b1975325e5a89d5d3285a1303c7bac4f167e Mon Sep 17 00:00:00 2001 From: Domenico Date: Mon, 18 Mar 2024 14:14:27 +0100 Subject: [PATCH 09/21] Add unit tests for MonitorStmt --- .../evaluation/SmeupInterpreterTest.kt | 24 +++++++ .../test/resources/smeup/T11_A10_P01.rpgle | 13 ++++ .../test/resources/smeup/T11_A10_P02.rpgle | 31 ++++++++++ .../test/resources/smeup/T11_A10_P03.rpgle | 36 +++++++++++ .../test/resources/smeup/T11_A10_P04.rpgle | 62 +++++++++++++++++++ 5 files changed, 166 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P01.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P02.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P03.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P04.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index 4052ff83e..30071716a 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -666,4 +666,28 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("PROVA") assertEquals(expected, "smeup/T02_A80_P02".outputOf()) } + + @Test + fun executeT11_A10_P01() { + val expected = listOf("BLOCCO; ERR_ZERO_DIV;") + assertEquals(expected, "smeup/T11_A10_P01".outputOf()) + } + + @Test + fun executeT11_A10_P02() { + val expected = listOf("BLOCCO1; BLOCCO2; BLOCCO3; ERR_ZERO_DIV; FINE_BLOCCO3;; ERR_ZERO_DIV; FINE_BLOCCO2;; ERR_ZERO_DIV; FINE_BLOCCO1;") + assertEquals(expected, "smeup/T11_A10_P02".outputOf()) + } + + @Test + fun executeT11_A10_P03() { + val expected = listOf("DENTRO_IF(BLOCCO; ERR_ZERO_DIV;) DENTRO_DO(BLOCCO; ERR_ZERO_DIV;BLOCCO; ERR_ZERO_DIV;) DENTRO_WHEN(BLOCCO; ERR_ZERO_DIV;) DENTRO_OTHER(BLOCCO; ERR_ZERO_DIV;)") + assertEquals(expected, "smeup/T11_A10_P03".outputOf()) + } + + @Test + fun executeT11_A10_P04() { + val expected = listOf("DENTRO_IF(BLOCCO; ERR_ZERO_DIV;) DENTRO_DO(BLOCCO; ERR_ZERO_DIV;) DENTRO_WHEN(BLOCCO; ERR_ZERO_DIV;) DENTRO_OTHER(BLOCCO; ERR_ZERO_DIV;)") + assertEquals(expected, "smeup/T11_A10_P04".outputOf()) + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P01.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P01.rpgle new file mode 100644 index 000000000..16f593448 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P01.rpgle @@ -0,0 +1,13 @@ + D £DBG_Str S 150 VARYING + D T11_A10_A20A S 2 0 INZ(10) + D T11_A10_A20B S 2 0 INZ(0) + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; FINE_BLOCCO;' + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C £DBG_Str DSPLY \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P02.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P02.rpgle new file mode 100644 index 000000000..4386ee2e5 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P02.rpgle @@ -0,0 +1,31 @@ + D £DBG_Str S 150 VARYING + D T11_A10_A20A S 2 0 INZ(10) + D T11_A10_A20B S 2 0 INZ(0) + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO1;' + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' BLOCCO2;' + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' BLOCCO3' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' FINE_BLOCCO3;' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' FINE_BLOCCO2;' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' FINE_BLOCCO1;' + C £DBG_Str DSPLY diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P03.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P03.rpgle new file mode 100644 index 000000000..ddebc84b8 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P03.rpgle @@ -0,0 +1,36 @@ + D £DBG_Str S 180 VARYING + D T11_A10_A20A S 2 0 INZ(10) + D T11_A10_A20B S 2 0 INZ(0) + C EVAL £DBG_Str='DENTRO_IF(' + C IF 'A'='A' + C EXSR SUB_SEZ_A10 + C ENDIF + C EVAL £DBG_Str=%TRIM(£DBG_Str)+') DENTRO_DO(' + C DO 2 + C EXSR SUB_SEZ_A10 + C ENDDO + C EVAL £DBG_Str=%TRIM(£DBG_Str)+') DENTRO_WHEN(' + C SELECT + C WHEN 'A'='A' + C EXSR SUB_SEZ_A10 + C ENDSL + C EVAL £DBG_Str=%TRIM(£DBG_Str)+') DENTRO_OTHER(' + C SELECT + C WHEN 'A'='B' + C OTHER + C EXSR SUB_SEZ_A10 + C ENDSL + C EVAL £DBG_Str=%TRIM(£DBG_Str)+')' + C £DBG_Str DSPLY + + C SUB_SEZ_A10 BEGSR + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; FINE_BLOCCO;' + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C ENDSR \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P04.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P04.rpgle new file mode 100644 index 000000000..af3c386c2 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T11_A10_P04.rpgle @@ -0,0 +1,62 @@ + D £DBG_Str S 150 VARYING + D T11_A10_A20A S 2 0 INZ(10) + D T11_A10_A20B S 2 0 INZ(0) + C MONITOR + C EVAL £DBG_Str='DENTRO_IF(' + C IF 'A'='A' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; FINE_BLOCCO;' + C ENDIF + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+')' + * + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' DENTRO_DO(' + C DO 2 + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; FINE_BLOCCO;' + C ENDDO + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+')' + * + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' DENTRO_WHEN(' + C SELECT + C WHEN 'A'='A' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; FINE_BLOCCO;' + C ENDSL + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+')' + * + C MONITOR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+' DENTRO_OTHER(' + C SELECT + C WHEN 'A'='B' + C OTHER + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'BLOCCO' + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; '+ + C %CHAR(T11_A10_A20A/T11_A10_A20B) + C EVAL £DBG_Str=%TRIM(£DBG_Str)+'; FINE_BLOCCO;' + C ENDSL + C ON-ERROR + C EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C '; ERR_ZERO_DIV;' + C ENDMON + C EVAL £DBG_Str=%TRIM(£DBG_Str)+')' + C £DBG_Str DSPLY \ No newline at end of file From 30dc3ceed0541c01d38fbdc3df6744520093917f Mon Sep 17 00:00:00 2001 From: Domenico Date: Mon, 18 Mar 2024 14:16:30 +0100 Subject: [PATCH 10/21] Implement MonitorStmt --- .../interpreter/ExpressionEvaluation.kt | 28 ++++----- .../com/smeup/rpgparser/interpreter/logs.kt | 21 +++++++ .../rpgparser/parsing/ast/serialization.kt | 1 + .../smeup/rpgparser/parsing/ast/statements.kt | 61 ++++++++++++++++++- .../rpgparser/parsing/parsetreetoast/misc.kt | 5 +- .../parsing/parsetreetoast/statements.kt | 24 ++++++++ 6 files changed, 120 insertions(+), 20 deletions(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt index 58d9f94d5..a419a0e74 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/ExpressionEvaluation.kt @@ -206,21 +206,19 @@ class ExpressionEvaluation( override fun eval(expression: CharExpr): Value { val value = expression.value.evalWith(this) - return if (expression.value is DivExpr) { - // are always return 10 decimal digits - // fill with 0 if necessary - if (value.asDecimal().value.scale() != 0) { - val numeDecimals = value.asDecimal().value.scale() - if (numeDecimals < 10) { - StringValue(value.stringRepresentation(expression.format) + "0".repeat(10 - numeDecimals)) - } else { - StringValue(value.stringRepresentation(expression.format).trim()) - } - } else { - StringValue(value.stringRepresentation(expression.format) + ".0000000000") - } - } else { - StringValue(value.stringRepresentation(expression.format)) + val representation = value.stringRepresentation(expression.format) + + if (expression.value !is DivExpr) { + return StringValue(representation) + } + + // Decimals are always returned with 10 decimal digits + // fill with 0 if necessary + val numDecimals = value.asDecimal().value.scale() + return when { + numDecimals == 0 -> StringValue("$representation.0000000000") + numDecimals < 10 -> StringValue(representation + "0".repeat(10 - numDecimals)) + else -> StringValue(representation.trim()) } } diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/logs.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/logs.kt index e5302877c..73c63f9a4 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/logs.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/logs.kt @@ -411,6 +411,17 @@ class CasOtherExecutionLogEntry(programName: String, val other: CaseOtherClause, } } +class MonitorExecutionLogEntry(programName: String, val statement: MonitorStmt) : LogEntry(programName) { + override fun toString(): String { + return "executing MONITOR" + } + + override fun renderStatement(channel: String, filename: String, sep: String): String { + val data = "MONITOR" + return renderHeader(channel, filename, statement.startLine(), sep) + data + } +} + class IfExecutionLogEntry(programName: String, val statement: IfStmt, val result: Value) : LogEntry(programName) { override fun toString(): String { return "executing IF" @@ -442,6 +453,16 @@ class ElseExecutionLogEntry(programName: String, val statement: ElseClause, val } } +class OnErrorExecutionLogEntry(programName: String, val statement: OnErrorClause) : LogEntry(programName) { + override fun toString(): String { + return "executing ON-ERROR" + } + override fun renderStatement(channel: String, filename: String, sep: String): String { + val data = "ON-ERROR" + return renderHeader(channel, filename, statement.startLine(), sep) + data + } +} + class EvaluationLogEntry(programName: String, val statement: EvalStmt, val value: Value?) : LogEntry(programName) { override fun toString(): String { return "evaluating $statement as $value" diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/serialization.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/serialization.kt index f58318903..ed2fb4c07 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/serialization.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/serialization.kt @@ -68,6 +68,7 @@ private val modules = SerializersModule { subclass(LeaveSrStmt::class) subclass(LeaveStmt::class) subclass(LookupStmt::class) + subclass(MonitorStmt::class) subclass(MoveAStmt::class) subclass(MoveLStmt::class) subclass(MoveStmt::class) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt index 16d630be7..8e6ae5dca 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt @@ -814,6 +814,62 @@ private constructor(val name: String, val fields: List, override val pos } } +@Serializable +data class MonitorStmt( + @SerialName("body") + val monitorBody: List, + val onErrorClauses: List = emptyList(), + override val position: Position? = null +) : Statement(position), CompositeStatement { + + // Since that this property is a collection achieved from thenBody + elseIfClauses + elseClause, this annotation + // is necessary to avoid that the same node is processed more than ones, thing that it would cause that the same + // ErrorEvent is fired more times + @Derived + @Transient + override val body: List = mutableListOf().apply { + addAll(monitorBody) + onErrorClauses.forEach { addAll(it.body) } + } + + override fun accept(mutes: MutableMap, start: Int, end: Int): MutableList { + // check if the annotation is just before the ELSE + val muteAttached: MutableList = mutableListOf() + + // Process the body statements + muteAttached.addAll( + acceptBody(monitorBody, mutes, this.position!!.start.line, this.position.end.line) + ) + + // Process the ON ERROR + onErrorClauses.forEach { + muteAttached.addAll( + acceptBody(it.body, mutes, it.position!!.start.line, it.position.end.line) + ) + } + + return muteAttached + } + + override fun execute(interpreter: InterpreterCore) { + interpreter.log { + MonitorExecutionLogEntry( + interpreter.getInterpretationContext().currentProgramName, + this + ) + } + + try { + interpreter.execute(this.monitorBody) + } catch (_: Exception) { + onErrorClauses.forEach { + interpreter.log { OnErrorExecutionLogEntry(interpreter.getInterpretationContext().currentProgramName, it) } + interpreter.execute(it.body) + } + } + } +} + @Serializable data class IfStmt( val condition: Expression, @@ -889,6 +945,9 @@ data class IfStmt( } } +@Serializable +data class OnErrorClause(override val body: List, override val position: Position? = null) : Node(position), CompositeStatement + @Serializable data class ElseClause(override val body: List, override val position: Position? = null) : Node(position), CompositeStatement @@ -1061,7 +1120,7 @@ data class DefineStmt( } else { val inStatementDataDefinition = containingCU.main.stmts - .filterIsInstance(StatementThatCanDefineData::class.java) + .filterIsInstance() .filter { it != this } .asSequence() .map(StatementThatCanDefineData::dataDefinition) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index e9cc0ddf4..877657f1d 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -1121,10 +1121,7 @@ internal fun Cspec_fixed_standard_partsContext.toDataDefinition( position: Position?, conf: ToAstConfiguration ): InStatementDataDefinition? { - val len = this.len.asInt() - if (len == null) { - return null - } + val len = this.len.asInt() ?: return null val decimals = this.decimalPositions.asInt() val initialValue = this.factor2Expression(conf) return InStatementDataDefinition(name, dataType(len, decimals), position, initializationValue = initialValue) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/statements.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/statements.kt index 3dd55e631..e8bb11dc6 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/statements.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/statements.kt @@ -56,6 +56,12 @@ internal fun BlockContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()) this.csDOWxx() != null -> this.csDOWxx().toAst(blockContext = this, conf = conf) this.forstatement() != null -> this.forstatement().toAst(conf) this.begindou() != null -> this.begindou().toAst(blockContext = this, conf = conf) + this.monitorstatement() != null -> this.monitorstatement().let { + it.beginmonitor().csMONITOR().cspec_fixed_standard_parts().validate( + stmt = it.toAst(conf = conf), + conf = conf + ) + } else -> todo(message = "Missing composite statement implementation for this block: ${this.text}", conf = conf) } } @@ -358,6 +364,18 @@ internal fun toAst(conf: ToAstConfiguration = ToAstConfiguration()): SelectOther TODO("OtherContext.toAst with $conf") } +internal fun RpgParser.MonitorstatementContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): MonitorStmt { + val position = toPosition(conf.considerPosition) + val statements = this.statement().mapNotNull { + it.toAst(conf) + } + val onErrorClauses = this.onError().mapNotNull { + it.toAst(conf) + } + + return MonitorStmt(statements, onErrorClauses, position) +} + internal fun RpgParser.IfstatementContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): IfStmt { val position = toPosition(conf.considerPosition) return if (this.beginif().fixedexpression != null) { @@ -387,6 +405,12 @@ internal fun RpgParser.IfstatementContext.toAst(conf: ToAstConfiguration = ToAst } } +internal fun RpgParser.OnErrorContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): OnErrorClause { + val body = this.statement().mapNotNull { kotlin.runCatching { it.toAst(conf) }.getOrNull() } + val position = toPosition(conf.considerPosition) + return OnErrorClause(body, position) +} + internal fun RpgParser.ElseClauseContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): ElseClause { return ElseClause(this.statement().mapNotNull { kotlin.runCatching { it.toAst(conf) }.getOrNull() }, toPosition(conf.considerPosition)) } From 229b1953107b86730cc2fb5064b3e629614c1f43 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 08:27:40 +0100 Subject: [PATCH 11/21] Move test to MULANGT10BaseCodopTest --- .../rpgparser/evaluation/SmeupInterpreterTest.kt | 6 ------ .../rpgparser/smeup/MULANGT10BaseCodopTest.kt | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index 5b7da5187..afeae5b9c 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -678,10 +678,4 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("Lunghezza: 32580 Contenuto: - - - - - - -") assertEquals(expected, "smeup/T40_A30_P01".outputOf(configuration = smeupConfig)) } - - @Test - fun executeT10_A20_P52() { - val expected = listOf("A20_N73(2.272) A20_N70(0) A20_N112(11.11) A20_N110(0) A20_N309(4.889964788)") - assertEquals(expected, "smeup/T10_A20_P52".outputOf(configuration = smeupConfig)) - } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt index 9d46c6f12..bd7521a70 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt @@ -1,3 +1,16 @@ package com.smeup.rpgparser.smeup -open class MULANGT10BaseCodopTest : MULANGTTest() \ No newline at end of file +import org.junit.Test +import kotlin.test.assertEquals + +open class MULANGT10BaseCodopTest : MULANGTTest() { + /** + * DIV e MVR con indicatori + * @see #245 + */ + @Test + fun executeT10_A20_P52() { + val expected = listOf("A20_N73(2.272) A20_N70(0) A20_N112(11.11) A20_N110(0) A20_N309(4.889964788)") + assertEquals(expected, "smeup/T10_A20_P52".outputOf(configuration = smeupConfig)) + } +} \ No newline at end of file From 749c7d53e9d31a7f80c1c33f9315413cbc13b260 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 08:31:39 +0100 Subject: [PATCH 12/21] Move test to MULANGT11Codop2Test --- .../evaluation/SmeupInterpreterTest.kt | 24 ---------- .../rpgparser/smeup/MULANGT11Codop2Test.kt | 45 ++++++++++++++++++- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index 389937dc2..0d845883a 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -666,28 +666,4 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("Lunghezza: 32580 Contenuto: - - - - - - -") assertEquals(expected, "smeup/T40_A30_P01".outputOf(configuration = smeupConfig)) } - - @Test - fun executeT11_A10_P01() { - val expected = listOf("BLOCCO; ERR_ZERO_DIV;") - assertEquals(expected, "smeup/T11_A10_P01".outputOf()) - } - - @Test - fun executeT11_A10_P02() { - val expected = listOf("BLOCCO1; BLOCCO2; BLOCCO3; ERR_ZERO_DIV; FINE_BLOCCO3;; ERR_ZERO_DIV; FINE_BLOCCO2;; ERR_ZERO_DIV; FINE_BLOCCO1;") - assertEquals(expected, "smeup/T11_A10_P02".outputOf()) - } - - @Test - fun executeT11_A10_P03() { - val expected = listOf("DENTRO_IF(BLOCCO; ERR_ZERO_DIV;) DENTRO_DO(BLOCCO; ERR_ZERO_DIV;BLOCCO; ERR_ZERO_DIV;) DENTRO_WHEN(BLOCCO; ERR_ZERO_DIV;) DENTRO_OTHER(BLOCCO; ERR_ZERO_DIV;)") - assertEquals(expected, "smeup/T11_A10_P03".outputOf()) - } - - @Test - fun executeT11_A10_P04() { - val expected = listOf("DENTRO_IF(BLOCCO; ERR_ZERO_DIV;) DENTRO_DO(BLOCCO; ERR_ZERO_DIV;) DENTRO_WHEN(BLOCCO; ERR_ZERO_DIV;) DENTRO_OTHER(BLOCCO; ERR_ZERO_DIV;)") - assertEquals(expected, "smeup/T11_A10_P04".outputOf()) - } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt index f45bd304b..61d651633 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt @@ -1,3 +1,46 @@ package com.smeup.rpgparser.smeup -open class MULANGT11Codop2Test : MULANGTTest() \ No newline at end of file +import org.junit.Test +import kotlin.test.assertEquals + +open class MULANGT11Codop2Test : MULANGTTest() { + /** + * Monitoraggio e cattura errore + * @see #241 + */ + @Test + fun executeT11_A10_P01() { + val expected = listOf("BLOCCO; ERR_ZERO_DIV;") + assertEquals(expected, "smeup/T11_A10_P01".outputOf()) + } + + /** + * Specifiche MONITOR annidiate + * @see #241 + */ + @Test + fun executeT11_A10_P02() { + val expected = listOf("BLOCCO1; BLOCCO2; BLOCCO3; ERR_ZERO_DIV; FINE_BLOCCO3;; ERR_ZERO_DIV; FINE_BLOCCO2;; ERR_ZERO_DIV; FINE_BLOCCO1;") + assertEquals(expected, "smeup/T11_A10_P02".outputOf()) + } + + /** + * Specifiche MONITOR annidiate in IF, DO e SELECT + * @see #241 + */ + @Test + fun executeT11_A10_P03() { + val expected = listOf("DENTRO_IF(BLOCCO; ERR_ZERO_DIV;) DENTRO_DO(BLOCCO; ERR_ZERO_DIV;BLOCCO; ERR_ZERO_DIV;) DENTRO_WHEN(BLOCCO; ERR_ZERO_DIV;) DENTRO_OTHER(BLOCCO; ERR_ZERO_DIV;)") + assertEquals(expected, "smeup/T11_A10_P03".outputOf()) + } + + /** + * Specifiche IF, DO e SELECT in MONITOR + * @see #241 + */ + @Test + fun executeT11_A10_P04() { + val expected = listOf("DENTRO_IF(BLOCCO; ERR_ZERO_DIV;) DENTRO_DO(BLOCCO; ERR_ZERO_DIV;) DENTRO_WHEN(BLOCCO; ERR_ZERO_DIV;) DENTRO_OTHER(BLOCCO; ERR_ZERO_DIV;)") + assertEquals(expected, "smeup/T11_A10_P04".outputOf()) + } +} \ No newline at end of file From 6b0396cdb7e7d86cc2222e43a032e4900e9536b2 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 09:00:51 +0100 Subject: [PATCH 13/21] Move tests to MULANGT10BaseCodopTest --- .../evaluation/SmeupInterpreterTest.kt | 18 ---------- .../rpgparser/smeup/MULANGT10BaseCodopTest.kt | 35 ++++++++++++++++++- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index 9be2b68da..d949ee3d7 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -672,22 +672,4 @@ open class SmeupInterpreterTest : AbstractTest() { val expected = listOf("Lunghezza: 32580 Contenuto: - - - - - - -") assertEquals(expected, "smeup/T40_A30_P01".outputOf(configuration = smeupConfig)) } - - @Test - fun executeT10_A45_P04() { - val expected = listOf("IND(0)") - assertEquals(expected, "smeup/T10_A45_P04".outputOf()) - } - - @Test - fun executeT10_A45_P05() { - val expected = listOf("IND(1)") - assertEquals(expected, "smeup/T10_A45_P05".outputOf()) - } - - @Test - fun executeT10_A45_P06() { - val expected = listOf("IND(0)") - assertEquals(expected, "smeup/T10_A45_P06".outputOf()) - } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt index 9d46c6f12..d2d2fe7cb 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt @@ -1,3 +1,36 @@ package com.smeup.rpgparser.smeup -open class MULANGT10BaseCodopTest : MULANGTTest() \ No newline at end of file +import org.junit.Test +import kotlin.test.assertEquals + +open class MULANGT10BaseCodopTest : MULANGTTest() { + /** + * Check con indicatore con verifica a buon fine + * @see #246 + */ + @Test + fun executeT10_A45_P04() { + val expected = listOf("IND(0)") + assertEquals(expected, "smeup/T10_A45_P04".outputOf()) + } + + /** + * Check con indicatore con verifica non ok + * @see #246 + */ + @Test + fun executeT10_A45_P05() { + val expected = listOf("IND(1)") + assertEquals(expected, "smeup/T10_A45_P05".outputOf()) + } + + /** + * Check con indicatore di errore + * @see #246 + */ + @Test + fun executeT10_A45_P06() { + val expected = listOf("IND(0)") + assertEquals(expected, "smeup/T10_A45_P06".outputOf()) + } +} \ No newline at end of file From 10894cc94badc9ea6332cdaeb2ca6d3855395db6 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 11:40:17 +0100 Subject: [PATCH 14/21] Add unit test --- .../rpgparser/smeup/MULANGT40ArrayAndDSTest.kt | 15 ++++++++++++++- .../src/test/resources/smeup/T40_A10_P10.rpgle | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T40_A10_P10.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt index 53c400fe2..d88696736 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt @@ -1,3 +1,16 @@ package com.smeup.rpgparser.smeup -open class MULANGT40ArrayAndDSTest : MULANGTTest() \ No newline at end of file +import org.junit.Test +import kotlin.test.assertEquals + +open class MULANGT40ArrayAndDSTest : MULANGTTest() { + /** + * Reset con definizione inline + * @see #242 + */ + @Test + fun executeT40_A10_P10() { + val expected = listOf("Contenuto Pre-RESET: AAA - Contenuto Post-RESET:") + assertEquals(expected, "smeup/T40_A10_P10".outputOf(configuration = smeupConfig)) + } +} \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T40_A10_P10.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T40_A10_P10.rpgle new file mode 100644 index 000000000..fc9ee5879 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T40_A10_P10.rpgle @@ -0,0 +1,7 @@ + D £DBG_Str S 150 VARYING + C EVAL A10_D1='AAA' + C EVAL £DBG_Str='Contenuto Pre-RESET: '+A10_D1 + C RESET A10_D1 10 + C EVAL £DBG_Str=%TRIMR(£DBG_Str) + C +' - Contenuto Post-RESET: '+A10_D1 + C £DBG_Str DSPLY From 7b65b54b31f13499672add6443a02170bea11742 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 11:40:54 +0100 Subject: [PATCH 15/21] Add support for ResetStmt inline declarations --- .../smeup/rpgparser/parsing/ast/statements.kt | 27 +++++++++++-------- .../rpgparser/parsing/parsetreetoast/misc.kt | 5 ++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt index 16d630be7..512924a9f 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt @@ -1968,22 +1968,27 @@ data class XlateStmt( @Serializable data class ResetStmt( val name: String, + @Derived val dataDefinition: InStatementDataDefinition? = null, override val position: Position? = null -) : Statement(position) { +) : Statement(position), StatementThatCanDefineData { override fun execute(interpreter: InterpreterCore) { - val dataDefinition = interpreter.dataDefinitionByName(name) - require(dataDefinition != null) { - this.error("Data definition $name not found") - } - require(dataDefinition is DataDefinition) { - this.error("Data definition $name is not an instance of DataDefinition") - } - require(dataDefinition.defaultValue != null) { - this.error("Data definition $name has no default value") + when (val dataDefinition = interpreter.dataDefinitionByName(name)) { + null -> this.error("Data definition $name not found") + is DataDefinition -> { + require(dataDefinition.defaultValue != null) { + this.error("Data definition $name has no default value") + } + interpreter.assign(dataDefinition, dataDefinition.defaultValue!!) + } + is InStatementDataDefinition -> { + interpreter.assign(dataDefinition, dataDefinition.type.blank()) + } + else -> this.error("Data definition $name is not a valid instance of DataDefinition") } - interpreter.assign(dataDefinition, dataDefinition.defaultValue!!) } + + override fun dataDefinition(): List = dataDefinition?.let { listOf(it) } ?: emptyList() } @Serializable diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt index e9cc0ddf4..4c07b4b23 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt @@ -1940,6 +1940,7 @@ internal fun CsCLOSEContext.toAst(conf: ToAstConfiguration = ToAstConfiguration( internal fun CsRESETContext.toAst(conf: ToAstConfiguration = ToAstConfiguration()): Statement { val position = toPosition(conf.considerPosition) + require(this.cspec_fixed_standard_parts().factor().text.isEmptyTrim()) { "RESET operation does not support factor1" } @@ -1950,8 +1951,12 @@ internal fun CsRESETContext.toAst(conf: ToAstConfiguration = ToAstConfiguration( require(!result.isEmptyTrim()) { "RESET operation requires result" } + + val dataDefinition = this.cspec_fixed_standard_parts().toDataDefinition(result, position, conf) + return ResetStmt( name = result, + dataDefinition = dataDefinition, position = position ) } From 933c6eee4674e91a5311eeb3199d6ddaceaf8893 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 13:04:50 +0100 Subject: [PATCH 16/21] Update test description --- .../kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt index d88696736..5a740c0e4 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT40ArrayAndDSTest.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals open class MULANGT40ArrayAndDSTest : MULANGTTest() { /** - * Reset con definizione inline + * Reset with inline declaration * @see #242 */ @Test From 267fc4739d31157ad3ede7c9fec7db04775fca82 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 13:06:51 +0100 Subject: [PATCH 17/21] Update test description --- .../com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt index 61d651633..8bda0a157 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT11Codop2Test.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals open class MULANGT11Codop2Test : MULANGTTest() { /** - * Monitoraggio e cattura errore + * MONITOR and error catching * @see #241 */ @Test @@ -15,7 +15,7 @@ open class MULANGT11Codop2Test : MULANGTTest() { } /** - * Specifiche MONITOR annidiate + * Nested MONITOR statements * @see #241 */ @Test @@ -25,7 +25,7 @@ open class MULANGT11Codop2Test : MULANGTTest() { } /** - * Specifiche MONITOR annidiate in IF, DO e SELECT + * MONITOR nested in IF, DO and SELECT * @see #241 */ @Test @@ -35,7 +35,7 @@ open class MULANGT11Codop2Test : MULANGTTest() { } /** - * Specifiche IF, DO e SELECT in MONITOR + * IF, DO and SELECT in MONITOR * @see #241 */ @Test From 39d13863f79b9183f4d74ca4e79d01071332aa10 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 13:08:54 +0100 Subject: [PATCH 18/21] Update test description --- .../com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt index d2d2fe7cb..cdfd829ee 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals open class MULANGT10BaseCodopTest : MULANGTTest() { /** - * Check con indicatore con verifica a buon fine + * Positive Check with indicator * @see #246 */ @Test @@ -15,7 +15,7 @@ open class MULANGT10BaseCodopTest : MULANGTTest() { } /** - * Check con indicatore con verifica non ok + * Negative Check with indicator * @see #246 */ @Test @@ -25,7 +25,7 @@ open class MULANGT10BaseCodopTest : MULANGTTest() { } /** - * Check con indicatore di errore + * Check with error indicator * @see #246 */ @Test From 5edf31064064fcd8b6e55fc17fa91ae0fed1470d Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 13:09:36 +0100 Subject: [PATCH 19/21] Update test description --- .../kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt index bd7521a70..61423f3eb 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals open class MULANGT10BaseCodopTest : MULANGTTest() { /** - * DIV e MVR con indicatori + * DIV and MVR with indicators * @see #245 */ @Test From 3ee154953a81fbe4c1d5003ecdc55b2d597666c5 Mon Sep 17 00:00:00 2001 From: Domenico Date: Tue, 19 Mar 2024 13:15:14 +0100 Subject: [PATCH 20/21] Move unit tests to MULANGT10BaseCodopTest --- .../evaluation/SmeupInterpreterTest.kt | 12 --------- .../rpgparser/smeup/MULANGT10BaseCodopTest.kt | 25 ++++++++++++++++++- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index f9fe3310b..afeae5b9c 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -621,18 +621,6 @@ open class SmeupInterpreterTest : AbstractTest() { assertEquals(expected, "smeup/T10_A20_P47".outputOf()) } - @Test - fun executeT10_A35_P08() { - val expected = listOf("A35_AR1(2)(123&5) IN45(1)") - assertEquals(expected, "smeup/T10_A35_P08".outputOf(configuration = smeupConfig)) - } - - @Test - fun executeT10_A35_P10() { - val expected = listOf("A35_AR2(01)(5) A35_AR2(02)(6) A35_AR2(03)(0) IN20(1)") - assertEquals(expected, "smeup/T10_A35_P10".outputOf(configuration = smeupConfig)) - } - @Test fun executeT18_A10_P01() { val expected = listOf("Ritorno_Procedura") diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt index 9d46c6f12..0b10a127e 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT10BaseCodopTest.kt @@ -1,3 +1,26 @@ package com.smeup.rpgparser.smeup -open class MULANGT10BaseCodopTest : MULANGTTest() \ No newline at end of file +import org.junit.Test +import kotlin.test.assertEquals + +open class MULANGT10BaseCodopTest : MULANGTTest() { + /** + * SCAN with array in input + * @see #218 + */ + @Test + fun executeT10_A35_P08() { + val expected = listOf("A35_AR1(2)(123&5) IN45(1)") + assertEquals(expected, "smeup/T10_A35_P08".outputOf(configuration = smeupConfig)) + } + + /** + * SCAN with array in result + * @see #244 + */ + @Test + fun executeT10_A35_P10() { + val expected = listOf("A35_AR2(01)(5) A35_AR2(02)(6) A35_AR2(03)(0) IN20(1)") + assertEquals(expected, "smeup/T10_A35_P10".outputOf(configuration = smeupConfig)) + } +} \ No newline at end of file From d3cd7a2f8cdf9d8d0228d89a7811d6454c9bd5ce Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Tue, 19 Mar 2024 14:03:49 +0100 Subject: [PATCH 21/21] Fixed comments --- .../com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt index f69d2c890..8c630cf1a 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/smeup/MULANGT02ConstAndDSpecTest.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals open class MULANGT02ConstAndDSpecTest : MULANGTTest() { /** - * Data reference - Definizione inline e in specifiche D + * Data reference - Inline definition * @see #250 */ @Test