diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index f56ef3355..000000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "permissions": { - "allow": [ - "Read(/C:\\dev\\java\\smeup\\jariko/**)", - "Bash(git add:*)" - ], - "deny": [], - "ask": [] - } -} \ No newline at end of file diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/facade/RpgParserFacade.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/facade/RpgParserFacade.kt index 3e741d5a4..08efbb1f1 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/facade/RpgParserFacade.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/facade/RpgParserFacade.kt @@ -162,7 +162,7 @@ class RpgParserFacade { val code = inputStreamToString(inputStream) val lines = code.lines() val longLines = lines.map { it.padEnd(threshold) } - val paddedCode = longLines.joinToString(System.lineSeparator()) + val paddedCode = longLines.joinToString("\n") return CharStreams.fromStream(paddedCode.byteInputStream(StandardCharsets.UTF_8)) } diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/utils/misc.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/utils/misc.kt index e41c9718e..6f93675fa 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/utils/misc.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/utils/misc.kt @@ -122,9 +122,9 @@ fun String?.asDouble(): Double { fun String.asBigDecimal(): BigDecimal? = try { - BigDecimal(this.trim()) + BigDecimal(this.trim().replace(',', '.')) } catch (e: Exception) { - null + error("Unable to parse $this as BigDecimal") } fun Int.ceilDiv(divisor: Int): Int = this / divisor + if (this % divisor > 0) 1 else 0 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 b8a313aec..19f2f9065 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 @@ -1063,6 +1063,11 @@ Test 6 ) } + @Test + fun executeBIFDEC01() { + assertEquals(listOf("1.30", "1.30"), outputOf("BIFDEC01")) + } + @Test fun executeBIFEDITC() { // I don't know exactly what expected result should be @@ -1306,7 +1311,7 @@ Test 6 } @Test - fun EVALwithTypeError() { + fun evalWithTypeError() { val systemInterface = JavaSystemInterface() val source = diff --git a/rpgJavaInterpreter-core/src/test/resources/BIFDEC01.rpgle b/rpgJavaInterpreter-core/src/test/resources/BIFDEC01.rpgle new file mode 100644 index 000000000..c16856a3b --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/BIFDEC01.rpgle @@ -0,0 +1,25 @@ + V* ============================================================== + D* Purpose of this program is to fix %DEC when the string + D* contains italian decimal separator (comma instead of dot) + V* ============================================================== + + D DECIMAL S 9 2 + D STR S 10A + + * %DEC with dot decimal separator ************************************ + C EVAL STR='1.30' + C EVAL DECIMAL=%DEC(STR:9:2) + * Expected: + * DECIMAL = 1.30 + C DECIMAL DSPLY + *********************************************************************** + + * %DEC with italian decimal separator (comma) ************************ + C EVAL STR='1,30' + C EVAL DECIMAL=%DEC(STR:9:2) + * Expected: + * DECIMAL = 1.30 + C DECIMAL DSPLY + *********************************************************************** + + C SETON LR \ No newline at end of file