Skip to content

Commit

Permalink
Merge pull request #683 from smeup/bugfix/LS24005329/improve-comparis…
Browse files Browse the repository at this point in the history
…on-between-hival-and-string

Bugfix/LS24005329/Improve comparison between `*HIVAL` and String
  • Loading branch information
lanarimarco authored Dec 12, 2024
2 parents 9cf1550 + e237706 commit 1d32783
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,4 +830,82 @@ open class MULANGT10BaseCodopTest : MULANGTTest() {
val expected = listOf("", "FOO", "BAR", "BARX")
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))
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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<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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1d32783

Please sign in to comment.