Skip to content

Commit a7c7eca

Browse files
committed
New test cases at resources + input/output
Signed-off-by: Flavia Beo <flavia.beo@ibm.com>
1 parent 5881489 commit a7c7eca

File tree

9 files changed

+427
-223
lines changed

9 files changed

+427
-223
lines changed
Lines changed: 6 additions & 223 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
translate code from cobol to java
1+
System:
2+
Solve the following coding problem. Wrap your code answer using ```
23

34

4-
Input:
5+
Question:
6+
Translate code from cobol to java:
7+
58
DEMO-TASKA.
6-
7-
* This is prompt example 1 *
89
MOVE 'HELLO WORLD' TO VA-TAB
910
MOVE '45' TO CA-PAYMENT
1011
IF MAN-BOOKER IS EQUAL TO 24
@@ -30,223 +31,5 @@ ENDIF
3031
DISPLAY AGE
3132
EXIT.
3233

33-
## Variable Map:
34-
VA-TAB gettermapping recordBook.getRetailName().getTabValue()
35-
VA-TAB settermapping recordBook.getRetailName().setTabValue(val)
36-
VA-TAB PIC X(20) JavaType String
37-
MAN-BOOKER gettermapping markDanson.getPost().getManBooker()
38-
MAN-BOOKER settermapping markDanson.getPost().setManBooker(val)
39-
MAN-BOOKER PIC 9(3) JavaType int
40-
CA-PAYMENT gettermapping this.getCaPayment()
41-
CA-PAYMENT settermapping this.setCaPayment(val)
42-
CA-PAYMENT PIC 9(2) JavaType int
43-
PY-RES-INT gettermapping this.getPyResInt()
44-
PY-RES-INT settermapping this.setPyResInt(val)
45-
PY-RES-INT PIC 99 JavaType int
46-
SHAP-VALUE gettermapping this.retail.getShapValue()
47-
SHAP-VALUE settermapping this.retail.setShapValue(val)
48-
SHAP-VALUE PIC X(4) JavaType String
49-
SAN-NUM gettermapping sanNum
50-
SAN-NUM settermapping sanNum
51-
SAN-NUM PIC 9(2) JavaType int
52-
AGE gettermapping spa.getInt("age")
53-
AGE settermapping spa.setInt("age", val)
54-
AGE PIC 9(2) JavaType int
55-
TRAN-RATE-INTERVAL, markDanson.tranInterval(reportVal)
56-
57-
## Class Map:
58-
void demoTaskA(int sanNum){
59-
bookShop markDanson = new BookShop();
60-
}
61-
62-
Output:
63-
void demoTaskA(int sanNum) {
64-
bookShop markDanson = new BookShop();
65-
/* This is prompt example 1 */
66-
recordBook.getRetailName().setTabValue("HELLO WORLD");
67-
this.setCaPayment(Integer.parseInt("45"));
68-
69-
if (markDanson.getPost().getManBooker() == 24) {
70-
try {
71-
String sql = "INSERT INTO ADDR(NUMBER, NAME)values(?, ?)";
72-
PreparedStatement ps = JdbcConnection.connection.prepareStatement(sql);
73-
ps.setInt(1, sanNum);
74-
ps.setString(2, this.retail.getShapValue());
75-
ps.executeUpdate();
76-
ps.close();
77-
}
78-
catch(SQLException exception) {
79-
markDanson.tranInterval(reportVal);
80-
return;
81-
}
82-
}
83-
try{
84-
ResultSet rs = JdbcConnection.connection.createStatement().executeQuery("SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1");
85-
rs.next();
86-
sanNum = rs.getInt(1);
87-
}
88-
catch(SQLException exception){
89-
System.out.println(exception);
90-
return;
91-
}
92-
this.setPyResInt(sanNum);
93-
markDanson.getPost().setManBooker(25);
94-
spa.setInt("age", 20);
95-
System.out.println( spa.getInt("age") );
96-
}
97-
98-
Input:
99-
BUZZ-VAL.
100-
* This is prompt example 2 *
101-
IF CAN-BANK-VAL IS EQUAL TO 87
102-
EXEC SQL
103-
INSERT INTO BANK
104-
( NUM,
105-
LOCATION)
106-
VALUES ( DEFAULT,
107-
:SYS-GERM)
108-
END-EXEC
109-
IF SQLCODE NOT EQUAL 0
110-
MOVE '10' TO CA-SUM-ASSURED
111-
PERFORM PRINT-FUNCTION
112-
EXEC STATEMENT2 END-EXEC
113-
END-IF
114-
END-IF
115-
EXIT.
116-
117-
## Variable Map:
118-
SYS-GERM gettermapping sysGerm
119-
SYS-GERM settermapping sysGerm
120-
SYS-GERM PIC X(5) JavaType String
121-
CAN-BANK-VAL gettermapping bankVar.getCanBankVal()
122-
CAN-BANK-VAL settermapping bankVar.setCanBankVal(val)
123-
CAN-BANK-VAL 9(3) JavaType int
124-
CA-SUM-ASSURED gettermapping this.getCaSumAssured()
125-
CA-SUM-ASSURED settermapping this.setCaSumAssured(val)
126-
CA-SUM-ASSURED PIC 99 JavaType int
127-
PRINT-FUNCTION, this.printFunction(errReport)
128-
129-
## Class Map:
130-
void buzzVal(String caRhNum){
131-
int poll = 0;
132-
}
133-
134-
Output:
135-
void buzzVal(String caRhNum){
136-
int poll = 0;
137-
/* This is prompt example 2 */
138-
if (bankVar.getCanBankVal() == 87){
139-
try {
140-
String sql = "INSERT INTO BANK(LOCATION)values(?)";
141-
PreparedStatement ps = JdbcConnection.connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
142-
ps.setString(1, sysGerm);
143-
ps.executeUpdate();
144-
ps.close();
145-
}
146-
catch(SQLException exception) {
147-
this.setCaSumAssured(Integer.parseInt("10"));
148-
this.printFunction(errReport);
149-
return;
150-
}
151-
}
152-
}
153-
154-
Input:
155-
IF WS-DISPLAY-LINE = "* MQPUTSUB V1.0 " AND
156-
CA-RETURN-CODE = 0 AND
157-
WS-DEBUG = " " AND
158-
WS-COMM-QUEUE = "COMM BLOCK DATA" AND
159-
B100-NOT-RAN AND
160-
B117-NOT-RAN AND
161-
W500-RAN THEN
162-
DISPLAY "TEST 3 PASSED"
163-
ELSE
164-
DISPLAY "TEST 3 FAILED"
165-
END-IF
166-
INITIALIZE WS-COMM-BLOCK
167-
INITIALIZE WS-DISPLAY-LINE
168-
INITIALIZE WS-CONFIG-PARAMETERS
169-
INITIALIZE CA-MQPUTSUB-PARM
170-
SET DISCONNECT-ACTION TO TRUE
171-
SET TOGGLE-ERROR-FLAG TO TRUE
172-
MOVE "COMM BLOCK DATA" TO CA-COMM-BLOCK
173-
MOVE "QUEUE DATA" TO WS-QUEUE
174-
INITIALIZE SECTIONS-RUN
175-
PERFORM B000-INITIALISE.
176-
IF WS-DISPLAY-LINE = "* MQPUTSUB V1.0 " AND
177-
CA-RETURN-CODE = 0 AND
178-
WS-DEBUG = " " AND
179-
WS-COMM-QUEUE = "COMM BLOCK DATA" AND
180-
B100-NOT-RAN AND
181-
B117-NOT-RAN AND
182-
W500-RAN THEN
183-
DISPLAY "TEST 4 PASSED"
184-
ELSE
185-
DISPLAY "TEST 4 FAILED"
186-
END-IF.
187-
188-
## Variable Map:
189-
WS-QUEUE gettermapping wsConfigParameters.getWsQueue()
190-
WS-QUEUE settermapping wsConfigParameters.setWsQueue(val)
191-
WS-QUEUE PIC X(00048) JavaType String
192-
WS-DISPLAY-LINE gettermapping wsDisplayLine.getBytes()
193-
WS-DISPLAY-LINE settermapping wsDisplayLine.setBytes(val)
194-
WS-DISPLAY-LINE GROUP JavaType WsDisplayLine
195-
WS-DEBUG gettermapping wsCommBlock.getWsDebug()
196-
WS-DEBUG settermapping wsCommBlock.setWsDebug(val)
197-
WS-DEBUG PIC X(00001) JavaType char
198-
WS-CONFIG-PARAMETERS gettermapping wsConfigParameters.getBytes()
199-
WS-CONFIG-PARAMETERS settermapping wsConfigParameters.setBytes(val)
200-
WS-CONFIG-PARAMETERS GROUP JavaType WsConfigParameters
201-
WS-COMM-QUEUE gettermapping wsCommBlock.getWsCommQueue()
202-
WS-COMM-QUEUE settermapping wsCommBlock.setWsCommQueue(val)
203-
WS-COMM-QUEUE PIC X(00048) JavaType String
204-
WS-COMM-BLOCK gettermapping wsCommBlock.getBytes()
205-
WS-COMM-BLOCK settermapping wsCommBlock.setBytes(val)
206-
WS-COMM-BLOCK GROUP JavaType WsCommBlock
207-
W500-RAN gettermapping sectionsRun.isW500Ran()
208-
W500-RAN settermapping sectionsRun.setW500Ran()
209-
W500-RAN 88 JavaType boolean
210-
TOGGLE-ERROR-FLAG gettermapping testFlags.isToggleErrorFlag()
211-
TOGGLE-ERROR-FLAG settermapping testFlags.setToggleErrorFlag()
212-
TOGGLE-ERROR-FLAG 88 JavaType boolean
213-
TEST-ERROR-FLAG gettermapping testFlags.getTestErrorFlag()
214-
TEST-ERROR-FLAG settermapping testFlags.setTestErrorFlag(val)
215-
TEST-ERROR-FLAG PIC 9 JavaType int
216-
SECTIONS-RUN gettermapping sectionsRun.getBytes()
217-
SECTIONS-RUN settermapping sectionsRun.setBytes(val)
218-
SECTIONS-RUN GROUP JavaType SectionsRun
219-
DISCONNECT-ACTION gettermapping caMqputsubParm.getCaHeader().isDisconnectAction()
220-
DISCONNECT-ACTION settermapping caMqputsubParm.getCaHeader().setDisconnectAction()
221-
DISCONNECT-ACTION 88 JavaType boolean
222-
CA-RETURN-CODE gettermapping caMqputsubParm.getCaHeader().getCaReturnCode()
223-
CA-RETURN-CODE settermapping caMqputsubParm.getCaHeader().setCaReturnCode(val)
224-
CA-RETURN-CODE PIC 9(00004) JavaType int
225-
CA-MQPUTSUB-PARM gettermapping caMqputsubParm.getBytes()
226-
CA-MQPUTSUB-PARM settermapping caMqputsubParm.setBytes(val)
227-
CA-MQPUTSUB-PARM GROUP JavaType CaMqputsubParm
228-
CA-COMM-BLOCK gettermapping caMqputsubParm.getCaHeader().getCaCommBlock()
229-
CA-COMM-BLOCK settermapping caMqputsubParm.getCaHeader().setCaCommBlock(val)
230-
CA-COMM-BLOCK PIC X(00057) JavaType String
231-
CA-ACTION gettermapping caMqputsubParm.getCaHeader().getCaAction()
232-
CA-ACTION settermapping caMqputsubParm.getCaHeader().setCaAction(val)
233-
CA-ACTION PIC X(00004) JavaType String
234-
B117-NOT-RAN gettermapping sectionsRun.isB117NotRan()
235-
B117-NOT-RAN settermapping sectionsRun.setB117NotRan()
236-
B117-NOT-RAN 88 JavaType boolean
237-
B100-NOT-RAN gettermapping sectionsRun.isB100NotRan()
238-
B100-NOT-RAN settermapping sectionsRun.setB100NotRan()
239-
B100-NOT-RAN 88 JavaType boolean
240-
B000-INITIALISE, b000Initialise(caMqputsubParm, flErrorFlag, sectionsRun, testFlags, wsCommBlock, wsConfigParameters, wsDisplayLine)
241-
242-
## Class Map:
243-
public void testPara(){
244-
CaMqputsubParm caMqputsubParm = new CaMqputsubParm();
245-
FlErrorFlag flErrorFlag = new FlErrorFlag();
246-
SectionsRun sectionsRun = new SectionsRun();
247-
TestFlags testFlags = new TestFlags();
248-
WsCommBlock wsCommBlock = new WsCommBlock();
249-
WsConfigParameters wsConfigParameters = new WsConfigParameters();
250-
WsDisplayLine wsDisplayLine = new WsDisplayLine();
251-
}
25234

35+
Answer:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
System:
2+
Solve the following coding problem. Wrap your code answer using ```
3+
4+
5+
Question:
6+
Translate code from cobol to java:
7+
8+
BUZZ-VAL.
9+
IF CAN-BANK-VAL IS EQUAL TO 87
10+
EXEC SQL
11+
INSERT INTO BANK
12+
( NUM,
13+
LOCATION)
14+
VALUES ( DEFAULT,
15+
:SYS-GERM)
16+
END-EXEC
17+
IF SQLCODE NOT EQUAL 0
18+
MOVE '10' TO CA-SUM-ASSURED
19+
PERFORM PRINT-FUNCTION
20+
EXEC STATEMENT2 END-EXEC
21+
END-IF
22+
END-IF
23+
EXIT.
24+
25+
26+
Answer:
27+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
System:
2+
Solve the following coding problem. Wrap your code answer using ```
3+
4+
5+
Question:
6+
Translate code from cobol to java:
7+
DIF WS-DISPLAY-LINE = "* MQPUTSUB V1.0 " AND
8+
CA-RETURN-CODE = 0 AND
9+
WS-DEBUG = " " AND
10+
WS-COMM-QUEUE = "COMM BLOCK DATA" AND
11+
B100-NOT-RAN AND
12+
B117-NOT-RAN AND
13+
W500-RAN THEN
14+
DISPLAY "TEST 3 PASSED"
15+
ELSE
16+
DISPLAY "TEST 3 FAILED"
17+
END-IF
18+
INITIALIZE WS-COMM-BLOCK
19+
INITIALIZE WS-DISPLAY-LINE
20+
INITIALIZE WS-CONFIG-PARAMETERS
21+
INITIALIZE CA-MQPUTSUB-PARM
22+
SET DISCONNECT-ACTION TO TRUE
23+
SET TOGGLE-ERROR-FLAG TO TRUE
24+
MOVE "COMM BLOCK DATA" TO CA-COMM-BLOCK
25+
MOVE "QUEUE DATA" TO WS-QUEUE
26+
INITIALIZE SECTIONS-RUN
27+
PERFORM B000-INITIALISE.
28+
IF WS-DISPLAY-LINE = "* MQPUTSUB V1.0 " AND
29+
CA-RETURN-CODE = 0 AND
30+
WS-DEBUG = " " AND
31+
WS-COMM-QUEUE = "COMM BLOCK DATA" AND
32+
B100-NOT-RAN AND
33+
B117-NOT-RAN AND
34+
W500-RAN THEN
35+
DISPLAY "TEST 4 PASSED"
36+
ELSE
37+
DISPLAY "TEST 4 FAILED"
38+
END-IF.
39+
40+
41+
Answer:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
System:
2+
Solve the following coding problem. Wrap your code answer using ```
3+
4+
5+
Question:
6+
Translate the following cobol code to python:
7+
MOVE 'HELLO WORLD' TO VA-TAB
8+
MOVE '45' TO CA-PAYMENT
9+
IF MAN-BOOKER IS EQUAL TO 24
10+
EXEC SQL
11+
INSERT INTO ADDR
12+
( NUMBER,
13+
NAME)
14+
VALUES ( :SAN-NUM,
15+
:SHAP-VALUE)
16+
END-EXEC
17+
IF SQLCODE NOT EQUAL 0
18+
PERFORM TRAN-RATE-INTERVAL
19+
EXEC STATEMENT1 END-EXEC
20+
END-IF
21+
ENDIF
22+
EXEC SQL
23+
SET :SAN-NUM = IDENTITY_VAL_LOCAL()
24+
END-EXEC
25+
26+
MOVE SAN-NUM TO PY-RES-INT
27+
MOVE 25 TO MAN-BOOKER
28+
MOVE 20 TO AGE
29+
DISPLAY AGE
30+
EXIT.
31+
32+
33+
Answer:
34+
```python
35+
va_tab = 'HELLO WORLD'
36+
ca_payment = '45'
37+
38+
if man_booker == 24:
39+
try:
40+
with sqlite3.connect('example.db') as conn:
41+
cursor = conn.cursor()
42+
cursor.execute("INSERT INTO ADDR (NUMBER, NAME) VALUES (?, ?)", (san_num, shap_value))
43+
conn.commit()
44+
except sqlite3.Error as e:
45+
print(f"Error: {e}")
46+
perform_tran_rate_interval()
47+
finally:
48+
cursor.close()
49+
50+
try:
51+
with sqlite3.connect('example.db') as conn:
52+
cursor = conn.cursor()
53+
cursor.execute("SET ?", (san_num,))
54+
conn.commit()
55+
except sqlite3.Error as e:
56+
print(f"Error: {e}")
57+
finally:
58+
cursor.close()
59+
60+
py_res_int = san_num
61+
man_booker = 25
62+
age = 20
63+
print(age)
64+
exit()
65+
66+
```

0 commit comments

Comments
 (0)