Skip to content

Commit 0888b31

Browse files
committed
fixed interop tests - there are no more precision loss warnings due to changed fitsInDouble logic in truffle
1 parent db5b56d commit 0888b31

File tree

2 files changed

+25
-62
lines changed

2 files changed

+25
-62
lines changed

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -157969,17 +157969,8 @@ Error in as.vector(talc) :
157969157969
no method for coercing this polyglot value to a vector
157970157970

157971157971
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsVectorFromArray#
157972-
#if (!any(R.version$engine == "FastR")) { cat('[1] -9.223372e+18 2.000000e+00 9.223372e+18<<<NEWLINE>>>Warning messages:<<<NEWLINE>>>1: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :<<<NEWLINE>>> Possible precission loss by coercion of long -9223372036854775808 to double -9223372036854776000.000000<<<NEWLINE>>>2: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :<<<NEWLINE>>> Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000<<<NEWLINE>>>3: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :<<<NEWLINE>>> Possible precission loss by coercion of long -9223372036854775808 to double -9223372036854776000.000000<<<NEWLINE>>>4: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :<<<NEWLINE>>> Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000<<<NEWLINE>>>') } else { ta <- new('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestArraysClass'); as.vector(ta$longArrayMinMax) }
157972+
#if (!any(R.version$engine == "FastR")) { cat('[1] -9.223372e+18 2.000000e+00 9.223372e+18<<<NEWLINE>>>') } else { ta <- new('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestArraysClass'); as.vector(ta$longArrayMinMax) }
157973157973
[1] -9.223372e+18 2.000000e+00 9.223372e+18
157974-
Warning messages:
157975-
1: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :
157976-
Possible precission loss by coercion of long -9223372036854775808 to double -9223372036854776000.000000
157977-
2: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :
157978-
Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000
157979-
3: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :
157980-
Possible precission loss by coercion of long -9223372036854775808 to double -9223372036854776000.000000
157981-
4: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :
157982-
Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000
157983157974

157984157975
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsVectorFromArray#
157985157976
#if (!any(R.version$engine == "FastR")) { character() } else { as.vector(new(java.type('java.lang.Integer[]'), 0L), 'character'); }
@@ -158273,7 +158264,7 @@ NAs introduced by coercion
158273158264
#if (!any(R.version$engine == "FastR")) { as.complex(32767) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.complex(to$fieldStaticShortObject) }
158274158265
[1] 32767+0i
158275158266

158276-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage#
158267+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#
158277158268
#if (!any(R.version$engine == "FastR")) { as.complex(9223372036854775807) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.complex(to$fieldStaticLongObject) }
158278158269
[1] 9.223372e+18+0i
158279158270

@@ -158371,7 +158362,7 @@ NAs introduced by coercion
158371158362
#if (!any(R.version$engine == "FastR")) { as.double(32767) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.double(to$fieldStaticShortObject) }
158372158363
[1] 32767
158373158364

158374-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage#
158365+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#
158375158366
#if (!any(R.version$engine == "FastR")) { as.double(9223372036854775807) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.double(to$fieldStaticLongObject) }
158376158367
[1] 9.223372e+18
158377158368

@@ -158559,7 +158550,7 @@ NAs introduced by coercion to integer range
158559158550
#if (!any(R.version$engine == "FastR")) { as.integer(32767) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.integer(to$fieldStaticShortObject) }
158560158551
[1] 32767
158561158552

158562-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage#
158553+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#
158563158554
#if (!any(R.version$engine == "FastR")) { as.integer(9223372036854775807) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.integer(to$fieldStaticLongObject) }
158564158555
[1] NA
158565158556
Warning message:
@@ -158655,7 +158646,7 @@ NAs introduced by coercion
158655158646
#if (!any(R.version$engine == "FastR")) { as.logical(32767) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.logical(to$fieldStaticShortObject) }
158656158647
[1] TRUE
158657158648

158658-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage#
158649+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#
158659158650
#if (!any(R.version$engine == "FastR")) { as.logical(9223372036854775807) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.logical(to$fieldStaticLongObject) }
158660158651
[1] TRUE
158661158652

