diff --git a/kolasu/build.gradle b/kolasu/build.gradle index 9b6bab026..2149f051f 100644 --- a/kolasu/build.gradle +++ b/kolasu/build.gradle @@ -1,3 +1,19 @@ +/* + * Copyright 2019 Sme.UP S.p.A. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + //----------------- //kolasu build script //----------------- @@ -42,8 +58,6 @@ dependencies { testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion" testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" - implementation 'com.fifesoft:rsyntaxtextarea:3.5.2' - implementation 'com.fifesoft:autocomplete:3.3.1' implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion" implementation "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$serializationVersion" 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 9b2d02a26..3e0d9d34b 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 @@ -211,6 +211,7 @@ data class StringValue(var value: String, var varying: Boolean = false) : Abstra override operator fun compareTo(other: Value): Int = when (other) { is StringValue -> compare(other, DEFAULT_CHARSET) + is HiValValue -> if (this == this.hiValue()) EQUAL else SMALLER is BlanksValue -> if (this.isBlank()) EQUAL else SMALLER is BooleanValue -> if (this.value.isInt() && this.value.toInt() == other.value.toInt()) EQUAL else GREATER else -> super.compareTo(other) @@ -801,8 +802,13 @@ object HiValValue : Value { override fun copy(): HiValValue = this - override operator fun compareTo(other: Value): Int = - if (other is HiValValue) 0 else 1 + override operator fun compareTo(other: Value): Int { + return when (other) { + is StringValue -> if (other.hiValue() == other) EQUAL else GREATER + // TODO: Is much generic. Provide atomic cases. + else -> if (other is HiValValue) EQUAL else GREATER + } + } override fun asString(): StringValue { TODO("Not yet implemented") 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 59fd9d430..ecd6aae67 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 @@ -831,6 +831,84 @@ open class MULANGT10BaseCodopTest : MULANGTTest() { assertEquals(expected, "smeup/MUDRNRAPU00182".outputOf(configuration = smeupConfig)) } + /** + * Comparison between: + * - *HIVAL and String, + * - *HIVAL and *HIVAL + * by using "not equal" operator. + * @see #LS24005329 + */ + @Test + fun executeMUDRNRAPU00183() { + val expected = listOf("TRUE", "END", "TRUE", "END", "END", "END") + assertEquals(expected, "smeup/MUDRNRAPU00183".outputOf(configuration = smeupConfig)) + } + + /** + * Comparison between: + * - *HIVAL and String, + * - *HIVAL and *HIVAL + * by using "greater" operator. + * @see #LS24005329 + */ + @Test + fun executeMUDRNRAPU00184() { + val expected = listOf("TRUE", "END", "TRUE", "END", "END", "END") + assertEquals(expected, "smeup/MUDRNRAPU00184".outputOf(configuration = smeupConfig)) + } + + /** + * Comparison between: + * - *HIVAL and String, + * - *HIVAL and *HIVAL + * by using "greater/equal" operator. + * @see #LS24005329 + */ + @Test + fun executeMUDRNRAPU00185() { + val expected = listOf("TRUE", "END", "TRUE", "END", "TRUE", "END", "TRUE", "END") + assertEquals(expected, "smeup/MUDRNRAPU00185".outputOf(configuration = smeupConfig)) + } + + /** + * Comparison between: + * - *HIVAL and String, + * - *HIVAL and *HIVAL + * by using "lower" operator. + * @see #LS24005329 + */ + @Test + fun executeMUDRNRAPU00186() { + val expected = listOf("END", "END", "END", "END") + assertEquals(expected, "smeup/MUDRNRAPU00186".outputOf(configuration = smeupConfig)) + } + + /** + * Comparison between: + * - *HIVAL and String, + * - *HIVAL and *HIVAL + * by using "lower/equal" operator. + * @see #LS24005329 + */ + @Test + fun executeMUDRNRAPU00187() { + val expected = listOf("END", "END", "TRUE", "END", "TRUE", "END") + assertEquals(expected, "smeup/MUDRNRAPU00187".outputOf(configuration = smeupConfig)) + } + + /** + * Comparison between: + * - *HIVAL as Standalone of 2 chars, + * - *HIVAL as Standalone of 4 chars, + * by using "equal" operator. + * @see #LS24005329 + */ + @Test + fun executeMUDRNRAPU00188() { + val expected = listOf("END") + assertEquals(expected, "smeup/MUDRNRAPU00188".outputOf(configuration = smeupConfig)) + } + /** * SCAN followed by %FOUND * @see #LS24005347 diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00183.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00183.rpgle new file mode 100644 index 000000000..9afcb5750 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00183.rpgle @@ -0,0 +1,36 @@ + V* ============================================================== + V* 10/12/2024 APU001 Creation + V* ============================================================== + O * PROGRAM GOAL + O * Comparison between: + O * - *HIVAL and String, + O * - *HIVAL and *HIVAL + O * by using "not equal" operator. + V* ============================================================== + O * JARIKO ANOMALY + O * The expression is not evaluated when it's true. + V* ============================================================== + D ARR01 S 2 DIM(10) INZ('FF') + D ARR02 S 2 DIM(10) INZ(*HIVAL) + + C IF *HIVAL<>ARR01(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR01(1)<>*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF *HIVAL<>ARR02(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR02(1)<>*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C SETON LR \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00184.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00184.rpgle new file mode 100644 index 000000000..e2d166b57 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00184.rpgle @@ -0,0 +1,36 @@ + V* ============================================================== + V* 10/12/2024 APU001 Creation + V* ============================================================== + O * PROGRAM GOAL + O * Comparison between: + O * - *HIVAL and String, + O * - *HIVAL and *HIVAL + O * by using "greater" operator. + V* ============================================================== + O * JARIKO ANOMALY + O * The expression is not evaluated when it's true. + V* ============================================================== + D ARR01 S 2 DIM(10) INZ('FF') + D ARR02 S 2 DIM(10) INZ(*HIVAL) + + C IF *HIVAL>ARR01(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR01(1)<*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF *HIVAL>ARR02(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR02(1)<*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C SETON LR \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00185.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00185.rpgle new file mode 100644 index 000000000..c93844b4e --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00185.rpgle @@ -0,0 +1,36 @@ + V* ============================================================== + V* 10/12/2024 APU001 Creation + V* ============================================================== + O * PROGRAM GOAL + O * Comparison between: + O * - *HIVAL and String, + O * - *HIVAL and *HIVAL + O * by using "greater/equal" operator. + V* ============================================================== + O * JARIKO ANOMALY + O * The expression is not evaluated when it's true. + V* ============================================================== + D ARR01 S 2 DIM(10) INZ('FF') + D ARR02 S 2 DIM(10) INZ(*HIVAL) + + C IF *HIVAL>=ARR01(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR01(1)<=*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF *HIVAL>=ARR02(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR02(1)<=*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C SETON LR \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00186.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00186.rpgle new file mode 100644 index 000000000..f8c44e453 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00186.rpgle @@ -0,0 +1,36 @@ + V* ============================================================== + V* 10/12/2024 APU001 Creation + V* ============================================================== + O * PROGRAM GOAL + O * Comparison between: + O * - *HIVAL and String, + O * - *HIVAL and *HIVAL + O * by using "lower" operator. + V* ============================================================== + O * JARIKO ANOMALY + O * The expression is not evaluated when it's true. + V* ============================================================== + D ARR01 S 2 DIM(10) INZ('FF') + D ARR02 S 2 DIM(10) INZ(*HIVAL) + + C IF *HIVAL*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF *HIVAL*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C SETON LR \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00187.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00187.rpgle new file mode 100644 index 000000000..b100d71a9 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00187.rpgle @@ -0,0 +1,36 @@ + V* ============================================================== + V* 10/12/2024 APU001 Creation + V* ============================================================== + O * PROGRAM GOAL + O * Comparison between: + O * - *HIVAL and String, + O * - *HIVAL and *HIVAL + O * by using "lower/equal" operator. + V* ============================================================== + O * JARIKO ANOMALY + O * The expression is not evaluated when it's true. + V* ============================================================== + D ARR01 S 2 DIM(10) INZ('FF') + D ARR02 S 2 DIM(10) INZ(*HIVAL) + + C IF *HIVAL<=ARR01(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR01(1)>=*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF *HIVAL<=ARR02(1) + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C IF ARR02(1)>=*HIVAL + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C SETON LR \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00188.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00188.rpgle new file mode 100644 index 000000000..e49bcaf26 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/MUDRNRAPU00188.rpgle @@ -0,0 +1,21 @@ + V* ============================================================== + V* 10/12/2024 APU001 Creation + V* ============================================================== + O * PROGRAM GOAL + O * Comparison between: + O * - *HIVAL as Standalone of 2 chars, + O * - *HIVAL as Standalone of 4 chars, + O * by using "equal" operator. + V* ============================================================== + O * JARIKO ANOMALY + O * The expression is not evaluated when it's true. + V* ============================================================== + D D1 S 2 INZ(*HIVAL) + D D2 S 4 INZ(*HIVAL) + + C IF D1=D2 + C 'TRUE' DSPLY + C ENDIF + C 'END' DSPLY + + C SETON LR \ No newline at end of file