Skip to content

Commit 9f3a81d

Browse files
authored
Fix getSign() (#549)
* [WIP] Fix getSign() * Fix getSign() and add a test case
1 parent 4436faa commit 9f3a81d

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/data/CobolNumericField.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,7 @@ public int getSign() {
475475
if (attr.isFlagSignSeparate()) {
476476
return value == 0x2b ? 1 : -1;
477477
} else {
478-
if (0x30 <= value && value <= 0x39) {
479-
return 1;
480-
}
481-
if (value == 0x20) {
482-
this.getDataStorage().setByte(p, (byte) 0x30);
478+
if (value == 0x20 || (0x30 <= value && value <= 0x39)) {
483479
return 1;
484480
}
485481

tests/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ misc_DEPENDENCIES = \
223223
misc.src/file-handler-japanese.at \
224224
misc.src/perform-until-div.at \
225225
misc.src/search-occurs-depending.at \
226-
misc.src/fix-subtract.at
226+
misc.src/fix-subtract.at \
227+
misc.src/display-numeric-NUMERIC-class.at
227228

228229
EXTRA_DIST = $(srcdir)/package.m4 \
229230
$(TESTS) \

tests/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ misc_DEPENDENCIES = \
762762
misc.src/file-handler-japanese.at \
763763
misc.src/perform-until-div.at \
764764
misc.src/search-occurs-depending.at \
765-
misc.src/fix-subtract.at
765+
misc.src/fix-subtract.at \
766+
misc.src/display-numeric-NUMERIC-class.at
766767

767768
EXTRA_DIST = $(srcdir)/package.m4 \
768769
$(TESTS) \

tests/misc.at

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ m4_include([file-handler-japanese.at])
5353
m4_include([perform-until-div.at])
5454
m4_include([search-occurs-depending.at])
5555
m4_include([fix-subtract.at])
56+
m4_include([display-numeric-NUMERIC-class.at])
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AT_SETUP([DISPLAY numeric after NUMERIC class testing])
2+
3+
AT_DATA([prog.cbl], [
4+
IDENTIFICATION DIVISION.
5+
PROGRAM-ID. prog.
6+
DATA DIVISION.
7+
WORKING-STORAGE SECTION.
8+
01 N-REC.
9+
03 N-VAL PIC 9.
10+
PROCEDURE DIVISION.
11+
MAIN-PROC.
12+
*************************************************************
13+
MOVE SPACE TO N-REC.
14+
DISPLAY "N-VAL: '" N-VAL "'".
15+
16+
IF N-VAL NUMERIC
17+
DISPLAY "N-VAL is numeric"
18+
ELSE
19+
DISPLAY "N-VAL is not numeric"
20+
END-IF.
21+
22+
DISPLAY "N-VAL: '" N-VAL "'".
23+
])
24+
25+
AT_CHECK([${COBJ} prog.cbl])
26+
AT_CHECK([java prog], [0],
27+
[N-VAL: ' '
28+
N-VAL is not numeric
29+
N-VAL: ' '
30+
])
31+
32+
AT_CLEANUP

0 commit comments

Comments
 (0)