@@ -158947,7 +158938,7 @@ a
158947158938
#if (!any(R.version$engine == "FastR")) { as.vector(32767) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.vector(to$fieldStaticShortObject) }
158948158939
[1] 32767
158949158940

158950-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage#
158941+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#
158951158942
#if (!any(R.version$engine == "FastR")) { as.vector(9223372036854775807) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.vector(to$fieldStaticLongObject) }
158952158943
[1] 9.223372e+18
158953158944

@@ -159963,6 +159954,14 @@ Error: unexpected ')' in "if (!any(R.version$engine == "FastR")) { v <- c(1, 1,
159963159954
#if (!any(R.version$engine == "FastR")) { 32767 } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldShortObject }
159964159955
[1] 32767
159965159956

159957+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields#
159958+
#if (!any(R.version$engine == "FastR")) { 9223372036854775807 } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldLong }
159959+
[1] 9.223372e+18
159960+
159961+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields#
159962+
#if (!any(R.version$engine == "FastR")) { 9223372036854775807 } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldLongObject }
159963+
[1] 9.223372e+18
159964+
159966159965
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields#
159967159966
#if (!any(R.version$engine == "FastR")) { NULL } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldNullObject }
159968159967
NULL
@@ -159983,18 +159982,6 @@ NULL
159983159982
#if (!any(R.version$engine == "FastR")) { TRUE } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldBooleanObject }
159984159983
[1] TRUE
159985159984

159986-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields#
159987-
#if (!any(R.version$engine == "FastR")) { cat('[1] 9.223372e+18<<<NEWLINE>>>Warning message:<<<NEWLINE>>>Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000<<<NEWLINE>>>') } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldLong }
159988-
[1] 9.223372e+18
159989-
Warning message:
159990-
Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000
159991-
159992-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields#
159993-
#if (!any(R.version$engine == "FastR")) { cat('[1] 9.223372e+18<<<NEWLINE>>>Warning message:<<<NEWLINE>>>Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000<<<NEWLINE>>>') } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$fieldLongObject }
159994-
[1] 9.223372e+18
159995-
Warning message:
159996-
Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000
159997-
159998159985
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields#
159999159986
#if (!any(R.version$engine == "FastR")) { cat('[polyglot value]<<<NEWLINE>>>[[1]]<<<NEWLINE>>>[1] 1<<<NEWLINE>>><<<NEWLINE>>>[[2]]<<<NEWLINE>>>[1] 2.1<<<NEWLINE>>><<<NEWLINE>>>[[3]]<<<NEWLINE>>>[1] "a"<<<NEWLINE>>><<<NEWLINE>>>[[4]]<<<NEWLINE>>>[1] TRUE<<<NEWLINE>>><<<NEWLINE>>>[[5]]<<<NEWLINE>>>NULL<<<NEWLINE>>><<<NEWLINE>>>', sep='') } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$mixedTypesArray }
160000159987
[polyglot value]
@@ -161750,6 +161737,14 @@ com.oracle.truffle.r.runtime.data.RIntArrayVectorData
161750161737
#if (!any(R.version$engine == "FastR")) { 32767 } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodShortObject() }
161751161738
[1] 32767
161752161739

161740+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods#
161741+
#if (!any(R.version$engine == "FastR")) { 9223372036854775807 } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodLong() }
161742+
[1] 9.223372e+18
161743+
161744+
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods#
161745+
#if (!any(R.version$engine == "FastR")) { 9223372036854775807 } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodLongObject() }
161746+
[1] 9.223372e+18
161747+
161753161748
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods#
161754161749
#if (!any(R.version$engine == "FastR")) { NULL } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodReturnsNull() }
161755161750
NULL
@@ -161766,18 +161761,6 @@ NULL
161766161761
#if (!any(R.version$engine == "FastR")) { TRUE } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodBooleanObject() }
161767161762
[1] TRUE
161768161763

