Skip to content

Commit

Permalink
Merge pull request #685 from smeup/feature/LS24005347/missing-found
Browse files Browse the repository at this point in the history
Feature/ls24005347/missing found
  • Loading branch information
lanarimarco authored Dec 12, 2024
2 parents 82386f7 + 8640b04 commit 599a13a
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class ExpressionEvaluation(
start: IntValue?,
length: IntValue?,
operator: ComparisonOperator
): Value {
): IntValue {
val arrayLength = arrayType.numberOfElements()
val isSequenced = arrayType.ascend != null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ fun lookUp(statement: LookupStmt, interpreterCore: InterpreterCore, charset: Cha
arraySearchingParameters.indexVar?.let {
interpreterCore.assign(it, searchResult.oneBasedIndex.asValue())
}

// Lookup is relevant for %FOUND
interpreterCore.getStatus().lastFound = searchResult !is NotFound
}

class FoundIndexes(var hi: Int, var lo: Int, var eq: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,9 @@ data class ScanStmt(
val leftLength = leftLengthExpression?.let { interpreter.eval(it).asString().value.toInt() }
val start = startPosition?.let { interpreter.eval(it).asString().value.toInt() } ?: 1

// SCAN is relevant for %FOUND calls
interpreter.getStatus().lastFound = false

val stringToSearch = interpreter.eval(left).asString().value.substringOfLength(leftLength)
val searchInto = interpreter.eval(right).asString().value.substring(start - 1)
val occurrences = mutableListOf<Value>()
Expand All @@ -2391,6 +2394,9 @@ data class ScanStmt(
interpreter.assign(it, occurrences[0])
}
}

// Update found status
interpreter.getStatus().lastFound = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,4 +908,24 @@ open class MULANGT10BaseCodopTest : MULANGTTest() {
val expected = listOf("END")
assertEquals(expected, "smeup/MUDRNRAPU00188".outputOf(configuration = smeupConfig))
}

/**
* SCAN followed by %FOUND
* @see #LS24005347
*/
@Test
fun executeMUDRNRAPU00279() {
val expected = listOf("3", "FOUND", "0", "NOT FOUND")
assertEquals(expected, "smeup/MUDRNRAPU00279".outputOf(configuration = smeupConfig))
}

/**
* LOOKUP followed by %FOUND
* @see #LS24005347
*/
@Test
fun executeMUDRNRAPU00280() {
val expected = listOf("1", "0")
assertEquals(expected, "smeup/MUDRNRAPU00280".outputOf(configuration = smeupConfig))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
V* ==============================================================
O * JARIKO ANOMALY
O * Before the fix, jariko throw a syntax error
V* ============================================================== DA1 S 1
V* ==============================================================
DN2 S 2 0
D T$C5MD S 15
DA1 S 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
V* ==============================================================
V* 11/12/2024 APU002 Creation
V* ==============================================================
O * PROGRAM GOAL
O * SCAN followed by %FOUND
V* ==============================================================
O * JARIKO ANOMALY
O * Before the fix, jariko did not consider SCAN accountable for %FOUND
V* ==============================================================
D RESULT S 1 0
D BASE S 6 INZ('XCABCD')

C 'ABC' SCAN BASE RESULT
C RESULT DSPLY
C IF %FOUND
C 'FOUND' DSPLY
C ELSE
C 'NOT FOUND' DSPLY
C ENDIF

C 'FOO' SCAN BASE RESULT
C RESULT DSPLY
C IF %FOUND
C 'FOUND' DSPLY
C ELSE
C 'NOT FOUND' DSPLY
C ENDIF

C SETON RT
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
V* ==============================================================
V* 11/12/2024 APU002 Creation
V* ==============================================================
O * PROGRAM GOAL
O * LOOKUP followed by %FOUND
V* ==============================================================
O * JARIKO ANOMALY
O * Before the fix, jariko did not consider LOOKUP accountable for %FOUND
V* ==============================================================
D RESULT S 1 0
D FND S N
D ARY S 3 DIM(10)
C EVAL ARY(1)='ABC'
C* Lookup opcode found
C 'ABC' LOOKUP ARY 26
C EVAL FND=%FOUND
C FND DSPLY
C* Lookup opcode not found
C 'FOO' LOOKUP ARY 26
C EVAL FND=%FOUND
C FND DSPLY

C SETON RT

0 comments on commit 599a13a

Please sign in to comment.