diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatchArg.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatchArg.java index 748b85555f953729c12da0abc4c48ce5f2f51b41..f58283148d64ef914a001351d4363ed2c8423d36 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatchArg.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatchArg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.builtin.base; import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.logicalValue; -import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue; import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.toBoolean; import static com.oracle.truffle.r.nodes.builtin.casts.fluent.CastNodeBuilder.newCastBuilder; import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX; @@ -40,6 +39,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.RRootNode; +import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.MatchArgNodeGen.MatchArgInternalNodeGen; import com.oracle.truffle.r.nodes.function.FormalArguments; @@ -80,8 +80,8 @@ public abstract class MatchArg extends RBuiltinNode.Arg3 { @Child private PMatch pmatch = PMatchNodeGen.create(); @Child private Identical identical = IdenticalNodeGen.create(); - @Child private CastNode argCast = newCastBuilder().asStringVector().buildCastNode(); - @Child private CastNode choicesCast = newCastBuilder().allowMissing().mustBe(stringValue()).asStringVector().buildCastNode(); + @Child private CastNode argCast = newCastBuilder().defaultError(Message.MUST_BE_NULL_OR_STRING, "arg").allowNull().mustBe(stringValue()).buildCastNode(); + @Child private CastNode choicesCast = newCastBuilder().allowNull().asStringVector().buildCastNode(); @Child private CastNode severalOKCast = newCastBuilder().mustBe(logicalValue()).asLogicalVector().findFirst().map(toBoolean()).buildCastNode(); public abstract Object execute(Object arg, Object choices, Object severalOK); @@ -90,6 +90,11 @@ public abstract class MatchArg extends RBuiltinNode.Arg3 { return execute(argCast.doCast(arg), choicesCast.doCast(choices), severalOKCast.doCast(severalOK)); } + @Specialization + protected Object match(@SuppressWarnings("unused") RNull arg, @SuppressWarnings("unused") RNull choices, @SuppressWarnings("unused") boolean severalOK) { + return RNull.instance; + } + @Specialization protected String matchArgNULL(@SuppressWarnings("unused") RNull arg, RAbstractStringVector choices, @SuppressWarnings("unused") boolean severalOK, @Cached("createBinaryProfile()") ConditionProfile isEmptyProfile) { @@ -144,13 +149,24 @@ public abstract class MatchArg extends RBuiltinNode.Arg3 { } RIntVector matched = pmatch.execute(arg, choices, -1, true); int count = count(matched); + checkEmpty(choices, count); if (count == 1) { - return choices.getDataAt(matched.getDataAt(0) - 1); + for (int i = 0; i < matched.getLength(); i++) { + int matchedIdx = matched.getDataAt(i); + if (matchedIdx > 0) { + return choices.getDataAt(matchedIdx - 1); + } + } + assert false; } - checkEmpty(choices, count); String[] result = new String[count]; + int resultIdx = -1; for (int i = 0; i < matched.getLength(); i++) { - result[i] = choices.getDataAt(matched.getDataAt(i) - 1); + int matchedIdx = matched.getDataAt(i); + if (matchedIdx > 0) { + resultIdx++; + result[resultIdx] = choices.getDataAt(matchedIdx - 1); + } } return RDataFactory.createStringVector(result, choices.isComplete()); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java index 6ee0bd71c9059fa8f27e81e34a64ce30e5612cbb..041f3d91b568f1c83d4d41349949e3c5edb974cd 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java @@ -12,21 +12,25 @@ */ package com.oracle.truffle.r.nodes.builtin.base; +import com.oracle.truffle.api.CompilerDirectives; import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.LoopConditionProfile; import com.oracle.truffle.r.nodes.attributes.CopyOfRegAttributesNode; import com.oracle.truffle.r.nodes.attributes.CopyOfRegAttributesNodeGen; import com.oracle.truffle.r.nodes.attributes.InitAttributesNode; +import com.oracle.truffle.r.nodes.attributes.RemoveAttributeNode; import com.oracle.truffle.r.nodes.attributes.SetFixedAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.ExtractNamesAttributeNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.function.opt.ReuseNonSharedNode; import com.oracle.truffle.r.nodes.profile.VectorLengthProfile; @@ -37,8 +41,10 @@ import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RDataFactory.VectorFactory; import com.oracle.truffle.r.runtime.data.RList; +import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RVector; +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.RandomIterator; @@ -61,6 +67,8 @@ public abstract class Transpose extends RBuiltinNode.Arg1 { @Child private ExtractNamesAttributeNode extractAxisNamesNode = ExtractNamesAttributeNode.create(); @Child private GetDimAttributeNode getDimNode = GetDimAttributeNode.create(); @Child private ReuseNonSharedNode reuseNonShared = ReuseNonSharedNode.create(); + @Child private GetNamesAttributeNode getNamesNode; + @Child private RemoveAttributeNode removeAttributeNode; static { Casts.noCasts(Transpose.class); @@ -146,7 +154,7 @@ public abstract class Transpose extends RBuiltinNode.Arg1 { } } // don't need to set new dimensions; it is a square matrix - putNewDimNames(vector, vector); + convertDimNames(vector, vector); } @Specialization(guards = {"isSquare(x)", "!isRExpression(x)", "xReuse.supports(x)"}) @@ -192,7 +200,7 @@ public abstract class Transpose extends RBuiltinNode.Arg1 { // copy attributes copyRegAttributes.execute(x, result); // set new dimensions - putNewDimensions(x, result, new int[]{secondDim, firstDim}); + putNewDimsFromDimnames(x, result, new int[]{secondDim, firstDim}); } result.setComplete(x.isComplete()); return result; @@ -208,17 +216,21 @@ public abstract class Transpose extends RBuiltinNode.Arg1 { @Specialization(guards = {"!isMatrix(x)", "!isRExpression(x)"}) protected RVector<?> transposeNonMatrix(RAbstractVector x) { RVector<?> reused = reuseNonShared.execute(x); - putNewDimensions(reused, reused, new int[]{1, x.getLength()}); + putNewDimsFromNames(reused, reused, new int[]{1, x.getLength()}); return reused; + } + private void putNewDimsFromDimnames(RAbstractVector source, RAbstractVector dest, int[] newDim) { + putDimensions.execute(initAttributes.execute(dest), RDataFactory.createIntVector(newDim, RDataFactory.COMPLETE_VECTOR)); + convertDimNames(source, dest); } - private void putNewDimensions(RAbstractVector source, RAbstractVector dest, int[] newDim) { + private void putNewDimsFromNames(RAbstractVector source, RAbstractVector dest, int[] newDim) { putDimensions.execute(initAttributes.execute(dest), RDataFactory.createIntVector(newDim, RDataFactory.COMPLETE_VECTOR)); - putNewDimNames(source, dest); + convertNamesToDimnames(source, dest); } - private void putNewDimNames(RAbstractVector source, RAbstractVector dest) { + private void convertDimNames(RAbstractVector source, RAbstractVector dest) { // set new dim names RList dimNames = getDimNamesNode.getDimNames(source); if (dimNames != null) { @@ -231,6 +243,24 @@ public abstract class Transpose extends RBuiltinNode.Arg1 { } } + private void convertNamesToDimnames(RAbstractVector source, RAbstractVector dest) { + if (getNamesNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + getNamesNode = insert(GetNamesAttributeNode.create()); + } + RAbstractStringVector names = (RAbstractStringVector) getNamesNode.execute(source); + if (names != null) { + RList newDimNames = RDataFactory.createList(new Object[]{RNull.instance, names}); + DynamicObject attributes = dest.getAttributes(); + putDimNames.execute(attributes, newDimNames); + if (removeAttributeNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + removeAttributeNode = insert(RemoveAttributeNode.create()); + } + removeAttributeNode.execute(attributes, "names"); + } + } + @Fallback protected RVector<?> transpose(@SuppressWarnings("unused") Object x) { throw error(Message.ARGUMENT_NOT_MATRIX); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Collections.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Collections.java index 1ec37f3d8c4b3b081f6ac0e8e5e2cb15477c92bf..1b339b72df6f9396e3784d58e0b2d4a0da5ea4ff 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Collections.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Collections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,7 +92,7 @@ public final class Collections { } public boolean add(double key) { - int ind = Math.abs(Double.hashCode(key)) % keys.length; + int ind = getInd(key, keys.length); int firstInd = ind; while (true) { if (RRuntime.isNAorNaN(keys[ind])) { @@ -108,7 +108,7 @@ public final class Collections { Arrays.fill(newKeys, RRuntime.DOUBLE_NA); for (int i = 0; i < keys.length; i++) { if (!RRuntime.isNAorNaN(keys[i])) { - int tmpInd = Math.abs(Double.hashCode(keys[i])) % newKeys.length; + int tmpInd = getInd(keys[i], newKeys.length); while (true) { if (RRuntime.isNAorNaN(newKeys[tmpInd])) { newKeys[tmpInd] = keys[i]; @@ -124,11 +124,22 @@ public final class Collections { keys = newKeys; // start hashing from the beginning - ind = Math.abs(Double.hashCode(key)) % keys.length; + ind = getInd(key, keys.length); } } } } + + private static int getInd(double key, int keyLength) { + int h = Double.hashCode(key); + if (h == Integer.MIN_VALUE) { + // HOTFIX: + // Double.hashCode(-0.0) is Integer.MIN_VALUE + // Maths.abs(Integer.MIN_VALUE) is Integer.MIN_VALUE + return 0; + } + return Math.abs(h) % keyLength; + } } public static class NonRecursiveHashSetInt { 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 cf3bf2b3242a84b9aa267d5ad5af6ded38960207..9638386128124c34d5310738811de205e4d850b3 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 @@ -38087,6 +38087,108 @@ integer(0) [1] 1 1 2 2 3 4 5 5 5 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 [26] 10 11 11 12 12 12 13 13 13 13 14 14 14 15 15 15 15 15 16 17 18 18 18 18 19 +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(NULL, NULL) +NULL + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(NULL, c('a')) +[1] "a" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(NULL, c()) +NULL + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(NULL, c(1)) +[1] 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(NULL, character()) +[1] NA + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(NULL, list()) +[[1]] +NULL + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(c('1'), c(1), T) +[1] 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(c('1'), list(1), T) +[[1]] +[1] 1 + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(c('1', '1'), c(1), T) +[1] 1 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a'), c('a'), T) +[1] "a" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Output.IgnoreErrorMessage# +#match.arg(c('a'), c('b'), T) +Error in match.arg(c("a"), c("b"), T) : 'arg' should be one of “b” + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(c('a'), list('a', 'b'), T) +[[1]] +[1] "a" + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#match.arg(c('a'), list(a='a', b='b'), T) +$a +[1] "a" + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b'), c('a'), F) +Error in match.arg(c("a", "b"), c("a"), F) : 'arg' must be of length 1 + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b'), c('a'), T) +[1] "a" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b'), c('b'), T) +[1] "b" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b', 'c'), c('a', 'b'), T) +[1] "a" "b" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b', 'c'), c('a', 'c'), T) +[1] "a" "c" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b', 'c'), c('b'), T) +[1] "b" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b', 'c'), c('b', 'c'), T) +[1] "b" "c" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg# +#match.arg(c('a', 'b', 'c'), c('c', 'b'), T) +[1] "b" "c" + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Output.IgnoreErrorMessage# +#match.arg(list('a', 'b'), 'c', T) +Error in match.arg(list("a", "b"), "c", T) : + 'arg' must be NULL or a character vector + +##com.oracle.truffle.r.test.builtins.TestBuiltin_matcharg.testMatchArg#Ignored.ImplementationError# +#{ v<-c('a', 'b'); names(v) <- c('an', 'ab'); match.arg(c('a', 'b'), v, T)} + an ab +"a" "b" + ##com.oracle.truffle.r.test.builtins.TestBuiltin_matchcall.testMatchCall# #fn3 <- function(...) { (function(...) match.call(cat, call("cat", "abc", p=3,as.symbol("...")), expand.dots = FALSE))(...) }; fn3(sep=x,lab="b",fill=13) cat(... = pairlist("abc", p = 3, lab = "b"), sep = ..1, fill = 13) @@ -73796,6 +73898,11 @@ Error in t.default(new.env()) : argument is not a matrix [,1] [,2] [,3] [1,] 1 2 3 +##com.oracle.truffle.r.test.builtins.TestBuiltin_t.testTranspose# +#{ x <- 1:3; names(x) <- c('a', 'b'); t(x) } + a b <NA> +[1,] 1 2 3 + ##com.oracle.truffle.r.test.builtins.TestBuiltin_t.testTranspose# #{ x<-matrix(1:2, ncol=2, dimnames=list("a", c("b", "c"))); t(x) } a @@ -76085,6 +76192,10 @@ attr(,"row.names") "3rd Qu.: 7.75 " "3rd Qu.: 7.75 3rd Qu.:17.75 " "Max. :10.00 " "Max. :10.00 Max. :20.00 " +##com.oracle.truffle.r.test.builtins.TestBuiltin_unique.testUnique# +#{ unique(c(-0.0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) } +[1] 0 1 + ##com.oracle.truffle.r.test.builtins.TestBuiltin_unique.testUnique#Ignored.ReferenceError# #{ unique(c(1,2,1), incomparables=function() 42) } Error in unique.default(c(1, 2, 1), incomparables = function() 42) : diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_matcharg.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_matcharg.java new file mode 100644 index 0000000000000000000000000000000000000000..a5bf170f7c1bb401a1cf49c5d65128c296c4f0ec --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_matcharg.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.test.builtins; + +import org.junit.Test; + +import com.oracle.truffle.r.test.TestBase; + +public class TestBuiltin_matcharg extends TestBase { + + @Test + public void testMatchArg() { + assertEval("match.arg(NULL, c('a'))"); + assertEval(Ignored.ImplementationError, "match.arg(NULL, c(1))"); + assertEval("match.arg(NULL, c())"); + assertEval("match.arg(NULL, character())"); + assertEval(Ignored.ImplementationError, "match.arg(NULL, list())"); + assertEval("match.arg(NULL, NULL)"); + + // plain vector + assertEval("match.arg(c('a'), c('a'), T)"); + + assertEval("match.arg(c('a', 'b'), c('a'), F)"); + + assertEval("match.arg(c('a', 'b'), c('a'), T)"); + assertEval("match.arg(c('a', 'b'), c('b'), T)"); + assertEval("match.arg(c('a', 'b', 'c'), c('b'), T)"); + assertEval("match.arg(c('a', 'b', 'c'), c('b', 'c'), T)"); + assertEval("match.arg(c('a', 'b', 'c'), c('c', 'b'), T)"); + assertEval("match.arg(c('a', 'b', 'c'), c('a', 'b'), T)"); + assertEval("match.arg(c('a', 'b', 'c'), c('a', 'c'), T)"); + + assertEval(Ignored.ImplementationError, "match.arg(c('1'), c(1), T)"); + assertEval(Ignored.ImplementationError, "match.arg(c('1', '1'), c(1), T)"); + + // named vector + assertEval(Ignored.ImplementationError, "{ v<-c('a', 'b'); names(v) <- c('an', 'ab'); match.arg(c('a', 'b'), v, T)}"); + + // list/named list + assertEval(Ignored.ImplementationError, "match.arg(c('a'), list('a', 'b'), T)"); + assertEval(Ignored.ImplementationError, "match.arg(c('a'), list(a='a', b='b'), T)"); + assertEval(Ignored.ImplementationError, "match.arg(c('1'), list(1), T)"); + + assertEval(Output.IgnoreErrorMessage, "match.arg(list('a', 'b'), 'c', T)"); + assertEval(Output.IgnoreErrorMessage, "match.arg(c('a'), c('b'), T)"); + } +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_t.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_t.java index ca5b37d80674154befc4b2ec214dc4a11909ea31..e85550eebe9790f47c6bfe8d339fa778967caa4f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_t.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_t.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2012-2014, Purdue University - * Copyright (c) 2013, 2017, Oracle and/or its affiliates + * Copyright (c) 2013, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -34,6 +34,8 @@ public class TestBuiltin_t extends TestBase { assertEval("{ t(1:3) }"); assertEval("{ t(t(t(1:3))) }"); + assertEval("{ x <- 1:3; names(x) <- c('a', 'b'); t(x) }"); + assertEval("{ t(matrix(1:6, nrow=2)) }"); assertEval("{ t(t(matrix(1:6, nrow=2))) }"); assertEval("{ t(matrix(1:4, nrow=2)) }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_unique.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_unique.java index d990d1c239ab17efd170416b2321c2f77144a1dc..9ebd101691772a36f124662f99d9fddcab6d60b4 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_unique.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_unique.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2012-2014, Purdue University - * Copyright (c) 2013, 2017, Oracle and/or its affiliates + * Copyright (c) 2013, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -192,5 +192,7 @@ public class TestBuiltin_unique extends TestBase { // seems a bit better than GnuR's "cannot coerce type 'closure' to vector of type 'double'" assertEval(Ignored.ReferenceError, "{ unique(c(1,2,1), incomparables=function() 42) }"); + assertEval("{ unique(c(-0.0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) }"); + } }