From d0de1dfb77738f62705bbc92238aef49bc7f13bf Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Mon, 4 Mar 2024 15:32:34 +0100 Subject: [PATCH 1/6] Implemented case of test --- .../evaluation/SmeupInterpreterTest.kt | 7 ++ .../test/resources/smeup/T60_A10_P01.rpgle | 108 ++++++++++++++++++ .../resources/smeup/metadata/MLNGT60V.json | 19 +++ 3 files changed, 134 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/T60_A10_P01.rpgle create mode 100644 rpgJavaInterpreter-core/src/test/resources/smeup/metadata/MLNGT60V.json 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 edc651468..d139e3b5b 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 @@ -2,6 +2,7 @@ package com.smeup.rpgparser.evaluation import com.smeup.dbnative.DBNativeAccessConfig import com.smeup.rpgparser.AbstractTest +import com.smeup.rpgparser.assertCanBeParsed import com.smeup.rpgparser.execution.Configuration import com.smeup.rpgparser.execution.ReloadConfig import com.smeup.rpgparser.execution.SimpleReloadConfig @@ -478,4 +479,10 @@ open class SmeupInterpreterTest : AbstractTest() { ) assertEquals(expected, "smeup/T02_A30_P03".outputOf()) } + + @Test + fun executeT60_A10_P01() { + val expected = listOf("KA(0)KB(0)KC(0)KD(0)KE(0)KF(0)KG(0)KH(0)KI(0)KJ(0)KK(0)KL(0)KM(0)KN(0)KP(0)KQ(0)KR(0)KS(0)KT(0)KU(0)KV(0)KW(0)KX(0)KY(0)") + assertEquals(expected, "smeup/T60_A10_P01".outputOf(configuration = smeupConfig)) + } } \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T60_A10_P01.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T60_A10_P01.rpgle new file mode 100644 index 000000000..6c4a3982c --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T60_A10_P01.rpgle @@ -0,0 +1,108 @@ + D £DBG_Str S 250 + D $OP S 1N INZ(*ON) + + D* Test sugli indicatori delle chiavi KA-KY (F01-F24) + C EVAL £DBG_Str='' + C IF $OP=*OFF + C OPEN MLNGT60V + C ENDIF + C KA EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KA(1) ' + C NKA EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KA(0) ' + C KB EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KB(1) ' + C NKB EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KB(0) ' + C KC EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KC(1) ' + C NKC EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KC(0) ' + C KD EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KD(1) ' + C NKD EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KD(0) ' + C KE EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KE(1) ' + C NKE EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KE(0) ' + C KF EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KF(1) ' + C NKF EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KF(0) ' + C KG EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KG(1) ' + C NKG EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KG(0) ' + C KH EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KH(1) ' + C NKH EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KH(0) ' + C KI EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KI(1) ' + C NKI EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KI(0) ' + C KJ EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KJ(1) ' + C NKJ EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KJ(0) ' + C KK EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KK(1) ' + C NKK EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KK(0) ' + C KL EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KL(1) ' + C NKL EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KL(0) ' + C KM EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KM(1) ' + C NKM EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KM(0) ' + C KN EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KN(1) ' + C NKN EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KN(0) ' + C KP EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KP(1) ' + C NKP EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KP(0) ' + C KQ EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KQ(1) ' + C NKQ EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KQ(0) ' + C KR EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KR(1) ' + C NKR EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KR(0) ' + C KS EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KS(1) ' + C NKS EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KS(0) ' + C KT EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KT(1) ' + C NKT EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KT(0) ' + C KU EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KU(1) ' + C NKU EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KU(0) ' + C KV EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KV(1) ' + C NKV EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KV(0) ' + C KW EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KW(1) ' + C NKW EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KW(0) ' + C KX EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KX(1) ' + C NKX EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KX(0) ' + C KY EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KY(1)' + C NKY EVAL £DBG_Str=%TRIM(£DBG_Str)+ + C 'KY(0)' + C IF $OP=*OFF + C CLOSE MLNGT60V + C ENDIF + C £DBG_Str DSPLY \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/metadata/MLNGT60V.json b/rpgJavaInterpreter-core/src/test/resources/smeup/metadata/MLNGT60V.json new file mode 100644 index 000000000..27ba6b1a4 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/metadata/MLNGT60V.json @@ -0,0 +1,19 @@ +{"name": "MLNGT60V", + "tableName": "MULANGTF", + "recordFormat": "", + "fields": [ + { "fieldName": "*IN62", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":1, "varying":false}} + , { "fieldName": "*IN96", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":1, "varying":false}} + , { "fieldName": "*IN97", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":1, "varying":false}} + , { "fieldName": "£RASDI", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":15, "varying":false}} + , { "fieldName": "£PDSNP", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":10, "varying":false}} + , { "fieldName": "£PDSJN", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":10, "varying":false}} + , { "fieldName": "£PDSNU", + "type":{"type":"com.smeup.rpgparser.interpreter.StringType","length":10, "varying":false}} + ], "accessFields": []} From 5b3e7d965ec934004d587e9d070c9aa59f3a8261 Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Mon, 4 Mar 2024 16:03:50 +0100 Subject: [PATCH 2/6] Fixed the bug by adding missed enums --- .../smeup/rpgparser/parsing/ast/indicators.kt | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt index 450939bb2..a5435905e 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt @@ -41,7 +41,31 @@ typealias IndicatorKey = Int * Managed indicator types * */ enum class IndicatorType(val range: IntRange) { - Predefined(1..99), + KA(1..1), + KB(2..2), + KC(3..3), + KD(4..4), + KE(5..5), + KF(6..6), + KG(7..7), + KH(8..8), + KI(9..9), + KJ(10..10), + KK(11..11), + KL(12..12), + KM(13..13), + KN(14..14), + KP(15..15), + KQ(16..16), + KR(17..17), + KS(18..18), + KT(19..19), + KU(20..20), + KV(21..21), + KW(22..22), + KX(23..23), + KY(24..24), + Predefined(25..99), LR(100..100), RT(101..101), OC(102..102), From bde54b47b702c02420378b4e595fa711063bca52 Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Mon, 4 Mar 2024 16:04:25 +0100 Subject: [PATCH 3/6] Fix after ktlinCheck --- .../com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt | 1 - 1 file changed, 1 deletion(-) 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 d139e3b5b..37cdda703 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 @@ -2,7 +2,6 @@ package com.smeup.rpgparser.evaluation import com.smeup.dbnative.DBNativeAccessConfig import com.smeup.rpgparser.AbstractTest -import com.smeup.rpgparser.assertCanBeParsed import com.smeup.rpgparser.execution.Configuration import com.smeup.rpgparser.execution.ReloadConfig import com.smeup.rpgparser.execution.SimpleReloadConfig From 175510bd7f52de3a986fa0b534d22294c7eb344c Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Tue, 5 Mar 2024 10:07:32 +0100 Subject: [PATCH 4/6] Fixed the problem when is used predefined indicator --- .../main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt index a5435905e..c9e758711 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt @@ -41,6 +41,7 @@ typealias IndicatorKey = Int * Managed indicator types * */ enum class IndicatorType(val range: IntRange) { + Predefined(1..99), KA(1..1), KB(2..2), KC(3..3), @@ -65,7 +66,6 @@ enum class IndicatorType(val range: IntRange) { KW(22..22), KX(23..23), KY(24..24), - Predefined(25..99), LR(100..100), RT(101..101), OC(102..102), From 15c8300741c75a1b8feaaf4e3724ba00fa1b544c Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Tue, 5 Mar 2024 13:09:41 +0100 Subject: [PATCH 5/6] Implemented `INDIC03` test case --- .../rpgparser/evaluation/InterpreterTest.kt | 9 +++++++++ .../src/test/resources/INDIC03.rpgle | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 rpgJavaInterpreter-core/src/test/resources/INDIC03.rpgle diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt index b8f2c6e4d..73c302d56 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/InterpreterTest.kt @@ -2255,6 +2255,15 @@ Test 6 assertEquals(expected, "INDIC02".outputOf()) } + @Test + fun executeINDIC03() { + val expected = listOf( + "*INKA(0) *IN01(1)", + "*INKA(1) *IN01(0)" + ) + assertEquals(expected, "INDIC03".outputOf()) + } + @Test fun executeBIFCHECK() { assertEquals(listOf("ok"), outputOf("BIFCHECK")) diff --git a/rpgJavaInterpreter-core/src/test/resources/INDIC03.rpgle b/rpgJavaInterpreter-core/src/test/resources/INDIC03.rpgle new file mode 100644 index 000000000..e0098755b --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/INDIC03.rpgle @@ -0,0 +1,18 @@ + D £DBG_Str S 50 VARYING + + C MOVEL *ON *IN01 + C MOVEL *OFF *INKA + * + C EVAL £DBG_Str= '*INKA('+%CHAR(*INKA)+')' + C +' *IN01('+%CHAR(*IN01)+')' + C £DBG_Str DSPLY + * result: '*INKA(0) *IN01(1)' + * + C MOVEL *OFF *IN01 + C MOVEL *ON *INKA + * + C EVAL £DBG_Str= '*INKA('+%CHAR(*INKA)+')' + C +' *IN01('+%CHAR(*IN01)+')' + C £DBG_Str DSPLY + * result: '*INKA(1) *IN01(0)' + C SETON LR From fceda42b0643565a1c2818783e4416df5d14a968 Mon Sep 17 00:00:00 2001 From: Davide Palladino Date: Tue, 5 Mar 2024 15:06:51 +0100 Subject: [PATCH 6/6] Fixed enums --- .../smeup/rpgparser/parsing/ast/indicators.kt | 48 +++++++++---------- .../rpgparser/parsing/parsetreetoast/misc.kt | 4 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt index c9e758711..d992296f4 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/indicators.kt @@ -42,35 +42,35 @@ typealias IndicatorKey = Int * */ enum class IndicatorType(val range: IntRange) { Predefined(1..99), - KA(1..1), - KB(2..2), - KC(3..3), - KD(4..4), - KE(5..5), - KF(6..6), - KG(7..7), - KH(8..8), - KI(9..9), - KJ(10..10), - KK(11..11), - KL(12..12), - KM(13..13), - KN(14..14), - KP(15..15), - KQ(16..16), - KR(17..17), - KS(18..18), - KT(19..19), - KU(20..20), - KV(21..21), - KW(22..22), - KX(23..23), - KY(24..24), LR(100..100), RT(101..101), OC(102..102), OF(103..103), OV(104..104), + KA(105..105), + KB(106..106), + KC(107..107), + KD(108..108), + KE(109..109), + KF(110..110), + KG(111..111), + KH(112..112), + KI(113..113), + KJ(114..114), + KK(115..115), + KL(116..116), + KM(117..117), + KN(118..118), + KP(119..119), + KQ(120..120), + KR(121..121), + KS(122..122), + KT(123..123), + KU(124..124), + KV(125..125), + KW(126..126), + KX(127..127), + KY(128..128), ; companion object { 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 1657ca755..1c5215fa0 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 @@ -955,8 +955,8 @@ private fun annidatedReferenceExpression( } } if (text.uppercase(Locale.getDefault()).startsWith("*IN")) { - val index = text.uppercase(Locale.getDefault()).removePrefix("*IN").toInt() - return IndicatorExpr(index, position) + val index = text.uppercase(Locale.getDefault()).removePrefix("*IN") + return IndicatorExpr(index.toIndicatorKey(), position) } var expr: Expression