| 1 |
*> { dg-do run } |
| 2 |
*> { dg-options "-dialect mf" } |
| 3 |
*> { dg-output-file "group2/INSPECT_TRAILING.out" } |
| 4 |
|
| 5 |
identification division. |
| 6 |
program-id. prog. |
| 7 |
data division. |
| 8 |
working-storage section. |
| 9 |
01 the-text pic x(30) value " middle". |
| 10 |
01 counter pic 9999. |
| 11 |
01 expected pic 9999. |
| 12 |
01 should-be pic zzz9. |
| 13 |
01 but-is pic zzz9. |
| 14 |
01 msg pic x(100). |
| 15 |
procedure division. |
| 16 |
|
| 17 |
move "inspect for leading spaces" to msg |
| 18 |
move zero to counter |
| 19 |
inspect the-text tallying counter for leading spaces |
| 20 |
move 4 to expected |
| 21 |
perform result. |
| 22 |
|
| 23 |
move "inspect for trailing spaces with reverse" to msg |
| 24 |
move zero to counter |
| 25 |
inspect function reverse(the-text) tallying counter for leading spaces |
| 26 |
move 20 to expected |
| 27 |
perform result. |
| 28 |
|
| 29 |
move "inspect for trailing spaces with reversed variable" to msg |
| 30 |
move function reverse(the-text) to the-text |
| 31 |
move zero to counter |
| 32 |
inspect the-text tallying counter for leading spaces |
| 33 |
move 20 to expected |
| 34 |
perform result. |
| 35 |
|
| 36 |
move "inspect for trailing spaces with INSPECT TRAILING extension" to msg |
| 37 |
move function reverse(the-text) to the-text |
| 38 |
move zero to counter |
| 39 |
inspect the-text tallying counter for trailing spaces |
| 40 |
move 20 to expected |
| 41 |
perform result. |
| 42 |
|
| 43 |
inspect the-text replacing trailing space by "X" |
| 44 |
display the-text |
| 45 |
|
| 46 |
stop run. |
| 47 |
|
| 48 |
result. |
| 49 |
display function trim(msg) ": " with no advancing |
| 50 |
move expected to should-be |
| 51 |
if counter equal to expected |
| 52 |
display function trim(should-be) |
| 53 |
else |
| 54 |
move counter to but-is |
| 55 |
display "should be " function trim(should-be) |
| 56 |
" but is " function trim(but-is) |
| 57 |
end-if. |
| 58 |
|