From 13cc1982d69c7a1338b6148aa8d42ab5597f0135 Mon Sep 17 00:00:00 2001 From: Aman Prashant Date: Tue, 5 Mar 2024 15:14:50 +0100 Subject: [PATCH] fix: update cics delay statement as per doc update cics delay statement as per doc. Ref: https://www.ibm.com/docs/en/cics-ts/6.1?topic=summary-delay Signed-off-by: Aman Prashant --- .../org/eclipse/lsp/cics/parser/CICSLexer.g4 | 1 + .../org/eclipse/lsp/cics/parser/CICSParser.g4 | 5 +- .../usecases/TestCicsDelayStatement.java | 66 +++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/TestCicsDelayStatement.java diff --git a/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSLexer.g4 b/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSLexer.g4 index fd7b18d38c..a49bf04ea5 100644 --- a/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSLexer.g4 +++ b/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSLexer.g4 @@ -460,6 +460,7 @@ METADATA : M E T A D A T A; METADATALEN : M E T A D A T A L E N; METHOD : M E T H O D; METHODLENGTH : M E T H O D L E N G T H; +MILLISECS: M I L L I S E C S; MILLISECONDS : M I L L I S E C O N D S; MINIMUM : M I N I M U M; MINUTES : M I N U T E S; diff --git a/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSParser.g4 b/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSParser.g4 index f3df3971da..4bbf8c07d0 100644 --- a/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSParser.g4 +++ b/server/engine/src/main/antlr4/org/eclipse/lsp/cics/parser/CICSParser.g4 @@ -314,8 +314,9 @@ cics_define_at: AT (HOURS cics_data_value | MINUTES cics_data_value | SECONDS ci cics_define_on: ON YEAR cics_data_value (MONTH cics_data_value DAYOFMONTH cics_data_value | DAYOFYEAR cics_data_value) cics_handle_response?; /** DELAY */ -cics_delay: DELAY (INTERVAL cics_zero_digit | INTERVAL cics_hhmmss | TIME cics_hhmmss | cics_delay_for | REQID cics_name | cics_handle_response)+; -cics_delay_for: (FOR | UNTIL) (HOURS cics_data_value | MINUTES cics_data_value | SECONDS cics_data_value)+; +cics_delay: DELAY (INTERVAL cics_zero_digit | INTERVAL cics_hhmmss | TIME cics_hhmmss | cics_delay_for | cics_dealy_until | REQID cics_name | cics_handle_response)+; +cics_delay_for: FOR (HOURS cics_data_value | MINUTES cics_data_value | SECONDS cics_data_value | MILLISECS cics_data_value)+; +cics_dealy_until: UNTIL (HOURS cics_data_value | MINUTES cics_data_value | SECONDS cics_data_value)+; /** DELETE (all of them) */ cics_delete: DELETE (cics_delete_file | ACTIVITY cics_data_value | cics_delete_container | cics_delete_counter | diff --git a/server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/TestCicsDelayStatement.java b/server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/TestCicsDelayStatement.java new file mode 100644 index 0000000000..dd20ad236e --- /dev/null +++ b/server/engine/src/test/java/org/eclipse/lsp/cobol/usecases/TestCicsDelayStatement.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 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 + * + */ +package org.eclipse.lsp.cobol.usecases; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.eclipse.lsp.cobol.test.engine.UseCaseEngine; +import org.junit.jupiter.api.Test; + +/** Test CICS DELAY statement as per https://www.ibm.com/docs/en/cics-ts/6.1?topic=summary-delay */ +public class TestCicsDelayStatement { + private static final String PREFIX = + " IDENTIFICATION DIVISION.\n" + + " PROGRAM-ID. TEXTEX.\n" + + " DATA DIVISION.\n" + + " WORKING-STORAGE SECTION.\n" + + " 01 {$*CHECK} pic x(9).\n" + + " PROCEDURE DIVISION.\n"; + public static final String TEXT = + PREFIX + + " EXEC CICS \n" + + " DELAY FOR MILLISECS(500) REQID({$CHECK})\n" + + " NOHANDLE \n" + + " END-EXEC."; + + public static final String TEXT2 = + PREFIX + + " EXEC CICS \n" + + " DELAY INTERVAL({$CHECK}) REQID({$CHECK})\n" + + " NOHANDLE \n" + + " END-EXEC."; + + public static final String TEXT3 = + PREFIX + + " EXEC CICS \n" + + " DELAY UNTIL HOURS(500) MINUTES(800) REQID({$CHECK})\n" + + " NOHANDLE \n" + + " END-EXEC."; + + @Test + void test_delayStatement_flow1() { + UseCaseEngine.runTest(TEXT, ImmutableList.of(), ImmutableMap.of()); + } + + @Test + void test_delayStatement_flow2() { + UseCaseEngine.runTest(TEXT2, ImmutableList.of(), ImmutableMap.of()); + } + + @Test + void test_delayStatement_flow3() { + UseCaseEngine.runTest(TEXT3, ImmutableList.of(), ImmutableMap.of()); + } +}