diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java index f3220adfb115c9ec71679b345c962a031ef4810b..b2727c0f33a122c872bb4b8537cd830af543067a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java @@ -32,6 +32,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RDispatch; +import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector; @@ -43,7 +44,7 @@ public abstract class AsComplex extends RBuiltinNode.Arg2 { static { Casts casts = new Casts(AsComplex.class); - casts.arg("x").returnIf(missingValue().or(nullValue()), emptyComplexVector()).asComplexVector(); + casts.arg("x").defaultWarningContext(RError.NO_CALLER).returnIf(missingValue().or(nullValue()), emptyComplexVector()).asComplexVector(); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/casts/PipelineToCastNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/casts/PipelineToCastNode.java index 9d2d812d29e2f8a38cf00a30edf12f9b8dc3d7cc..198ee3b003554aba713b10fb3da6db947fe56e3f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/casts/PipelineToCastNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/casts/PipelineToCastNode.java @@ -246,7 +246,7 @@ public final class PipelineToCastNode { return step.vectorCoercion ? CastLogicalNodeGen.create(step.preserveNames, step.preserveDimensions, step.preserveAttributes) : CastLogicalBaseNodeGen.create(step.preserveNames, step.preserveDimensions, step.preserveAttributes); case Complex: - return CastComplexNodeGen.create(step.preserveNames, step.preserveDimensions, step.preserveAttributes); + return CastComplexNodeGen.create(step.preserveNames, step.preserveDimensions, step.preserveAttributes, false, warningContext); case Raw: return CastRawNodeGen.create(step.preserveNames, step.preserveDimensions, step.preserveAttributes); case Any: diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java index f82df687f42e7a19fcb3844248e6ab7e9e7baba5..1e44f39a62e4a164664b6d800c9d9dea4d280452 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java @@ -22,19 +22,17 @@ */ package com.oracle.truffle.r.nodes.unary; -import java.util.function.IntFunction; - import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.r.runtime.DSLConfig; import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.ErrorContext; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RComplexVector; -import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RForeignBooleanWrapper; import com.oracle.truffle.r.runtime.data.RForeignDoubleWrapper; import com.oracle.truffle.r.runtime.data.RForeignIntWrapper; @@ -46,23 +44,16 @@ import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RPairList; import com.oracle.truffle.r.runtime.data.RRaw; import com.oracle.truffle.r.runtime.data.closures.RClosures; +import com.oracle.truffle.r.runtime.data.model.RAbstractAtomicVector; import com.oracle.truffle.r.runtime.data.model.RAbstractComplexVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractListVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractRawVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import com.oracle.truffle.r.runtime.data.nodes.VectorAccess; +import com.oracle.truffle.r.runtime.data.nodes.VectorAccess.SequentialIterator; import com.oracle.truffle.r.runtime.ops.na.NACheck; -import com.oracle.truffle.r.runtime.ops.na.NAProfile; public abstract class CastComplexNode extends CastBaseNode { - private final NACheck naCheck = NACheck.create(); - private final NAProfile naProfile = NAProfile.create(); - private final BranchProfile warningBranch = BranchProfile.create(); - public abstract Object executeComplex(int o); public abstract Object executeComplex(double o); @@ -79,6 +70,10 @@ public abstract class CastComplexNode extends CastBaseNode { super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } + protected CastComplexNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI, ErrorContext warningContext) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI, false, warningContext); + } + @Child private CastComplexNode recursiveCastComplex; private Object castComplexRecursive(Object o) { @@ -105,19 +100,22 @@ public abstract class CastComplexNode extends CastBaseNode { } @Specialization - protected RComplex doInt(int operand) { + protected RComplex doInt(int operand, + @Cached("create()") NACheck naCheck) { naCheck.enable(operand); return naCheck.convertIntToComplex(operand); } @Specialization - protected RComplex doDouble(double operand) { + protected RComplex doDouble(double operand, + @Cached("create()") NACheck naCheck) { naCheck.enable(operand); return naCheck.convertDoubleToComplex(operand); } @Specialization - protected RComplex doLogical(byte operand) { + protected RComplex doLogical(byte operand, + @Cached("create()") NACheck naCheck) { naCheck.enable(operand); return naCheck.convertLogicalToComplex(operand); } @@ -134,86 +132,45 @@ public abstract class CastComplexNode extends CastBaseNode { @Specialization protected RComplex doCharacter(String operand, - @Cached("createBinaryProfile()") ConditionProfile emptyStringProfile) { + @Cached("createBinaryProfile()") ConditionProfile emptyStringProfile, + @Cached("create()") NACheck naCheck) { naCheck.enable(operand); if (naCheck.check(operand) || emptyStringProfile.profile(operand.isEmpty())) { return RComplex.createNA(); } RComplex result = RRuntime.string2complexNoCheck(operand); if (RRuntime.isNA(result) && !operand.equals(RRuntime.STRING_NaN)) { - warning(RError.Message.NA_INTRODUCED_COERCION); + warning(warningContext(), RError.Message.NA_INTRODUCED_COERCION); } return result; } - private RComplexVector createResultVector(RAbstractVector operand, IntFunction<RComplex> elementFunction) { - naCheck.enable(operand); + private RComplexVector createResultVector(RAbstractVector operand, VectorAccess uAccess) { double[] ddata = new double[operand.getLength() << 1]; - boolean seenNA = false; - for (int i = 0; i < operand.getLength(); i++) { - RComplex complexValue = elementFunction.apply(i); - int index = i << 1; - ddata[index] = complexValue.getRealPart(); - ddata[index + 1] = complexValue.getImaginaryPart(); - seenNA = seenNA || naProfile.isNA(complexValue); + try (SequentialIterator sIter = uAccess.access(operand, warningContext())) { + while (uAccess.next(sIter)) { + RComplex complexValue = uAccess.getComplex(sIter); + int index = sIter.getIndex() << 1; + ddata[index] = complexValue.getRealPart(); + ddata[index + 1] = complexValue.getImaginaryPart(); + } } - RComplexVector ret = factory().createComplexVector(ddata, !seenNA, getPreservedDimensions(operand), getPreservedNames(operand), getPreservedDimNames(operand)); + RComplexVector ret = factory().createComplexVector(ddata, !uAccess.na.isEnabled(), getPreservedDimensions(operand), getPreservedNames(operand), getPreservedDimNames(operand)); if (preserveRegAttributes()) { ret.copyRegAttributesFrom(operand); } return ret; } - @Specialization(guards = "!isForeignWrapper(operand)") - protected RComplexVector doIntVector(RAbstractIntVector operand) { - return createResultVector(operand, index -> naCheck.convertIntToComplex(operand.getDataAt(index))); + @Specialization(guards = {"uAccess.supports(operand)", "isAbstractAtomicVector(operand)"}, limit = "getGenericVectorAccessSize()") + protected RComplexVector doAbstractVector(RAbstractAtomicVector operand, + @Cached("operand.access()") VectorAccess uAccess) { + return createResultVector(operand, uAccess); } - @Specialization(guards = "!isForeignWrapper(operand)") - protected RComplexVector doDoubleVector(RAbstractDoubleVector operand) { - return createResultVector(operand, index -> naCheck.convertDoubleToComplex(operand.getDataAt(index))); - } - - @Specialization(guards = "!isForeignWrapper(operand)") - protected RComplexVector doLogicalVector(RAbstractLogicalVector operand) { - return createResultVector(operand, index -> naCheck.convertLogicalToComplex(operand.getDataAt(index))); - } - - @Specialization(guards = "!isForeignWrapper(operand)") - protected RComplexVector doStringVector(RAbstractStringVector operand, - @Cached("createBinaryProfile()") ConditionProfile emptyStringProfile) { - naCheck.enable(operand); - double[] ddata = new double[operand.getLength() << 1]; - boolean seenNA = false; - boolean warning = false; - for (int i = 0; i < operand.getLength(); i++) { - String value = operand.getDataAt(i); - RComplex complexValue; - if (naCheck.check(value) || emptyStringProfile.profile(value.isEmpty())) { - complexValue = RComplex.createNA(); - seenNA = true; - } else { - complexValue = RRuntime.string2complexNoCheck(value); - if (naProfile.isNA(complexValue)) { - seenNA = true; - if (!value.isEmpty()) { - warningBranch.enter(); - warning = true; - } - } - } - int index = i << 1; - ddata[index] = complexValue.getRealPart(); - ddata[index + 1] = complexValue.getImaginaryPart(); - } - if (warning) { - warning(RError.Message.NA_INTRODUCED_COERCION); - } - RComplexVector ret = factory().createComplexVector(ddata, !seenNA, getPreservedDimensions(operand), getPreservedNames(operand), getPreservedDimNames(operand)); - if (preserveRegAttributes()) { - ret.copyRegAttributesFrom(operand); - } - return ret; + @Specialization(replaces = "doAbstractVector", guards = "isAbstractAtomicVector(operand)") + protected RComplexVector doAbstractVectorGeneric(RAbstractAtomicVector operand) { + return doAbstractVector(operand, operand.slowPathAccess()); } @Specialization @@ -221,45 +178,44 @@ public abstract class CastComplexNode extends CastBaseNode { return vector; } - @Specialization - protected RComplexVector doRawVector(RAbstractRawVector operand) { - return createResultVector(operand, index -> RDataFactory.createComplex(operand.getRawDataAt(index), 0)); - } - - @Specialization - protected RComplexVector doList(RAbstractListVector list) { + @Specialization(guards = "uAccess.supports(list)", limit = "getVectorAccessCacheSize()") + protected RComplexVector doList(RAbstractListVector list, + @Cached("list.access()") VectorAccess uAccess) { int length = list.getLength(); double[] result = new double[length * 2]; boolean seenNA = false; - for (int i = 0, j = 0; i < length; i++, j += 2) { - Object entry = list.getDataAt(i); - if (entry instanceof RList) { - result[j] = RRuntime.DOUBLE_NA; - result[j + 1] = RRuntime.DOUBLE_NA; - seenNA = true; - } else { - Object castEntry = castComplexRecursive(entry); - if (castEntry instanceof RComplex) { - RComplex value = (RComplex) castEntry; - result[j] = value.getRealPart(); - result[j + 1] = value.getImaginaryPart(); - seenNA = seenNA || RRuntime.isNA(value); - } else if (castEntry instanceof RComplexVector) { - RComplexVector complexVector = (RComplexVector) castEntry; - if (complexVector.getLength() == 1) { - RComplex value = complexVector.getDataAt(0); - result[j] = value.getRealPart(); - result[j + 1] = value.getImaginaryPart(); + try (SequentialIterator sIter = uAccess.access(list, warningContext())) { + while (uAccess.next(sIter)) { + int i = sIter.getIndex() << 1; + Object entry = uAccess.getListElement(sIter); + if (entry instanceof RList) { + result[i] = RRuntime.DOUBLE_NA; + result[i + 1] = RRuntime.DOUBLE_NA; + seenNA = true; + } else { + Object castEntry = castComplexRecursive(entry); + if (castEntry instanceof RComplex) { + RComplex value = (RComplex) castEntry; + result[i] = value.getRealPart(); + result[i + 1] = value.getImaginaryPart(); seenNA = seenNA || RRuntime.isNA(value); - } else if (complexVector.getLength() == 0) { - result[j] = RRuntime.DOUBLE_NA; - result[j + 1] = RRuntime.DOUBLE_NA; - seenNA = true; + } else if (castEntry instanceof RComplexVector) { + RComplexVector complexVector = (RComplexVector) castEntry; + if (complexVector.getLength() == 1) { + RComplex value = complexVector.getDataAt(0); + result[i] = value.getRealPart(); + result[i + 1] = value.getImaginaryPart(); + seenNA = seenNA || RRuntime.isNA(value); + } else if (complexVector.getLength() == 0) { + result[i] = RRuntime.DOUBLE_NA; + result[i + 1] = RRuntime.DOUBLE_NA; + seenNA = true; + } else { + throw throwCannotCoerceListError("complex"); + } } else { throw throwCannotCoerceListError("complex"); } - } else { - throw throwCannotCoerceListError("complex"); } } } @@ -270,13 +226,18 @@ public abstract class CastComplexNode extends CastBaseNode { return ret; } + @Specialization(replaces = "doList") + protected RComplexVector doListGeneric(RAbstractListVector list) { + return doList(list, list.slowPathAccess()); + } + @Specialization(guards = "!pairList.isLanguage()") protected RComplexVector doPairList(RPairList pairList) { - return doList(pairList.toRList()); + return (RComplexVector) castComplexRecursive(pairList.toRList()); } - protected boolean isForeignWrapper(Object value) { - return value instanceof RForeignWrapper; + protected boolean isAbstractAtomicVector(RAbstractAtomicVector value) { + return !(value instanceof RForeignWrapper) && !(value instanceof RAbstractComplexVector); } @Specialization @@ -310,4 +271,12 @@ public abstract class CastComplexNode extends CastBaseNode { public static CastComplexNode createNonPreserving() { return CastComplexNodeGen.create(false, false, false); } + + protected int getVectorAccessCacheSize() { + return DSLConfig.getVectorAccessCacheSize(); + } + + protected int getGenericVectorAccessSize() { + return DSLConfig.getVectorAccessCacheSize() * 6; + } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java index c5cd5eecdefa9172c3f01d56d3617156dad13012..cae6a747e75e43c1adce82cb6f564649854b95bf 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java @@ -542,7 +542,19 @@ public abstract class FastPathVectorAccess extends VectorAccess { @Override protected final RComplex getComplexImpl(AccessIterator accessIter, int index) { - return na.convertStringToComplex(getStringImpl(accessIter, index)); + String value = getStringImpl(accessIter, index); + RComplex complexValue; + if (na.check(value) || emptyStringProfile.profile(value.isEmpty())) { + complexValue = RComplex.createNA(); + } else { + complexValue = RRuntime.string2complexNoCheck(value); + if (complexValue.isNA()) { + warningReportedProfile.enter(); + na.enable(true); + accessIter.warning(Message.NA_INTRODUCED_COERCION); + } + } + return complexValue; } @Override diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java index 80747e85b36766d62e689f0c1e866b084253a36c..0c6c1a9611df82c707fd3a115c0f83b1136cf0d6 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java @@ -521,7 +521,18 @@ public abstract class SlowPathVectorAccess extends VectorAccess { @Override protected final RComplex getComplexImpl(AccessIterator accessIter, int index) { - return na.convertStringToComplex(getStringImpl(accessIter, index)); + String value = getStringImpl(accessIter, index); + RComplex complexValue; + if (na.check(value) || value.isEmpty()) { + complexValue = RComplex.createNA(); + } else { + complexValue = RRuntime.string2complexNoCheck(value); + if (complexValue.isNA()) { + na.enable(true); + accessIter.warning(Message.NA_INTRODUCED_COERCION); + } + } + return complexValue; } @Override diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index aae4df0bc853a78142532fac5fc1d4ab83621178..84853d8c5effef726e1d85bc70526307c8bd5af1 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -6478,10 +6478,6 @@ character(0) #{ as.complex("0x42") } [1] 66+0i -##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# -#{ as.complex("1+5i") } -[1] 1+5i - ##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex#Ignored.ImplementationError# #{ as.complex("1e-2+3i") } [1] 0.01+3i @@ -6498,8 +6494,12 @@ character(0) #{ as.complex("NaN") } [1] NaN+0i -##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex#Output.IgnoreWarningContext# -#{ as.complex("TRUE") } +##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# +#{ as.complex('1+5i') } +[1] 1+5i + +##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# +#{ as.complex('TRUE') } [1] NA Warning message: NAs introduced by coercion @@ -6524,16 +6524,28 @@ complex(0) #{ as.complex(TRUE) } [1] 1+0i -##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex#Output.IgnoreWarningContext# -#{ as.complex(c("1","hello")) } +##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# +#{ as.complex(c('1', NA_character_)) } +[1] 1+0i NA + +##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# +#{ as.complex(c('1','hello')) } [1] 1+0i NA Warning message: NAs introduced by coercion +##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# +#{ as.complex(c('1+5i', '1+5i')) } +[1] 1+5i 1+5i + ##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# #{ as.complex(c(0/0, 0/0)) } [1] NaN+0i NaN+0i +##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex# +#{ as.complex(c(1, NA)) } +[1] 1+0i NA + ##com.oracle.truffle.r.test.builtins.TestBuiltin_ascomplex.testAsComplex#Output.IgnoreWarningContext# #{ as.complex(list("foo")) } [1] NA @@ -144851,13 +144863,13 @@ character(0) #if (!any(R.version$engine == "FastR")) { as.character(c(TRUE,FALSE,TRUE)) } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.character(to$listBoolean); } [1] "TRUE" "FALSE" "TRUE" -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX# #if (!any(R.version$engine == "FastR")) { as.complex("a string") } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.complex(to$fieldStaticStringObject) } [1] NA Warning message: NAs introduced by coercion -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX#Output.IgnoreWarningMessage# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testAsXXX# #if (!any(R.version$engine == "FastR")) { as.complex("a") } else { to <- .fastr.interop.new(java.type('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'));as.complex(to$fieldStaticCharObject) } [1] NA Warning message: diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascomplex.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascomplex.java index 7d1c29ceda48c97da0ae1457c546ddcb997bc068..17871c3a901121188d634a07c72ede6fec287ddf 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascomplex.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascomplex.java @@ -88,13 +88,16 @@ public class TestBuiltin_ascomplex extends TestBase { assertEval("{ as.complex() }"); assertEval("{ as.complex(0) }"); assertEval("{ as.complex(TRUE) }"); - assertEval("{ as.complex(\"1+5i\") }"); + assertEval("{ as.complex('1+5i') }"); + assertEval("{ as.complex(c('1+5i', '1+5i')) }"); + assertEval("{ as.complex(c(1, NA)) }"); + assertEval("{ as.complex(c('1', NA_character_)) }"); assertEval("{ as.complex(\"-1+5i\") }"); assertEval("{ as.complex(\"-1-5i\") }"); assertEval("{ as.complex(0/0) }"); assertEval("{ as.complex(c(0/0, 0/0)) }"); - assertEval(Output.IgnoreWarningContext, "{ as.complex(c(\"1\",\"hello\")) }"); - assertEval(Output.IgnoreWarningContext, "{ as.complex(\"TRUE\") }"); + assertEval("{ as.complex(c('1','hello')) }"); + assertEval("{ as.complex('TRUE') }"); assertEval("{ x<-c(a=1.1, b=2.2); dim(x)<-c(1,2); attr(x, \"foo\")<-\"foo\"; y<-as.complex(x); attributes(y) }"); assertEval("{ x<-c(a=1L, b=2L); dim(x)<-c(1,2); attr(x, \"foo\")<-\"foo\"; y<-as.complex(x); attributes(y) }"); assertEval("{ as.complex(\"Inf\") }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java index a793cba5711d33ccf59e88df4e6357ce6246d743..0b61650e7f505ebb35d33f562157e55a96858bbf 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java @@ -978,7 +978,7 @@ public class TestJavaInterop extends TestBase { if (name.startsWith("fieldStatic") && name.endsWith("Object")) { if (asXXX.equals("as.character") && name.contains("Long")) { assertEvalFastR(Ignored.ImplementationError, expr, getAsXXX(f.get(t), asXXX)); - } else if ((asXXX.equals("as.complex") || asXXX.equals("as.double") || asXXX.equals("as.raw")) && (name.contains("String") || name.contains("Char"))) { + } else if ((asXXX.equals("as.double") || asXXX.equals("as.raw")) && (name.contains("String") || name.contains("Char"))) { assertEvalFastR(Output.IgnoreWarningMessage, expr, getAsXXX(f.get(t), asXXX)); } else if (asXXX.equals("as.expression") && (name.contains("Long") || name.contains("Double"))) { assertEvalFastR(Ignored.ImplementationError, expr, getAsXXX(f.get(t), asXXX));