Skip to content

Commit

Permalink
Add arguments without commas
Browse files Browse the repository at this point in the history
  • Loading branch information
issacto committed Jun 22, 2023
1 parent 0753d3d commit 1f3599c
Showing 1 changed file with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public class TestSuiteParser {
private int testCaseNumber = 0;
private boolean expectNumericCompare;

private boolean previousLineContainsArgument = false;

// Lines inserted into the test program
private static final String COBOL_PERFORM_INITIALIZE = " PERFORM %sINITIALIZE";
private static final String COBOL_DISPLAY_TESTSUITE = " DISPLAY \"TESTSUITE:\"";
Expand Down Expand Up @@ -176,6 +178,7 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
numericFields = numericFieldsList;
String testSuiteToken = getNextTokenFromTestSuite(testSuiteReader);
while (testSuiteToken != null) {

if (!testSuiteToken.startsWith(Constants.QUOTE) && !testSuiteToken.startsWith(Constants.APOSTROPHE)) {
testSuiteToken = testSuiteToken.toUpperCase(Locale.ROOT);
}
Expand All @@ -184,6 +187,7 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
testSuiteToken = getNextTokenFromTestSuite(testSuiteReader);
continue;
}


boolean cobolTokenIsFieldName = (expectInProgress || expectQualifiedName || expectMockIdentifier
|| (expectMockArguments && !expectUsing));
Expand All @@ -195,11 +199,34 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
// to next token
expectMockArguments = false;
expectUsing = false;
// System.out.println("TESTING");
// System.out.println(keyword.keywordAction());
// System.out.println(testSuiteToken);
handleEndOfMockStatement(testSuiteReader, testSuiteToken, false);
testSuiteToken = getNextTokenFromTestSuite(testSuiteReader);
System.out.println(testSuiteToken);
continue;
}

if (!verifyInProgress && expectMockArguments
&& CobolVerbs.isStartOrEndCobolVerb(testSuiteToken)) {
// In this case we expected cobol verbs and stop counting arguments
// update the keyword as fieldname was assumed
keyword = Keywords.getKeywordFor(testSuiteToken, false);
expectMockArguments = false;
expectUsing = false;
// System.out.println("TESTING");
// System.out.println(testSuiteToken);
// System.out.println(keyword.keywordAction());
ignoreCobolStatementAndFieldNameKeyAction = true;
handleEndOfMockStatement(testSuiteReader, testSuiteToken, previousLineContainsArgument);
testSuiteToken = getNextTokenFromTestSuite(testSuiteReader);
previousLineContainsArgument=false;
continue;
}



if (!testSuiteErrorLog.checkExpectedTokenSyntax(keyword, testSuiteToken, currentTestSuiteRealFile,
fileLineNumber, fileLineIndexNumber)) {
testSuiteToken = getNextTokenFromTestSuite(testSuiteReader);
Expand Down Expand Up @@ -318,6 +345,8 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
addTestCodeForAssertion(parsedTestSuiteLines, numericFields);
toBeInProgress = false;
}


if (expectMockIdentifier) {
expectMockIdentifier = false;
ignoreCobolStatementAndFieldNameKeyAction = true;
Expand Down Expand Up @@ -345,6 +374,7 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
if (!expectUsing) {
currentLineContainsArgument = true;
ignoreCobolStatementAndFieldNameKeyAction = true;

if (verifyInProgress)
currentVerify.addArgument(getCallArgument(currentMockArgument, testSuiteToken));
else
Expand All @@ -354,13 +384,7 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
if (testSuiteToken.endsWith(","))
break;
}
// Contains no arguments or all arguments has been added
expectMockArguments = false;
expectUsing = false;
if (!verifyInProgress) {
ignoreCobolStatementAndFieldNameKeyAction = true;
handleEndOfMockStatement(testSuiteReader, testSuiteToken, currentLineContainsArgument);
}
previousLineContainsArgument = currentLineContainsArgument;
}

if (verifyInProgress) {
Expand All @@ -374,6 +398,8 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
break;

case Constants.ALPHANUMERIC_LITERAL_KEYWORD:


if (expectTestsuiteName) {
expectTestsuiteName = false;
currentTestSuiteName = testSuiteToken;
Expand Down Expand Up @@ -618,7 +644,7 @@ public List<String> getParsedTestSuiteLines(BufferedReader testSuiteReader,
break;
}
if (CobolVerbs.isStartOrEndCobolVerb(testSuiteToken)) {
if (cobolStatementInProgress) {
if ( cobolStatementInProgress) {
addUserWrittenCobolStatement(parsedTestSuiteLines);
initializeCobolStatement();
}
Expand Down Expand Up @@ -830,6 +856,7 @@ private String getCallArgument(String referenceType, String value) {
outPut = ("REFERENCE " + value.replace(",", ""));
else
outPut = (referenceType + " " + value.replace(",", ""));

return outPut;
}

Expand Down

0 comments on commit 1f3599c

Please sign in to comment.