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

Area after col 72 #337

Open
wants to merge 6 commits into
base: Developer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/cobol/MOCK.CBL
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
PROGRAM-ID. MOCK.
/****************************************************************
* Program to exercise different mock statements and edge cases.
*****************************************************************
*****************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
WORKING-STORAGE SECTION.
Expand All @@ -23,10 +23,10 @@

000-START SECTION.
MOVE "Value1" to VALUE-1
MOVE "Value2" to VALUE-2
MOVE "Value2" to VALUE-2 dadawdwd
/
PERFORM 100-WELCOME
PERFORM 200-GOODBYE
PERFORM 100-WELCOME dadadada
PERFORM 200-GOODBYE dadadada
/
PERFORM 300-CHANGE-1
PERFORM 400-CHANGE-2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.openmainframeproject.cobolcheck.services.cobolLogic.CobolLine;
import org.openmainframeproject.cobolcheck.services.cobolLogic.Interpreter;
import org.openmainframeproject.cobolcheck.services.cobolLogic.TokenExtractor;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,7 +23,7 @@ public class CobolReader {

private String lineJustEntered = null;
private final int maxLineLength = 72;

public CobolReader(BufferedReader sourceReader) {
reader = sourceReader;
state = new State();
Expand Down Expand Up @@ -66,7 +65,10 @@ CobolLine readLine() throws IOException {
}
previousLine = currentLine;
setPreviousMeaningfulLine();
currentLine = new CobolLine(line, tokenExtractor);
if (line.length() > 72)
currentLine = new CobolLine(line.substring(0, 72), tokenExtractor);
else
currentLine = new CobolLine(line, tokenExtractor);
return currentLine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ public String interpretNextLine() {
}

// Current line might change from when it was originally read
return reader.getCurrentLine().getUnNumberedString();
if (reader.getCurrentLine().getUnNumberedString().length() > 72 )
return reader.getCurrentLine().getUnNumberedString().substring(0, 72);
else
return reader.getCurrentLine().getUnNumberedString();
}

public void closeReader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ public void variable_before_exec_sql_include_is_evaluated_as_text() throws IOExc
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING VALUE-1 " + Constants.NEWLINE +
" * ON EXCEPTION " + Constants.NEWLINE +
" * PERFORM 100-WELCOME " + Constants.NEWLINE +
" *END-CALL. " + Constants.NEWLINE +
" PERFORM UT-PROCESS-UNMOCK-CALL " + Constants.NEWLINE +
" CONTINUE " + Constants.NEWLINE +
" . ";
Expand Down Expand Up @@ -443,8 +440,6 @@ public void variable_before_exec_sql_include_is_evaluated_as_text() throws IOExc
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING VALUE-1 " + Constants.NEWLINE +
" * ON EXCEPTION " + Constants.NEWLINE +
" * PERFORM 100-WELCOME. " + Constants.NEWLINE +
" PERFORM UT-PROCESS-UNMOCK-CALL " + Constants.NEWLINE +
" CONTINUE " + Constants.NEWLINE +
" . ";
Expand Down Expand Up @@ -489,8 +484,6 @@ public void variable_before_exec_sql_include_is_evaluated_as_text() throws IOExc
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING VALUE-1 " + Constants.NEWLINE +
" * ON EXCEPTION " + Constants.NEWLINE +
" * DISPLAY \"HELLO WORLD\". " + Constants.NEWLINE +
" PERFORM UT-PROCESS-UNMOCK-CALL " + Constants.NEWLINE +
" CONTINUE " + Constants.NEWLINE +
" . ";
Expand Down Expand Up @@ -535,12 +528,6 @@ public void variable_before_exec_sql_include_is_evaluated_as_text() throws IOExc
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING VALUE-1 " + Constants.NEWLINE +
" * ON EXCEPTION " + Constants.NEWLINE +
" * CALL \"PROGRAM2\" USING VALUE-1 " + Constants.NEWLINE +
" * ON EXCEPTION " + Constants.NEWLINE +
" * DISPLAY \"HELLO WORLD\" " + Constants.NEWLINE +
" * END-CALL " + Constants.NEWLINE +
" *END-CALL " + Constants.NEWLINE +
" PERFORM UT-PROCESS-UNMOCK-CALL " + Constants.NEWLINE +
" CONTINUE " + Constants.NEWLINE +
" DISPLAY \"NO COMMENTS\" " + Constants.NEWLINE;
Expand Down Expand Up @@ -585,12 +572,10 @@ public void variable_before_exec_sql_include_is_evaluated_as_text() throws IOExc
" . " + Constants.NEWLINE +
" " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING DATA-1 ON EXCEPTION " + Constants.NEWLINE +
" * DISPLAY \"ERROR\". " + Constants.NEWLINE +
" PERFORM UT-PROCESS-UNMOCK-CALL " + Constants.NEWLINE +
" CONTINUE " + Constants.NEWLINE +
" . " + Constants.NEWLINE +
" *CALL \"PROGRAM\" USING DATA-1 ON EXCEPTION " + Constants.NEWLINE +
" * DISPLAY \"ERROR\". " + Constants.NEWLINE +
" PERFORM UT-PROCESS-UNMOCK-CALL " + Constants.NEWLINE +
" CONTINUE " + Constants.NEWLINE +
" . " + Constants.NEWLINE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,4 +1016,18 @@ public void it_stubs_linkage_line() throws IOException {
}
assertTrue(testsRan);
}

@Test
public void it_doesnt_read_pass_col_72() throws IOException {
String str1 = " THIS LINEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE IS LONGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";

Mockito.when(mockedReader.readLine()).thenReturn(str1, null);

while (interpreterController.interpretNextLine() != null){
interpreterController.interpretNextLine();
}

assertEquals(interpreterController.getCurrentLineAsStatement().getTrimmedString(), "THIS LINEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE IS LONGGGGGGGG");

}
}
Binary file modified vs-code-extension/Cobol-check/bin/cobol-check-0.2.8.jar
Binary file not shown.
Loading