Skip to content

Commit 0178e34

Browse files
Fix FUNCTION VARIANCE and a test case of FUNCTION SQRT (#280)
1 parent 3b990b8 commit 0178e34

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2222
* Fix error handlings of 0 divisions (#273)
2323
* Fix an error of comparing large numbers (#275)
2424
* Fix checkings for subscripts (#277)
25+
* Fix FUNCTION VARIANCE and a test case of FUNCTION SQRT (#280)
2526
### Optimized
2627
* Optimize the file reading process (#257)
2728

libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/CobolIntrinsic.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,18 +1554,17 @@ public static AbstractCobolField funcVariance(int prams, AbstractCobolField... f
15541554
}
15551555
CobolDataStorage data = new CobolDataStorage(8);
15561556
field.setDataStorage(data);
1557-
d4.getDisplayField(field, 0);
1558-
long n = data.longValue();
1557+
d4.getField(field, 0);
1558+
long n = field.getLong();
15591559
int i = 0;
15601560
while (n != 0) {
15611561
n /= 10;
15621562
++i;
15631563
}
1564-
field.setDataStorage(null);
1564+
makeFieldEntry(field);
15651565
if (i <= 18) {
15661566
attr.setScale(18 - i);
15671567
}
1568-
makeDoubleEntry();
15691568
d4.getField(currField, 0);
15701569
return currField;
15711570
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private void moveAlphanumericToDisplay(AbstractCobolField field) {
335335
// TODO Moduleの情報を参照するコードに編集する
336336
} else if (c == (byte) '.') {
337337
++count;
338-
if (count > 0) {
338+
if (count > 1) {
339339
break outer;
340340
}
341341

tests/run.src/functions.at

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,6 @@ AT_CHECK([java prog], [0],
15371537
AT_CLEANUP
15381538

15391539
AT_SETUP([FUNCTION SQRT])
1540-
AT_CHECK([${SKIP_TEST}])
15411540

15421541
AT_DATA([prog.cob], [
15431542
IDENTIFICATION DIVISION.
@@ -1548,8 +1547,8 @@ AT_DATA([prog.cob], [
15481547
01 Y PIC S9V9(17) COMP.
15491548
PROCEDURE DIVISION.
15501549
MOVE FUNCTION SQRT ( X ) TO Y.
1551-
IF Y >= 1.22474487139158890 AND
1552-
Y <= 1.22474487139158899
1550+
IF Y >= 1.2247448713915890 AND
1551+
Y <= 1.2247448713915900
15531552
DISPLAY "OK"
15541553
END-DISPLAY
15551554
ELSE
@@ -1855,7 +1854,6 @@ AT_CHECK([java prog], [0],
18551854
AT_CLEANUP
18561855

18571856
AT_SETUP([FUNCTION VARIANCE])
1858-
AT_CHECK([${SKIP_TEST}])
18591857

18601858
AT_DATA([prog.cob], [
18611859
IDENTIFICATION DIVISION.

0 commit comments

Comments
 (0)