Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

276 support on EXCEPTION in CALLs #311

Closed
wants to merge 2 commits into from
Closed

276 support on EXCEPTION in CALLs #311

wants to merge 2 commits into from

Conversation

AkashKumar7902
Copy link
Contributor

Fixes: #276

Copy link
Collaborator

@Rune-Christensen Rune-Christensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for removing the formatting changes, it helps a lot :-D

I would like you to consider if it is possible to tests how mocks work with CALL ON EXCEPTION statements.

And take a look at how the code manages CALL ON EXCEPTION that ends with a period, see my commet.

And if you can find a solution to my comment about the commented call in the resulting code, it would be awesome :-D

callTokenCount++;
}
if (token.equals(Constants.END_CALL_TOKEN)) {
endCallTokenCount++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might break if the "end-call-token" is replaced with a period.

Try making this test:
CALL "PROGRAM" USING DATA-1 ON EXCEPTION
DISPLAY "ERROR".
CALL "PROGRAM" USING DATA-1 ON EXCEPTION
DISPLAY "ERROR".
What code does that result in?
It should look something like this:

  • CALL "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR".
  • CALL "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR".
    But I think it will concatenate it like this:
  • CALL "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR". CALL
  • "PROGRAM" USING DATA-1 ON EXCEPTION DISPLAY "ERROR".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rune-Christensen
Thanks for the question.

The If conditions above line 166 will take care of the period terminator preventing the code from breaking.

The above code is returning the below code:

*CALL "PROGRAM" USING DATA-1 ON EXCEPTION
*    DISPLAY "ERROR"
           CONTINUE                                                            
           .                                                                 
*CALL "PROGRAM" USING DATA-1 ON EXCEPTION
*    DISPLAY "ERROR".                                       
            CONTINUE                                                            
           .

I have also added tests in my new PR :)

Regards,
Akash Kumar

" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING VALUE-1 ON EXCEPTION PERFORM 100-WELCOME END " + Constants.NEWLINE +
" * -CALL. " + Constants.NEWLINE +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like the way that the entire call statement is concatenated into a string, and then split over the required number of lines.
I would prefer that the comment looks something like this, that preserves the original lines and spacing:

* CALL \"PROGRAM\" USING VALUE-1
*   ON EXCEPTION
*   PERFORM 100-WELCOME
* END-CALL.

If you can find an easy fix for that, it would be awesome :-D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rune-Christensen
Thanks for raising this issue.
I have added code for this in my latest PR.
The commit link is : add pretty format for multiline comment statements

@AkashKumar7902
Copy link
Contributor Author

@Rune-Christensen
Should the mocked call statement in testfile will have 'on exception' signature ?
like:
MOCK CALL 'PROG' USING VALUE-1
ON EXCEPTION
PERFORM 100-WELCOME
DISPLAY "HELLO WORLD"
END-MOCK

@Rune-Christensen
Copy link
Collaborator

@Rune-Christensen Should the mocked call statement in testfile will have 'on exception' signature ? like: MOCK CALL 'PROG' USING VALUE-1 ON EXCEPTION PERFORM 100-WELCOME DISPLAY "HELLO WORLD" END-MOCK

@AkashKumar7902 At the moment, we do not want the MOCK CALL statement, to contain ON EXCEPTION as part of the signature.
Therefore we want to ensure, with a tests, that a call, with on exception, can be mocked and that the mock works. As the code is right now.

@AkashKumar7902 AkashKumar7902 closed this by deleting the head repository Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ON EXCEPTION in CALLs
2 participants