161769-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods#
161770-
#if (!any(R.version$engine == "FastR")) { cat('[1] 9.223372e+18<<<NEWLINE>>>Warning message:<<<NEWLINE>>>Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000<<<NEWLINE>>>') } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodLong() }
161771-
[1] 9.223372e+18
161772-
Warning message:
161773-
Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000
161774-
161775-
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods#
161776-
#if (!any(R.version$engine == "FastR")) { cat('[1] 9.223372e+18<<<NEWLINE>>>Warning message:<<<NEWLINE>>>Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000<<<NEWLINE>>>') } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodLongObject() }
161777-
[1] 9.223372e+18
161778-
Warning message:
161779-
Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000
161780-
161781161764
##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods#
161782161765
#if (!any(R.version$engine == "FastR")) { cat('[polyglot value]\n[1] "a" "b" "c"\n') } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); to$methodStringArray() }
161783161766
[polyglot value]

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.oracle.truffle.r.nodes.builtin.fastr.FastRInterop;
4444
import com.oracle.truffle.r.runtime.RRuntime;
4545
import com.oracle.truffle.r.runtime.RType;
46-
import com.oracle.truffle.r.runtime.data.VectorDataLibrary;
4746
import com.oracle.truffle.r.test.TestBase;
4847
import com.oracle.truffle.r.test.generate.FastRSession;
4948
import static com.oracle.truffle.r.test.library.fastr.Utils.errorIn;
@@ -368,12 +367,7 @@ public void testMethods() throws IllegalAccessException, IllegalArgumentExceptio
368367
}
369368

370369
private void testForValue(String member, Object value) {
371-
if ((member.startsWith("fieldLong") || member.startsWith("methodLong")) && !member.contains("Array")) {
372-
assertEvalFastR(CREATE_TRUFFLE_OBJECT + " to$" + member,
373-
"cat('[1] 9.223372e+18\nWarning message:\nPossible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000\n')");
374-
} else {
375-
assertEvalFastR(CREATE_TRUFFLE_OBJECT + " to$" + member, getRValue(value));
376-
}
370+
assertEvalFastR(CREATE_TRUFFLE_OBJECT + " to$" + member, getRValue(value));
377371
}
378372

379373
@Test
@@ -744,21 +738,7 @@ public void testAsVectorFromArray() throws NoSuchFieldException, IllegalArgument
744738

745739
testConvertObjectArray("as.vector");
746740

747-
String cmd = CREATE_TEST_ARRAYS + " as.vector(ta$longArrayMinMax)";
748-
String expected = "cat('[1] -9.223372e+18 2.000000e+00 9.223372e+18\nWarning messages:\n" +
749-
"1: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :\n" +
750-
" Possible precission loss by coercion of long -9223372036854775808 to double -9223372036854776000.000000\n" +
751-
"2: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :\n" +
752-
" Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000\n" +
753-
"3: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :\n" +
754-
" Possible precission loss by coercion of long -9223372036854775808 to double -9223372036854776000.000000\n" +
755-
"4: In print.default(c(-9223372036854776832, 2, 9223372036854776832)) :\n" +
756-
" Possible precission loss by coercion of long 9223372036854775807 to double 9223372036854776000.000000\n')";
757-
if (VectorDataLibrary.ENABLE_VERY_SLOW_ASSERTS) {
758-
assertEvalFastR(Output.IgnoreWarningMessage, cmd, expected);
759-
} else {
760-
assertEvalFastR(cmd, expected);
761-
}
741+
assertEvalFastR(CREATE_TEST_ARRAYS + " as.vector(ta$longArrayMinMax)", "cat('[1] -9.223372e+18 2.000000e+00 9.223372e+18\n')");
762742

763743
assertEvalFastR(Ignored.ImplementationError, "as.vector(new(java.type('java.lang.Integer[]'), 1))", "integer()");
764744

@@ -1192,7 +1172,7 @@ public void testAsXXX(String asXXX, String type) throws IllegalArgumentException
11921172
} else if (asXXX.equals("as.symbol") && (name.contains("Null"))) {
11931173
assertEvalFastR(Output.IgnoreErrorContext, expr, getAsXXX(f.get(t), asXXX));
11941174
} else if (name.contains("Long")) {
1195-
assertEvalFastR(Output.IgnoreWarningMessage, expr, getAsXXX(f.get(t), asXXX));
1175+
assertEvalFastR(expr, getAsXXX(f.get(t), asXXX));
11961176
} else {
11971177
assertEvalFastR(expr, getAsXXX(f.get(t), asXXX));
11981178
}

0 commit comments

Comments
 (0)