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

tests/automation: Increase coverage #2135

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
88 changes: 69 additions & 19 deletions clients/cobol-lsp-vscode-extension/src/test/suite/lsp.spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,28 +590,37 @@ suite("Integration Test Suite", function () {
.timeout(helper.TEST_TIMEOUT)
.slow(1000);

test("Show transition copybook errors", async () => {
// Open program with error inside a copybook
await helper.showDocument("TESTCPY2.cbl");
const progUri = await helper.getUri("TESTCPY2.cbl");
test(
"Show transition copybook errors" +
"TC288744: Underscore a copy statement if its copybook contains error: nested copybooks" +
'TC247996: Nested copybooks with "no extension" are supported',
Nurkambay marked this conversation as resolved.
Show resolved Hide resolved
async () => {
// Open program with error inside a copybook
await helper.showDocument("TESTCPY2.cbl");
const progUri = await helper.getUri("TESTCPY2.cbl");

const copybookPath = path.join("testing", "COPYC");
const copybookUri = await helper.getUri(copybookPath);
const copybookPath = path.join("testing", "COPYC");
const copybookUri = await helper.getUri(copybookPath);

// Open copybook with an error
await helper.showDocument(copybookPath);
// Open copybook with an error
await helper.showDocument(copybookPath);

await helper.waitFor(
() => vscode.languages.getDiagnostics(copybookUri).length === 1,
);
const diagnostic = vscode.languages.getDiagnostics(copybookUri);
assert.strictEqual(
diagnostic.length,
1,
"got: " + JSON.stringify(diagnostic),
);
assert.strictEqual(diagnostic[0].message, "Errors inside the copybook");
})
await helper.waitFor(
() => vscode.languages.getDiagnostics(copybookUri).length === 1,
);
const diagnostic = vscode.languages.getDiagnostics(progUri);
assert.strictEqual(
diagnostic.length,
1,
"got: " + JSON.stringify(diagnostic),
);
helper.assertRangeIsEqual(
diagnostic[0].range,
range(pos(20, 7), pos(20, 18)),
);
// assert.strictEqual(diagnostic[0].message, "Errors inside the copybook");
},
)
.timeout(helper.TEST_TIMEOUT)
.slow(1000);

Expand Down Expand Up @@ -688,4 +697,45 @@ suite("Integration Test Suite", function () {
})
.timeout(helper.TEST_TIMEOUT)
.slow(1000);

test(
"TC314993: TITLE Statement is allowed before ID DIVISION" +
"TC315392: PROGRAM-ID Check Is Not Case Sensitive",
async () => {
const extSrcPath = path.join("TEST_TITLE.CBL");
const diagPromise = helper.waitForDiagnosticsChange(extSrcPath);
await helper.showDocument(extSrcPath);
const diagnostics = await diagPromise;
assert.strictEqual(diagnostics.length, 1);
const message = diagnostics[0].message;
assert.match(message, /^Variable ABC-ID is not defined/);
},
)
.timeout(helper.TEST_TIMEOUT)
.slow(1000);

test("TC288730: Underscore a copy statement if its copybook contains error", async () => {
const editor = await helper.showDocument(path.join("TEST8.CBL"));
await helper.deleteLine(editor, 12);
const extSrcPath = path.join("testing", "REPLERR");
await helper.showDocument(extSrcPath);
await helper.waitFor(
() => vscode.languages.getDiagnostics(editor.document.uri).length > 1,
);
const diagnostics = vscode.languages.getDiagnostics(editor.document.uri);
helper.assertRangeIsEqual(
diagnostics[0].range,
range(pos(18, 11), pos(18, 24)),
);
});

test("TC247997: Info message for copybooks cannot be downloaded", async () => {
const editor = await helper.showDocument(path.join("USERC1F.cbl"));
await helper.waitFor(
() => vscode.languages.getDiagnostics(editor.document.uri).length > 1,
);
const diagnostics = vscode.languages.getDiagnostics(editor.document.uri);
const message = diagnostics[0].message;
assert.match(message, /^BOOK3: Copybook not found/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,19 @@ suite("TF35623: Support for Replacing and Mapping statement", function () {
assert.match(message, /^Syntax error on 'REPLACING' expected SECTION/);
});

test("TC250946: Support building of the extended document - Replace by arithmetic operations", async () => {
let editor = await helper.showDocument(path.join("TEST7.CBL"));
const extSrcPath = path.join("testing", "NEW.CPY");
editor = await helper.showDocument(extSrcPath);
await helper.waitFor(
() => vscode.languages.getDiagnostics(editor.document.uri).length > 0,
);
let diagnostics = vscode.languages.getDiagnostics(editor.document.uri);
const message = diagnostics[0].message;
assert.match(message, /^Missing token SECTION at procedureSectionHeader/);
});
test(
"TC250946: Support building of the extended document - Replace by arithmetic operations" +
"TC314935: Copybook with Name in Quotes is Recognized",
async () => {
let editor = await helper.showDocument(path.join("TEST7.CBL"));
const extSrcPath = path.join("testing", "NEW.CPY");
editor = await helper.showDocument(extSrcPath);
await helper.waitFor(
() => vscode.languages.getDiagnostics(editor.document.uri).length > 0,
);
let diagnostics = vscode.languages.getDiagnostics(editor.document.uri);
const message = diagnostics[0].message;
assert.match(message, /^Missing token SECTION at procedureSectionHeader/);
},
);
});
23 changes: 23 additions & 0 deletions tests/test_files/project/TEST8.CBL
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
* Copyright (c) 2021 Broadcom. *
* The term "Broadcom" refers to Broadcom Inc. and/or its *
* subsidiaries. *
* *
* This program and the accompanying materials are made *
* available under the terms of the Eclipse Public License 2.0 *
* which is available at https://www.eclipse.org/legal/epl-2.0/ *
* *
* SPDX-License-Identifier: EPL-2.0 *
* *
* Contributors: *
* Broadcom, Inc. - initial API and implementation *
****************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. ABCDEF.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PARENT.
COPY REPLERR.
PROCEDURE DIVISION.

MAINLINE.
GOBACK.
29 changes: 29 additions & 0 deletions tests/test_files/project/TEST_TITLE.CBL
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
* Copyright (c) 2021 Broadcom. *
* The term "Broadcom" refers to Broadcom Inc. and/or its *
* subsidiaries. *
* *
* This program and the accompanying materials are made *
* available under the terms of the Eclipse Public License 2.0 *
* which is available at https://www.eclipse.org/legal/epl-2.0/ *
* *
* SPDX-License-Identifier: EPL-2.0 *
* *
* Contributors: *
* Broadcom, Inc. - initial API and implementation *
****************************************************************
TITLE "Something".
IDENTIFICATION DIVISION.
PROGRAM-ID. ABCDEF.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Variable-FFFF PIC 9(9).
01 PARENT.
COPY REPL.
PROCEDURE DIVISION.

MAINLINE.
MOVE 0 TO ABC-ID.

GOBACK.

End program ABCDEf.
2 changes: 2 additions & 0 deletions tests/test_files/project/testing/REPLERR
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
05 TAG-ID PIC 9.
05 TAR-ID PI 9.
Loading