Skip to content

Commit

Permalink
Merge pull request #399 from smeup/bugfix/NW23001440/call_not_existen…
Browse files Browse the repository at this point in the history
…t_pgm

bugfix/NW23001440/error indicator on nonexistent program call
  • Loading branch information
lanarimarco authored Jan 18, 2024
2 parents 85034b3 + 9b2a4bf commit 87fa2b7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,20 @@ data class CallStmt(
val callStatement = this
val programToCall = interpreter.eval(expression).asString().value.trim()
MainExecutionContext.setExecutionProgramName(programToCall)
val program = interpreter.getSystemInterface().findProgram(programToCall)
val program: Program?
try {
program = interpreter.getSystemInterface().findProgram(programToCall)
if (errorIndicator != null) {
interpreter.getIndicators()[errorIndicator] = BooleanValue.FALSE
}
} catch (e: Exception) {
if (errorIndicator == null) {
throw e
}
interpreter.getIndicators()[errorIndicator] = BooleanValue.TRUE
return
}

require(program != null) {
"Line: ${this.position.line()} - Program '$programToCall' cannot be found"
}
Expand Down Expand Up @@ -659,6 +672,9 @@ data class CallStmt(
System.currentTimeMillis() - startTime
)
}
if (errorIndicator != null) {
interpreter.getIndicators()[errorIndicator] = BooleanValue.FALSE
}
}
} catch (e: Exception) { // TODO Catch a more specific exception?
interpreter.log {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ open class SmeupInterpreterTest : AbstractTest() {
assertEquals(expected, "smeup/T40_A10_P07".outputOf())
}

@Test
fun executeT20_A10_P05() {
val expected = listOf(
"1",
"0"
)
assertEquals(expected, "smeup/T20_A10_P05".outputOf())
}

@Test
fun executeT02_S10_P01() {
val expected = listOf(
Expand Down
15 changes: 15 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/smeup/T20_A10_P05.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
D £DBG_Str S 2560 Stringa
D TXT S 10
* Test indicator 35 activation when CALL non existent pgm
C CALL 'XXXXXX_YY' 35
C EVAL £DBG_Str=%CHAR(*IN35)
C £DBG_Str DSPLY
*
C EVAL TXT='PING'
C CALL 'ECHO_PGM' 35
C PARM TXT
C
C EVAL £DBG_Str=%CHAR(*IN35)
C £DBG_Str DSPLY
*
C SETON LR

0 comments on commit 87fa2b7

Please sign in to comment.