Skip to content

Commit

Permalink
test: fix dialect test
Browse files Browse the repository at this point in the history
Signed-off-by: Aman Prashant <aman.prashant@broadcom.com>
  • Loading branch information
ap891843 committed May 24, 2024
1 parent ba78fa1 commit d76649c
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
Expand All @@ -33,7 +33,7 @@
class TestAdjustCopyMaidNumbers {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.common.error.ErrorCodes;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp4j.Diagnostic;
Expand All @@ -32,7 +32,7 @@
class TestCopyMaidDoesNotShowMissingCopybookOnStatementWithoutNumber {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** Test that COPY MAID statement is not resolved if it is in the PROCEDURE DIVISION */
class TestCopyMaidIsNotResolvedInProcedureDivision {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

Expand All @@ -29,7 +29,7 @@
class TestCopyMaidWithKmkRequestsCorrectFile {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
*/
package org.eclipse.lsp.cobol.dialects.daco.usecases;

import static java.util.stream.Collectors.toList;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.model.tree.CopyNode;
import org.eclipse.lsp.cobol.common.model.NodeType;
import org.eclipse.lsp.cobol.common.model.tree.CopyNode;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.dialects.daco.utils.Fixtures;
import org.eclipse.lsp.cobol.dialects.idms.IdmsDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp.cobol.test.engine.UseCaseUtils;
import org.eclipse.lsp.cobol.dialects.daco.utils.Fixtures;
import org.eclipse.lsp4j.Diagnostic;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;

import static java.util.stream.Collectors.toList;

/** COPY MAID copybook definitions should have correct URIs */
class TestCopyMaidWithQualifierHasCorrectDefinition {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " DATA DIVISION.\n"
+ " WORKING-STORAGE SECTION.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

Expand All @@ -29,7 +29,7 @@
class TestCopyMaidWithRedefinesGroupVariable {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

Expand All @@ -29,7 +29,7 @@
class TestCopyMaidWithWRK {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** WRK qualifier should work when specified in any case. */
class TestCopyMaidWithWrkDifferentCase {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** WRK qualifier does not retrieve the name of the previous 88 variable. */
class TestCopyMaidWithWrkDoesNotTakeNameFrom88 {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

Expand All @@ -29,7 +29,7 @@
class TestCopyMaidWithWrkRedefines {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** WRK qualifier should work even with copybooks with too short name. */
class TestCopyMaidWithWrkShortName {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
Expand All @@ -30,7 +30,7 @@
class TestCopyMaidWithWrkShowsErrorAfterFiller {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
Expand All @@ -30,7 +30,7 @@
class TestCopyMaidWithWrkShowsErrorAfterVariableWithoutName {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.common.error.ErrorSource;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;
Expand All @@ -30,7 +30,7 @@
class TestCopyMaidWithWrkShowsErrorOnShortVariableName {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.DaCoDialect;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.CobolText;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** WRK qualifier should work when specified in any case. */
class TestCopyMaidWithWrkThreeCharsSuffix {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestDaCoRcu {

private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class TestDaCoWhenKeywordTerminator {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.eclipse.lsp.cobol.dialects.daco.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp.cobol.dialects.daco.utils.Fixtures;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.Test;

/** This test covers case with overlap locations in mapping */
class TestOnRcuRangeException {
static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " DATA DIVISION.\n"
+ " WORKING-STORAGE SECTION.\n"
+ " 01 {$*A} PIC X.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class TestReadTransaction {
private static final String TEXT =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " PROCEDURE DIVISION.\n"
+ " {#*FOO}.\n"
+ " READ TRANSACTION\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class TestUserDefinedSections {
private static final String TEXT_GOTO =
" IDENTIFICATION DIVISION.\n"
+ " PROGRAM-ID. TEST.\n"
+ " PROGRAM-ID. TEST1.\n"
+ " ENVIRONMENT DIVISION.\n"
+ " IDMS-CONTROL SECTION.\n"
+ " PROTOCOL. MODE ABC.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.stream.Stream;
import org.eclipse.lsp.cobol.dialects.idms.utils.DialectConfigs;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.eclipse.lsp.cobol.dialects.idms.utils.Fixtures;
import org.eclipse.lsp.cobol.test.engine.UseCaseEngine;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.Stream;

/** These test for variations of valid DELETE statements */
class TestDelete {

Expand All @@ -34,7 +33,7 @@ class TestDelete {
+ " ENVIRONMENT DIVISION.\r\n"
+ " INPUT-OUTPUT SECTION.\r\n"
+ " FILE-CONTROL.\r\n"
+ " SELECT {$SCRATCH} ASSIGN TO TEST \r\n"
+ " SELECT {$SCRATCH} ASSIGN TO TEST2 \r\n"
+ " ORGANIZATION IS LINE SEQUENTIAL \r\n"
+ " ACCESS MODE IS SEQUENTIAL. \r\n"
+ " DATA DIVISION. \r\n"
Expand Down
Loading

0 comments on commit d76649c

Please sign in to comment.