|
| 1 | +/* |
| 2 | + * Copyright (c) 2021 Broadcom. |
| 3 | + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. |
| 4 | + * |
| 5 | + * This program and the accompanying materials are made |
| 6 | + * available under the terms of the Eclipse Public License 2.0 |
| 7 | + * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 8 | + * |
| 9 | + * SPDX-License-Identifier: EPL-2.0 |
| 10 | + * |
| 11 | + * Contributors: |
| 12 | + * Broadcom, Inc. - initial API and implementation |
| 13 | + * |
| 14 | + */ |
| 15 | +package org.eclipse.lsp.cobol.usecases; |
| 16 | + |
| 17 | +import com.google.common.collect.ImmutableList; |
| 18 | +import com.google.common.collect.ImmutableMap; |
| 19 | +import org.eclipse.lsp.cobol.service.delegates.validations.SourceInfoLevels; |
| 20 | +import org.eclipse.lsp.cobol.usecases.engine.UseCaseEngine; |
| 21 | +import org.eclipse.lsp4j.Diagnostic; |
| 22 | +import org.eclipse.lsp4j.DiagnosticSeverity; |
| 23 | +import org.junit.jupiter.api.Test; |
| 24 | + |
| 25 | +/** |
| 26 | + * Test that not completely typed variable definition doesn't produce an exception. |
| 27 | + */ |
| 28 | +class TestHalfTypedVariableDefinition { |
| 29 | + private static final String TEXT = |
| 30 | + " Identification Division.\n" |
| 31 | + + " Program-id. HELLO-WORLD.\n" |
| 32 | + + " DATA DIVISION.\n" |
| 33 | + + " WORKING-STORAGE SECTION.\n" |
| 34 | + + " 01 {$*COD-RETOUR} PIC X{(|1}{66|2}{|3}"; |
| 35 | + |
| 36 | + @Test |
| 37 | + void test() { |
| 38 | + UseCaseEngine.runTest(TEXT, ImmutableList.of(), ImmutableMap.of( |
| 39 | + "1", |
| 40 | + new Diagnostic(null, "Extraneous input '(' expected {BINARY, BLANK, COMP, COMPUTATIONAL, " |
| 41 | + + "COMPUTATIONAL-1, COMPUTATIONAL-2, COMPUTATIONAL-3, COMPUTATIONAL-4, COMPUTATIONAL-5, COMP-1, COMP-2, " |
| 42 | + + "COMP-3, COMP-4, COMP-5, DISPLAY, DISPLAY-1, DYNAMIC, EXTERNAL, FUNCTION-POINTER, GLOBAL, GROUP-USAGE, " |
| 43 | + + "INDEX, IS, JUST, JUSTIFIED, LEADING, NATIONAL, OBJECT, OCCURS, PACKED-DECIMAL, PIC, PICTURE, POINTER, " |
| 44 | + + "POINTER-32, PROCEDURE-POINTER, REDEFINES, SIGN, SYNC, SYNCHRONIZED, TRAILING, USAGE, UTF-8, VALUE, " |
| 45 | + + "VALUES, VOLATILE, '.', '.'2}", |
| 46 | + DiagnosticSeverity.Error, SourceInfoLevels.ERROR.getText()), |
| 47 | + "2", |
| 48 | + new Diagnostic(null, "No data definition entry found for rename", |
| 49 | + DiagnosticSeverity.Error, SourceInfoLevels.ERROR.getText()), |
| 50 | + "3", |
| 51 | + new Diagnostic(null, "Unexpected end of file", |
| 52 | + DiagnosticSeverity.Error, SourceInfoLevels.ERROR.getText()) |
| 53 | + )); |
| 54 | + } |
| 55 | +} |
0 commit comments