diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java index d95c2c135e18b5fdd5493ae92c952a3600f9def4..b01b00dea10445156396ab78d186a30532d1fe24 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java @@ -76,6 +76,7 @@ import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RPromise; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RSymbol; +import com.oracle.truffle.r.runtime.data.RTypes; import com.oracle.truffle.r.runtime.data.RVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; import com.oracle.truffle.r.runtime.nodes.RBaseNode; @@ -103,6 +104,7 @@ public abstract class Bind extends RBaseNode { @Child private CastToVectorNode castVector; @Child private CastLogicalNode castLogical; @Child private GetDimAttributeNode getDimsNode; + @Child private SetDimNamesAttributeNode setDimNamesNode; private final BindType type; @@ -149,25 +151,19 @@ public abstract class Bind extends RBaseNode { } private Object bindInternal(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, CastNode castNode, boolean needsVectorCast, SetDimAttributeNode setDimNode, - SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { + GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { ArgumentsSignature signature = promiseArgs.getSignature(); String[] vecNames = nullNamesProfile.profile(signature.getNonNullCount() == 0) ? null : new String[signature.getLength()]; RAbstractVector[] vectors = new RAbstractVector[args.length]; boolean complete = true; int ind = 0; naCheck.enable(true); + RAbstractVector fromNotNullArgVector = null; for (int i = 0; i < args.length; i++) { - if (vecNames != null) { - nonNullNames.enter(); - vecNames[ind] = signature.getName(i); - naCheck.check(vecNames[ind]); - } - Object result = castNode.execute(args[i]); - RAbstractVector vector; - if (needsVectorCast) { - vector = castVector(result); - } else { - vector = (RAbstractVector) result; + setVectorNames(vecNames, ind, signature.getName(i)); + RAbstractVector vector = getVector(args[i], castNode, needsVectorCast); + if (fromNotNullArgVector == null && !RTypes.isRNull(args[i])) { + fromNotNullArgVector = vector; } if (emptyVectorProfile.profile(vector.getLength() == 0)) { // nothing to do @@ -177,25 +173,14 @@ public abstract class Bind extends RBaseNode { ind++; } } + boolean allEmpty = ind == 0; if (emptyVectorProfile.profile(ind < args.length)) { - if (allEmptyVectorProfile.profile(ind == 0)) { + if (allEmptyVectorProfile.profile(allEmpty)) { for (int i = 0; i < args.length; i++) { - if (vecNames != null) { - nonNullNames.enter(); - vecNames[i] = signature.getName(i); - naCheck.check(vecNames[i]); - } - Object result = castNode.execute(args[i]); - RAbstractVector vector; - if (needsVectorCast) { - vector = castVector(result); - } else { - vector = (RAbstractVector) result; - } - vectors[i] = vector; - complete &= vector.isComplete(); + setVectorNames(vecNames, i, signature.getName(i)); + vectors[i] = getVector(args[i], castNode, needsVectorCast); + complete &= vectors[i].isComplete(); } - ind = args.length; } else { if (vecNames != null) { nonNullNames.enter(); @@ -204,10 +189,42 @@ public abstract class Bind extends RBaseNode { vectors = Arrays.copyOf(vectors, ind); } } + + int[] bindDims = new int[vectors.length]; + int[] resultDimensions = new int[2]; + boolean rowsAndColumnsNotEqual = getResultDimensions(vectors, resultDimensions, bindDims); + RVector<?> resultVec; + if (fromNotNullArgVector != null) { + resultVec = resultProfile.profile(fromNotNullArgVector.createEmptySameType(resultDimensions[0] * resultDimensions[1], complete)); + } else { + resultVec = resultProfile.profile(vectors[0].createEmptySameType(resultDimensions[0] * resultDimensions[1], complete)); + } + if (type == BindType.cbind) { - return genericCBind(promiseArgs, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return genericCBind(promiseArgs, vectors, resultVec, resultDimensions, bindDims, rowsAndColumnsNotEqual, allEmpty, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, + getDimNamesNode, getNamesNode); + } else { + return genericRBind(promiseArgs, vectors, resultVec, resultDimensions, bindDims, rowsAndColumnsNotEqual, allEmpty, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, + getDimNamesNode, getNamesNode); + } + } + + private RAbstractVector getVector(Object arg, CastNode castNode, boolean needsVectorCast) { + Object result = castNode.execute(arg); + RAbstractVector vector; + if (needsVectorCast) { + vector = castVector(result); } else { - return genericRBind(promiseArgs, vectors, complete, vecNames, naCheck.neverSeenNA(), deparseLevel, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + vector = (RAbstractVector) result; + } + return vector; + } + + private void setVectorNames(String[] vecNames, int vectorInd, String signatureName) { + if (vecNames != null) { + nonNullNames.enter(); + vecNames[vectorInd] = signatureName; + naCheck.check(vecNames[vectorInd]); } } @@ -215,60 +232,54 @@ public abstract class Bind extends RBaseNode { protected Object allLogical(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, // @Cached("create()") CastLogicalNode cast, @Cached("create()") SetDimAttributeNode setDimNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == INT_PRECEDENCE", "args.length > 1"}) protected Object allInt(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, // @Cached("create()") CastIntegerNode cast, @Cached("create()") SetDimAttributeNode setDimNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == DOUBLE_PRECEDENCE", "args.length > 1"}) protected Object allDouble(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, // @Cached("create()") CastDoubleNode cast, @Cached("create()") SetDimAttributeNode setDimNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == STRING_PRECEDENCE", "args.length> 1"}) protected Object allString(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, // @Cached("create()") CastStringNode cast, @Cached("create()") SetDimAttributeNode setDimNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == COMPLEX_PRECEDENCE", "args.length > 1"}) protected Object allComplex(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, // @Cached("create()") CastComplexNode cast, @Cached("create()") SetDimAttributeNode setDimNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return bindInternal(deparseLevel, args, promiseArgs, cast, true, setDimNode, getDimNamesNode, getNamesNode); } @Specialization(guards = {"precedence == LIST_PRECEDENCE", "args.length > 1"}) protected Object allList(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, // @Cached("create()") CastListNode cast, @Cached("create()") SetDimAttributeNode setDimNode, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetDimNamesAttributeNode getDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { - return bindInternal(deparseLevel, args, promiseArgs, cast, false, setDimNode, setDimNamesNode, getDimNamesNode, getNamesNode); + return bindInternal(deparseLevel, args, promiseArgs, cast, false, setDimNode, getDimNamesNode, getNamesNode); } /** @@ -418,10 +429,10 @@ public abstract class Bind extends RBaseNode { private final BranchProfile everSeenNotEqualRows = BranchProfile.create(); private final BranchProfile everSeenNotEqualColumns = BranchProfile.create(); + private final ConditionProfile needsDimNames = ConditionProfile.createBinaryProfile(); @Specialization(guards = {"precedence != NO_PRECEDENCE", "args.length == 1"}) protected Object allOneElem(int deparseLevel, Object[] args, RArgsValuesAndNames promiseArgs, @SuppressWarnings("unused") int precedence, - @Cached("create()") SetDimNamesAttributeNode setDimNamesNode, @Cached("create()") GetNamesAttributeNode getNamesNode) { RAbstractVector vec = vectorProfile.profile(castVector(args[0])); int[] rawDimensions = getVectorDimensions(vec); @@ -455,18 +466,15 @@ public abstract class Bind extends RBaseNode { int[] dims = getDimensions(vec, rawDimensions); RVector<?> res = (RVector<?>) vec.copyWithNewDimensions(dims); - setDimNamesNode.execute(res, RDataFactory.createList(type == BindType.cbind ? new Object[]{dimNamesA, dimNamesB} : new Object[]{dimNamesB, dimNamesA})); + if (needsDimNames.profile(vec.getLength() == 0 || dimNamesA != RNull.instance || dimNamesB != RNull.instance)) { + setDimNames(res, RDataFactory.createList(type == BindType.cbind ? new Object[]{dimNamesA, dimNamesB} : new Object[]{dimNamesB, dimNamesA})); + } return res; } - public RVector<?> genericCBind(RArgsValuesAndNames promiseArgs, RAbstractVector[] vectors, boolean complete, String[] vecNames, boolean vecNamesComplete, int deparseLevel, - SetDimAttributeNode setDimNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { - - int[] resultDimensions = new int[2]; - int[] secondDims = new int[vectors.length]; - boolean notEqualRows = getResultDimensions(vectors, resultDimensions, secondDims); - RAbstractVector first = vectorProfile.profile(vectors[0]); - RVector<?> result = resultProfile.profile(first.createEmptySameType(resultDimensions[0] * resultDimensions[1], complete)); + public RVector<?> genericCBind(RArgsValuesAndNames promiseArgs, RAbstractVector[] vectors, RVector<?> result, int[] resultDimensions, int[] secondDims, boolean rowsAndColumnsNotEqual, + boolean allEmpty, String[] vecNames, boolean vecNamesComplete, int deparseLevel, + SetDimAttributeNode setDimNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { int ind = 0; Object rowDimResultNames = RNull.instance; @@ -494,7 +502,7 @@ public abstract class Bind extends RBaseNode { for (int j = 0; j < vecLength; j++) { result.transferElementSameType(ind++, vec, j); } - if (notEqualRows) { + if (rowsAndColumnsNotEqual) { everSeenNotEqualRows.enter(); if (vecLength < resultDimensions[0]) { // re-use vector elements @@ -511,7 +519,9 @@ public abstract class Bind extends RBaseNode { } Object colDimResultNames = allColDimNamesNull ? RNull.instance : RDataFactory.createStringVector(colDimNamesArray, vecNamesComplete); setDimNode.setDimensions(result, resultDimensions); - setDimNamesNode.setDimNames(result, RDataFactory.createList(new Object[]{rowDimResultNames, colDimResultNames})); + if (needsDimNames.profile(allEmpty || rowDimResultNames != RNull.instance || colDimResultNames != RNull.instance)) { + setDimNames(result, RDataFactory.createList(new Object[]{rowDimResultNames, colDimResultNames})); + } return result; } @@ -606,13 +616,9 @@ public abstract class Bind extends RBaseNode { } } - public RVector<?> genericRBind(RArgsValuesAndNames promiseArgs, RAbstractVector[] vectors, boolean complete, String[] vecNames, boolean vecNamesComplete, int deparseLevel, - SetDimAttributeNode setDimNode, SetDimNamesAttributeNode setDimNamesNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { - - int[] resultDimensions = new int[2]; - int[] firstDims = new int[vectors.length]; - boolean notEqualColumns = getResultDimensions(vectors, resultDimensions, firstDims); - RVector<?> result = resultProfile.profile(vectors[0].createEmptySameType(resultDimensions[0] * resultDimensions[1], complete)); + public RVector<?> genericRBind(RArgsValuesAndNames promiseArgs, RAbstractVector[] vectors, RVector<?> result, int[] resultDimensions, int[] firstDims, boolean rowsAndColumnsNotEqual, + boolean allEmpty, String[] vecNames, boolean vecNamesComplete, int deparseLevel, + SetDimAttributeNode setDimNode, GetDimNamesAttributeNode getDimNamesNode, GetNamesAttributeNode getNamesNode) { Object colDimResultNames = RNull.instance; String[] rowDimNamesArray = new String[resultDimensions[0]]; @@ -644,7 +650,7 @@ public abstract class Bind extends RBaseNode { result.transferElementSameType(j * resultDimensions[0] + k, vec, srcInd++); } } - if (notEqualColumns) { + if (rowsAndColumnsNotEqual) { everSeenNotEqualColumns.enter(); if (j < resultDimensions[1]) { // re-use vector elements @@ -663,7 +669,17 @@ public abstract class Bind extends RBaseNode { } Object rowDimResultNames = allRowDimNamesNull ? RNull.instance : RDataFactory.createStringVector(rowDimNamesArray, vecNamesComplete); setDimNode.setDimensions(result, resultDimensions); - setDimNamesNode.setDimNames(result, RDataFactory.createList(new Object[]{rowDimResultNames, colDimResultNames})); + if (needsDimNames.profile(allEmpty || rowDimResultNames != RNull.instance || colDimResultNames != RNull.instance)) { + setDimNames(result, RDataFactory.createList(new Object[]{rowDimResultNames, colDimResultNames})); + } return result; } + + private void setDimNames(RVector<?> result, RList dimNames) { + if (setDimNamesNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + setDimNamesNode = insert(SetDimNamesAttributeNode.create()); + } + setDimNamesNode.setDimNames(result, dimNames); + } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java index 426f5b569e5d7806695bf84bc7a7f996cb021f94..9c8ae0753becbf5e23ab8d663366ce364e93f35c 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java @@ -904,50 +904,49 @@ public class RDeparse { append("structure("); return () -> { DynamicObject attrs = ((RAttributable) obj).getAttributes(); - if (attrs != null) { - Iterator<RAttributesLayout.RAttribute> iter = RAttributesLayout.asIterable(attrs).iterator(); - while (iter.hasNext()) { - RAttributesLayout.RAttribute attr = iter.next(); - // TODO ignore function source attribute - String attrName = attr.getName(); - append(", "); - String dotName = null; - switch (attrName) { - case "dimnames": - dotName = ".Dimnames"; - break; - case "dim": - dotName = ".Dim"; - break; - case "names": - dotName = ".Names"; - break; - case "tsp": - dotName = ".Tsp"; - break; - case "levels": - dotName = ".Label"; - break; - - default: { - opts = SIMPLEDEPARSE; - if (attrName.contains(" ")) { - append('"'); - append(attrName); - append('"'); - } else { - append(attrName); - } + assert attrs != null; + Iterator<RAttributesLayout.RAttribute> iter = RAttributesLayout.asIterable(attrs).iterator(); + while (iter.hasNext()) { + RAttributesLayout.RAttribute attr = iter.next(); + // TODO ignore function source attribute + String attrName = attr.getName(); + append(", "); + String dotName = null; + switch (attrName) { + case "dimnames": + dotName = ".Dimnames"; + break; + case "dim": + dotName = ".Dim"; + break; + case "names": + dotName = ".Names"; + break; + case "tsp": + dotName = ".Tsp"; + break; + case "levels": + dotName = ".Label"; + break; + + default: { + opts = SIMPLEDEPARSE; + if (attrName.contains(" ")) { + append('"'); + append(attrName); + append('"'); + } else { + append(attrName); } } - if (dotName != null) { - append(dotName); - } - append(" = "); - appendValue(attr.getValue()); - append(')'); } + if (dotName != null) { + append(dotName); + } + append(" = "); + appendValue(attr.getValue()); } + append(')'); }; } else { return () -> { 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 004520f152ad296fd97931f372ae639913edd6cd..c96eb6ba63a6fc1ca4b41104a413aaeefca5b1e7 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 @@ -11944,13 +11944,197 @@ c 2 a c 1 7 42 +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(1L)) } +$dim +[1] 1 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(1L, 2L)) } +$dim +[1] 1 2 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(NULL, integer(0))) } +$dim +[1] 0 2 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(c(1), integer(0))) } +$dim +[1] 1 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(c(1L, 2L))) } +$dim +[1] 2 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(integer(0))) } +$dim +[1] 0 1 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(integer(0), integer(0))) } +$dim +[1] 0 2 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(list())) } +$dim +[1] 0 1 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(list(1L, 2L))) } +$dim +[1] 2 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(matrix())) } +$dim +[1] 1 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(matrix(1L, 2L))) } +$dim +[1] 2 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(structure(1:4, dim=c(2,2)), 1L)) } +$dim +[1] 2 3 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L)) } +$dim +[1] 2 3 + +$dimnames +$dimnames[[1]] +[1] "y1" "y2" + +$dimnames[[2]] +[1] "x1" "x2" "" + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L)) } +$dim +[1] 2 3 + +$dimnames +$dimnames[[1]] +[1] "y1" "y2" + +$dimnames[[2]] +[1] "x1" "x2" "" + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ attributes(cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0))) } +$dim +[1] 2 2 + +$dimnames +$dimnames[[1]] +[1] "y1" "y2" + +$dimnames[[2]] +[1] "x1" "x2" + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(NULL, integer(0)) } + [,1] [,2] + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(c(1), integer(0)) } + [,1] +[1,] 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(integer(0), integer(0)) } + [,1] [,2] + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(structure(1:4, dim=c(2,2)), 1L) } + [,1] [,2] [,3] +[1,] 1 3 1 +[2,] 2 4 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L) } + x1 x2 +y1 1 3 1 +y2 2 4 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L) } + x1 x2 +y1 1 3 1 +y2 2 4 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testDimnames# +#{ cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0)) } + x1 x2 +y1 1 3 +y2 2 4 + ##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testGenericDispatch# #{ v <- 1; cbind.foo <- function(...) 'foo'; cbind(v) } v [1,] 1 ##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testGenericDispatch# -#{ v <- 1; class(v) <- 'foo'; assign('cbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); cbind(v) ; rm('cbind.foo', envir=.__S3MethodsTable__.)} +#{ v <- 1; class(v) <- 'foo'; assign('cbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); result <- cbind(v) ; rm('cbind.foo', envir=.__S3MethodsTable__.); result;} +[1] "foo" ##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testGenericDispatch# #{ v <- 1; class(v) <- 'foo'; cbind(v) } @@ -12033,6 +12217,59 @@ Error in cbind(deparse.level, ...) : argument 'x' must be a raw vector #{ v1 <- 1; class(v1) <- 'foo1'; v2 <- 2; class(v2) <- 'foo2'; cbind.foo2 <- function(...) 'foo2'; cbind(v1, v2) } [1] "foo2" +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL)) +NULL + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, NULL, double(0))) +structure(numeric(0), .Dim = c(0L, 3L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, NULL, double(0), character(0))) +structure(character(0), .Dim = c(0L, 4L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, NULL, double(0), integer(0))) +structure(numeric(0), .Dim = c(0L, 4L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, NULL, double(0), integer(0), character(0))) +structure(character(0), .Dim = c(0L, 5L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, NULL, integer(0))) +structure(integer(0), .Dim = c(0L, 3L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, NULL, integer(0), double(0))) +structure(numeric(0), .Dim = c(0L, 4L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(NULL, integer(0))) +structure(integer(0), .Dim = c(0L, 2L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(c(NULL, NULL), integer(0))) +structure(integer(0), .Dim = c(0L, 2L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(integer(0))) +structure(integer(0), .Dim = 0:1, .Dimnames = list(NULL, NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testRetType# +#dput(cbind(integer(0), NULL, NULL)) +structure(integer(0), .Dim = c(0L, 3L), .Dimnames = list(NULL, + NULL)) + ##com.oracle.truffle.r.test.builtins.TestBuiltin_cbind.testcbind1# #argv <- list(748L, c(5.08759633523238, 4.0943445622221, 5.66642668811243, 3.43398720448515), c(1L, 1L, 1L, 1L), 1L, c(FALSE, TRUE, TRUE, TRUE), c(0, 1, 0, 1), c(0, 1, 1, 1), c(0, 1, 0, 1), c(FALSE, FALSE, TRUE, FALSE), c(FALSE, FALSE, FALSE, TRUE));do.call('cbind', argv) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] @@ -16529,6 +16766,18 @@ a[a <- TRUE] #{ x<-expression(1); deparse(x) } [1] "expression(1)" +##com.oracle.truffle.r.test.builtins.TestBuiltin_deparse.testDeparseStructure# +#{ deparse(structure(.Data=c(1,2))) } +[1] "c(1, 2)" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_deparse.testDeparseStructure# +#{ deparse(structure(.Data=c(1,2), attr1=c(1))) } +[1] "structure(c(1, 2), attr1 = 1)" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_deparse.testDeparseStructure# +#{ deparse(structure(.Data=c(1,2), attr1=c(1), attr2=c(2))) } +[1] "structure(c(1, 2), attr1 = 1, attr2 = 2)" + ##com.oracle.truffle.r.test.builtins.TestBuiltin_deparse.testdeparse1# #argv <- list(quote(rsp), 60L, FALSE, 69, -1L); .Internal(deparse(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])) [1] "rsp" @@ -42095,8 +42344,167 @@ Error in rawToBits(stdout()) : argument 'x' must be a raw vector #argv <- structure(list(x = as.raw(c(115, 116, 114, 105, 110, 103))), .Names = 'x');do.call('rawToChar', argv) [1] "string" +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(1L)) } +$dim +[1] 1 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(1L, 2L)) } +$dim +[1] 2 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(NULL, integer(0))) } +$dim +[1] 2 0 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(c(1), integer(0))) } +$dim +[1] 1 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(c(1L, 2L))) } +$dim +[1] 1 2 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(integer(0))) } +$dim +[1] 1 0 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(integer(0), integer(0))) } +$dim +[1] 2 0 + +$dimnames +$dimnames[[1]] +NULL + +$dimnames[[2]] +NULL + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(structure(1:4, dim=c(2,2)), 1L)) } +$dim +[1] 3 2 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L)) } +$dim +[1] 3 2 + +$dimnames +$dimnames[[1]] +[1] "y1" "y2" "" + +$dimnames[[2]] +[1] "x1" "x2" + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L)) } +$dim +[1] 3 2 + +$dimnames +$dimnames[[1]] +[1] "y1" "y2" "" + +$dimnames[[2]] +[1] "x1" "x2" + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ attributes(rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0))) } +$dim +[1] 2 2 + +$dimnames +$dimnames[[1]] +[1] "y1" "y2" + +$dimnames[[2]] +[1] "x1" "x2" + + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(NULL, integer(0)) } + +[1,] +[2,] + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(c(1), integer(0)) } + [,1] +[1,] 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(integer(0), integer(0)) } + +[1,] +[2,] + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(structure(1:4, dim=c(2,2)), 1L) } + [,1] [,2] +[1,] 1 3 +[2,] 2 4 +[3,] 1 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L) } + x1 x2 +y1 1 3 +y2 2 4 + 1 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L) } + x1 x2 +y1 1 3 +y2 2 4 + 1 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testDimnames# +#{ rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0)) } + x1 x2 +y1 1 3 +y2 2 4 + ##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testGenericDispatch# -#{ v <- 1; class(v) <- 'foo'; assign('rbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); rbind(v) ; rm('rbind.foo', envir=.__S3MethodsTable__.)} +#{ v <- 1; class(v) <- 'foo'; assign('rbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); result <- rbind(v) ; rm('rbind.foo', envir=.__S3MethodsTable__.); result;} +[1] "foo" ##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testGenericDispatch# #{ v <- 1; class(v) <- 'foo'; rbind(v) } @@ -42408,6 +42816,60 @@ B 2 4 a 7 c 42 +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL)) +NULL + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, NULL, double(0))) +structure(numeric(0), .Dim = c(3L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, NULL, double(0), character(0))) +structure(character(0), .Dim = c(4L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, NULL, double(0), integer(0))) +structure(numeric(0), .Dim = c(4L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, NULL, double(0), integer(0), character(0))) +structure(character(0), .Dim = c(5L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, NULL, integer(0))) +structure(integer(0), .Dim = c(3L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, NULL, integer(0), double(0))) +structure(numeric(0), .Dim = c(4L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(NULL, integer(0))) +structure(integer(0), .Dim = c(2L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(c(NULL, NULL), integer(0))) +structure(integer(0), .Dim = c(2L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(integer(0))) +structure(integer(0), .Dim = c(1L, 0L), .Dimnames = list(NULL, + NULL)) + +##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testRetType# +#dput(rbind(integer(0), NULL, NULL)) +structure(integer(0), .Dim = c(3L, 0L), .Dimnames = list(NULL, + NULL)) + ##com.oracle.truffle.r.test.builtins.TestBuiltin_rbind.testrbind1# #argv <- list(structure(c(3, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 11, 11, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 16, 16, 31, 31, 31, 33, 33, 43, 43, 43, 61, 61, 61, 62, 62, 106, 106, 110, 110, 110, 110, 163, 163, 165, 165, 165, 168, 168, 172, 172, 172, 204, 204, 206, 206, 206, 206, 206, 211, 211, 241, 241, 241, 241, 244, 244, 249, 249, 250, 250, 250, 250, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 256, 256, 265, 265, 265, 265, 265, 265, 265, 265, 265, 267, 267, 267, 269, 269, 269, 291, 291, 291, 291, 291, 291, 291, 312, 312, 312, 312, 312, 314, 314, 314, 314, 314, 2.484906649788, 6.27476202124194, 3.97029191355212, 3.98898404656427, 4.52178857704904, 0, 2.30258509299405, 4.59511985013459, 1.6094379124341, 2.94443897916644, 1.94591014905531, 2.99573227355399, 4.36944785246702, 1.38629436111989, 2.39789527279837, 3.98898404656427, 2.07944154167984, 5.64897423816121, 5.75574221358691, 2.89037175789616, 3.09104245335832, 4.70953020131233, 4.98360662170834, 1.6094379124341, 1.6094379124341, 4.70048036579242, 1.6094379124341, 4.54329478227, 1.6094379124341, 4.49980967033027, 5.62762111369064, 5.11799381241676, 2.39789527279837, 6.28785856016178, 5.4380793089232, 3.63758615972639, 5.76205138278018, 2.83321334405622, 5.7037824746562, 5.90263333340137, 3.40119738166216, 3.63758615972639, 4.31748811353631, 5.58724865840025, 5.32787616878958, 4.06044301054642, 6.22059017009974, 6.20455776256869, 5.2040066870768, 6.20253551718792, 3.78418963391826, 2.94443897916644, 2.63905732961526, 6.24804287450843, 2.63905732961526, 5.74620319054015, 1.79175946922805, 5.44241771052179, 4.99721227376411, 5.93753620508243, 4.02535169073515, 4.74493212836325, 5.90536184805457, 6.00388706710654, 4.91998092582813, 5.73979291217923, 3.13549421592915, 3.17805383034795, 3.58351893845611, 4.89783979995091, 4.49980967033027, 6.0913098820777, 5.75257263882563, 2.30258509299405, 2.77258872223978, 5.28826703069454, 6.10924758276437, 4.74493212836325, 6.16331480403464, 4.57471097850338, 3.55534806148941, 1.38629436111989, 4.46590811865458, 5.93224518744801, 0.693147180559945, 3.95124371858143, 4.0943445622221, 3.17805383034795, 2.484906649788, 5.15905529921453, 3.80666248977032, 2.484906649788, 3.3322045101752, 1.94591014905531, 2.77258872223978, 4.71849887129509, 6.23244801655052, 2.99573227355399, 3.71357206670431, 3.36729582998647, 5.64897423816121, 3.55534806148941, 0.693147180559945, 3.04452243772342, 4.30406509320417, 2.56494935746154, 3.61091791264422, 4.69134788222914, 5.93753620508243, 4.95582705760126, -0.693147180559945, 3.87120101090789, 6.31896811374643, 6.06145691892802, 1.79175946922805, 2.19722457733622, 2.07944154167984, 2.07944154167984, 1.94591014905531, 4.51085950651685, 5.85507192220243, 4.57471097850338, 0.693147180559945, 1.6094379124341, 4.36944785246702, 5.36129216570943, 4.40671924726425, 4.85981240436167, 3.61091791264422, 3.73766961828337, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1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1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0), .Dim = c(3L, 10L)));do.call('rbind', argv) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_cbind.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_cbind.java index 4366b6226e1e366d53718e8d262cb401e0d6a0c9..634cee88e38c519048f8d5e0a5fc6b17c861dd1e 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_cbind.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_cbind.java @@ -103,7 +103,7 @@ public class TestBuiltin_cbind extends TestBase { public void testGenericDispatch() { assertEval("{ v <- 1; class(v) <- 'foo'; cbind.foo <- function(...) 'foo'; cbind(v) }"); assertEval("{ v <- 1; class(v) <- 'foo'; cbind.foo <- function(...) 'foo'; v2 <- 1; class(v2) <- 'foo'; cbind(v2) }"); - assertEval("{ v <- 1; class(v) <- 'foo'; assign('cbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); cbind(v) ; rm('cbind.foo', envir=.__S3MethodsTable__.)}"); + assertEval("{ v <- 1; class(v) <- 'foo'; assign('cbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); result <- cbind(v) ; rm('cbind.foo', envir=.__S3MethodsTable__.); result;}"); // segfault in gnur assertEval(Ignored.ReferenceError, "{ v <- 1; class(v) <- 'foo'; cbind.foo <- length; cbind(v) }"); @@ -129,4 +129,48 @@ public class TestBuiltin_cbind extends TestBase { assertEval("{ v1 <- 1; class(v1) <- 'foo1'; v2 <- 2; class(v2) <- 'foo2'; cbind.foo2 <- function(...) 'foo2'; cbind(v1, v2) }"); } + @Test + public void testDimnames() { + assertEval("{ attributes(cbind(integer(0))) }"); + assertEval("{ attributes(cbind(list())) }"); + assertEval("{ attributes(cbind(matrix())) }"); + assertEval("{ attributes(cbind(1L)) }"); + assertEval("{ attributes(cbind(c(1L, 2L))) }"); + assertEval("{ attributes(cbind(list(1L, 2L))) }"); + assertEval("{ attributes(cbind(matrix(1L, 2L))) }"); + assertEval("{ attributes(cbind(1L, 2L)) }"); + + assertEval("{ cbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L) }"); + assertEval("{ cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L) }"); + assertEval("{ cbind(structure(1:4, dim=c(2,2)), 1L) }"); + + assertEval("{ attributes(cbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L)) }"); + assertEval("{ attributes(cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L)) }"); + assertEval("{ attributes(cbind(structure(1:4, dim=c(2,2)), 1L)) }"); + + assertEval("{ cbind(NULL, integer(0)) }"); + assertEval("{ cbind(integer(0), integer(0)) }"); + assertEval("{ cbind(c(1), integer(0)) }"); + assertEval("{ cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0)) }"); + + assertEval("{ attributes(cbind(NULL, integer(0))) }"); + assertEval("{ attributes(cbind(integer(0), integer(0))) }"); + assertEval("{ attributes(cbind(c(1), integer(0))) }"); + assertEval("{ attributes(cbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0))) }"); + } + + @Test + public void testRetType() { + assertEval("dput(cbind(NULL))"); + assertEval("dput(cbind(NULL, integer(0)))"); + assertEval("dput(cbind(NULL, NULL, integer(0)))"); + assertEval("dput(cbind(NULL, NULL, double(0)))"); + assertEval("dput(cbind(NULL, NULL, integer(0), double(0)))"); + assertEval("dput(cbind(NULL, NULL, double(0), integer(0)))"); + assertEval("dput(cbind(NULL, NULL, double(0), character(0)))"); + assertEval("dput(cbind(NULL, NULL, double(0), integer(0), character(0)))"); + assertEval("dput(cbind(c(NULL, NULL), integer(0)))"); + assertEval("dput(cbind(integer(0)))"); + assertEval("dput(cbind(integer(0), NULL, NULL))"); + } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_deparse.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_deparse.java index b1d19e945d05d1bb20551aa2f3eb906fe4bd6f31..70eb09d7837341c519da3734844e11d30cc5d755 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_deparse.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_deparse.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2012-2014, Purdue University - * Copyright (c) 2013, 2016, Oracle and/or its affiliates + * Copyright (c) 2013, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -276,6 +276,13 @@ public class TestBuiltin_deparse extends TestBase { "-0.0000000000000001", "-1.545234523452345252523452345", "-Inf", "c(1L,2L,3L)", "c(1,2,3)", "c(NA_integer_, 1L,2L,3L)", "c(1L,2L,3L, NA_integer_)", "c(3L,2L,1L)", "c(-2L,-1L,0L,1L)"}; + @Test + public void testDeparseStructure() { + assertEval("{ deparse(structure(.Data=c(1,2))) }"); + assertEval("{ deparse(structure(.Data=c(1,2), attr1=c(1))) }"); + assertEval("{ deparse(structure(.Data=c(1,2), attr1=c(1), attr2=c(2))) }"); + } + @Test public void testDeparse() { assertEval(template("deparse(%0)", VALUES)); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rbind.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rbind.java index af4dada52072288087467ed86b689faf77d3619d..f227f141c4a0161d40a9ff58ca6350e702590d9a 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rbind.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rbind.java @@ -87,7 +87,7 @@ public class TestBuiltin_rbind extends TestBase { public void testGenericDispatch() { assertEval("{ v <- 1; class(v) <- 'foo'; rbind.foo <- function(...) 'foo'; rbind(v) }"); assertEval("{ v <- 1; class(v) <- 'foo'; rbind.foo <- function(...) 'foo'; v2 <- 1; class(v2) <- 'foo'; rbind(v2) }"); - assertEval("{ v <- 1; class(v) <- 'foo'; assign('rbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); rbind(v) ; rm('rbind.foo', envir=.__S3MethodsTable__.)}"); + assertEval("{ v <- 1; class(v) <- 'foo'; assign('rbind.foo', function(x) {'foo'}, envir=.__S3MethodsTable__.); result <- rbind(v) ; rm('rbind.foo', envir=.__S3MethodsTable__.); result;}"); // segfault in gnur assertEval(Ignored.ReferenceError, "{ v <- 1; class(v) <- 'foo'; rbind.foo <- length; rbind(v) }"); @@ -112,4 +112,45 @@ public class TestBuiltin_rbind extends TestBase { assertEval("{ v1 <- 1; class(v1) <- 'foo1'; rbind.foo1 <- function(...) 'foo1'; v2 <- 2; class(v2) <- 'foo2'; rbind(v1, v2) }"); assertEval("{ v1 <- 1; class(v1) <- 'foo1'; v2 <- 2; class(v2) <- 'foo2'; rbind.foo2 <- function(...) 'foo2'; rbind(v1, v2) }"); } + + @Test + public void testDimnames() { + assertEval("{ attributes(rbind(integer(0))) }"); + assertEval("{ attributes(rbind(1L)) }"); + assertEval("{ attributes(rbind(c(1L, 2L))) }"); + assertEval("{ attributes(rbind(1L, 2L)) }"); + + assertEval("{ rbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L) }"); + assertEval("{ rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L) }"); + assertEval("{ rbind(structure(1:4, dim=c(2,2)), 1L) }"); + + assertEval("{ attributes(rbind(structure(1:4, dim=c(2,2), dimnames=list(c('y1', 'y2'), c('x1', 'x2'))), 1L)) }"); + assertEval("{ attributes(rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), 1L)) }"); + assertEval("{ attributes(rbind(structure(1:4, dim=c(2,2)), 1L)) }"); + + assertEval("{ rbind(NULL, integer(0)) }"); + assertEval("{ rbind(integer(0), integer(0)) }"); + assertEval("{ rbind(c(1), integer(0)) }"); + assertEval("{ rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0)) }"); + + assertEval("{ attributes(rbind(NULL, integer(0))) }"); + assertEval("{ attributes(rbind(integer(0), integer(0))) }"); + assertEval("{ attributes(rbind(c(1), integer(0))) }"); + assertEval("{ attributes(rbind(structure(1:4, dim=c(2,2), dimnames=list(y=c('y1', 'y2'), x=c('x1', 'x2'))), integer(0))) }"); + } + + @Test + public void testRetType() { + assertEval("dput(rbind(NULL))"); + assertEval("dput(rbind(NULL, integer(0)))"); + assertEval("dput(rbind(NULL, NULL, integer(0)))"); + assertEval("dput(rbind(NULL, NULL, double(0)))"); + assertEval("dput(rbind(NULL, NULL, integer(0), double(0)))"); + assertEval("dput(rbind(NULL, NULL, double(0), integer(0)))"); + assertEval("dput(rbind(NULL, NULL, double(0), character(0)))"); + assertEval("dput(rbind(NULL, NULL, double(0), integer(0), character(0)))"); + assertEval("dput(rbind(c(NULL, NULL), integer(0)))"); + assertEval("dput(rbind(integer(0)))"); + assertEval("dput(rbind(integer(0), NULL, NULL))"); + } }