From f23cbe29e90475834d85291d370c2a57721ec726 Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Wed, 14 Dec 2022 13:17:17 +0000 Subject: [PATCH] testcase for [r4670] which fixed decimal constants changing their precision [bugs:#798] --- tests/testsuite.src/run_fundamental.at | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/testsuite.src/run_fundamental.at b/tests/testsuite.src/run_fundamental.at index c880819b3..d40838af5 100644 --- a/tests/testsuite.src/run_fundamental.at +++ b/tests/testsuite.src/run_fundamental.at @@ -5070,6 +5070,42 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP +AT_SETUP([COMPUTE with decimal constants]) +AT_KEYWORDS([fundamental]) + +# see bug #798, GC 2.2 may change the precision of decimal contants + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 CNT PIC 99 VALUE ZERO. + 77 CALCER PIC s99v99. + 01 DUMMY-RES PIC 99. + *> + PROCEDURE DIVISION. + *> variable setting postponed here to work around "easy" + *> optimization to constant + MOVE 3.5 TO CALCER + PERFORM 42 TIMES + ADD 1 TO CNT + >>D DISPLAY CNT + *> directly returns: + *> COMPUTE DUMMY-RES = 2 * (CALCER + 2) + 2 + *> performs "felt as forever": + COMPUTE DUMMY-RES = (CALCER + 2) * 2 + 2 + END-PERFORM + + GOBACK. +]) + +AT_CHECK([$COMPILE prog.cob]) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) + +AT_CLEANUP + + AT_SETUP([debugging lines (not active)]) AT_KEYWORDS([fundamental])