openmainframeproject / cobol-check

A testing framework for Cobol applications
Apache License 2.0
78 stars 28 forks source link

[ENHANCEMENT] Array initializer #294

Open axtens opened 1 year ago

axtens commented 1 year ago

Currenly the test case says

TestCase "Latest score"
        MOVE '100,0,90,30' TO WS-SCORES
        MOVE "latest" TO WS-PROPERTY
        PERFORM HIGH-SCORES
        EXPECT WS-RESULT = 30

In HIGH-SCORES, WS-SCORES needs to UNSTRINGed into a table. Another option is to move '100000090030' to WS-SCORES and decompose the data with working-storage structures.

Assuming a WS-SCORES-TABLE with sufficient space to hold the elements, an instruction 'MOVE-EACH' is suggested that parses the supplied list of values into the table, e.g.

MOVE-EACH 100,0,90,30 TO WS-SCORES-TABLE

If the table is of strings, allow for the MOVE-EACH to handle then viz

MOVE-EACH 'Agaricomycetes','Arthoniomycetes','Coniocybomycetes','Dothideomycetes','Eurotiomycetes','Lecanoromycetes','Lichinomycetes','Sordariomycetes' TO WS-LICHEN-FUNGAL-CLASSES-TABLE
Rune-Christensen commented 1 year ago

Hi @axtens Thank you for your interest in COBOL Check :-) Just to clarify: you would want to use the MOVE-EACH statement instead of the first MOVE statement in your example?

If you wanted to use it in HIGH-SCORES, it would be out of scope for COBOL Check, and would have to be added as an ordinary COBOL statement.

axtens commented 1 year ago

It's a suggestion to extend the command set for cobolcheck itself. There's no MOVE-EACH in the COBOL dialect I use (GnuCOBOL) and likely never will be.

The suggestion comes from having to write my COBOL in such a way asto be able to use cobolcheck to test my COBOL.

-Bruce