diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c index bd23d30a26edf10ded673880bb6158f71974ca28..4d27f95442b8b16a2eb8a9743acd6e2d768fc386 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c @@ -59,6 +59,7 @@ static jmethodID TAG_MethodID; static jmethodID PRINTNAME_MethodID; static jmethodID CAR_MethodID; static jmethodID CDR_MethodID; +static jmethodID SET_TAG_MethodID; static jmethodID SETCAR_MethodID; static jmethodID SETCDR_MethodID; static jmethodID SET_STRING_ELT_MethodID; @@ -124,6 +125,7 @@ void init_internals(JNIEnv *env) { PRINTNAME_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "PRINTNAME", "(Ljava/lang/Object;)Ljava/lang/Object;", 1); CAR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CAR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1); CDR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "CDR", "(Ljava/lang/Object;)Ljava/lang/Object;", 1); + SET_TAG_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_TAG", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1); SETCAR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SETCAR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1); SETCDR_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SETCDR", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 1); SET_STRING_ELT_MethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_STRING_ELT", "(Ljava/lang/Object;ILjava/lang/Object;)V", 1); @@ -731,7 +733,8 @@ void SET_MISSING(SEXP x, int v) { } void SET_TAG(SEXP x, SEXP y) { - unimplemented("SET_TAG"); + JNIEnv *thisenv = getEnv(); + (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, SET_TAG_MethodID, x, y); } SEXP SETCAR(SEXP x, SEXP y) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java index fb1f000221e8594aba07ddc734d7d429fef6f432..17b15adcfdc3f4d0c7389466d5daa79af385918e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java @@ -222,7 +222,7 @@ public class BasePackage extends RBuiltinPackage { add(EnvFunctions.SetParentEnv.class, EnvFunctionsFactory.SetParentEnvNodeGen::create); add(EnvFunctions.UnlockBinding.class, EnvFunctionsFactory.UnlockBindingNodeGen::create); add(EvalFunctions.Eval.class, EvalFunctionsFactory.EvalNodeGen::create); - add(EvalFunctions.WithVisible.class, EvalFunctionsFactory.WithVisibleNodeGen::create); + add(WithVisible.class, WithVisibleNodeGen::create); add(Exists.class, ExistsNodeGen::create); add(Expression.class, ExpressionNodeGen::create); add(FastR.class, FastRNodeGen::create); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java index 8d29c93a3027eb447d1648aeb752f88f8f73103c..c40c949495f1b771c53e8683e4229fcfd3429be3 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Call.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -35,16 +35,18 @@ import com.oracle.truffle.r.runtime.nodes.*; /** * Construct a call object ({@link RLanguage}) from a name and optional arguments. + * + * Does not perform argument matching for first parameter "name". */ -@RBuiltin(name = "call", kind = PRIMITIVE, parameterNames = {"name", "..."}) +@RBuiltin(name = "call", kind = PRIMITIVE, parameterNames = {"", "..."}) public abstract class Call extends RBuiltinNode { - @Specialization(guards = "!isEmptyName(name)") - protected RLanguage call(RAbstractStringVector name, @SuppressWarnings("unused") RMissing args) { - return makeCall(name.getDataAt(0), null); + @Override + public Object[] getDefaultParameterValues() { + return new Object[]{RMissing.instance, RArgsValuesAndNames.EMPTY}; } - @Specialization(guards = "!isEmptyName(name)") + @Specialization(guards = "name.getLength() != 0") protected RLanguage call(RAbstractStringVector name, RArgsValuesAndNames args) { return makeCall(name.getDataAt(0), args); } @@ -55,10 +57,6 @@ public abstract class Call extends RBuiltinNode { throw RError.error(this, RError.Message.FIRST_ARG_MUST_BE_STRING); } - protected boolean isEmptyName(RAbstractStringVector name) { - return name.getLength() == 0; - } - @TruffleBoundary protected static RLanguage makeCall(String name, RArgsValuesAndNames args) { return makeCall0(name, false, args); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EvalFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EvalFunctions.java index 6acba6387a0ac5af60dd379a89c3ecff76d7a6eb..f807f883956513937fc39aa49d0e2b2fa4526545 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EvalFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EvalFunctions.java @@ -137,20 +137,4 @@ public class EvalFunctions { throw RError.error(this, RError.Message.INVALID_OR_UNIMPLEMENTED_ARGUMENTS); } } - - @RBuiltin(name = "withVisible", kind = RBuiltinKind.PRIMITIVE, parameterNames = "x", nonEvalArgs = 0) - public abstract static class WithVisible extends EvalAdapter { - private static final RStringVector LISTNAMES = RDataFactory.createStringVector(new String[]{"value", "visible"}, RDataFactory.COMPLETE_VECTOR); - - @Specialization - protected RList withVisible(VirtualFrame frame, RPromise expr) { - controlVisibility(); - Object result = doEvalBody(RArguments.getDepth(frame) + 1, RDataFactory.createLanguage((RNode) expr.getRep()), REnvironment.frameToEnvironment(frame.materialize())); - Object[] data = new Object[]{result, RRuntime.asLogical(RContext.getInstance().isVisible())}; - // Visibility is changed by the evaluation (else this code would not work), - // so we have to force it back on. - RContext.getInstance().setVisible(true); - return RDataFactory.createList(data, LISTNAMES); - } - } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java index 5662f28fcec5ded54024549d9107e3ca4b6d8074..ff65cf02c7519e8412c63a69da7f57cb617bbe48 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Round.java @@ -121,7 +121,7 @@ public abstract class Round extends RBuiltinNode { } @Specialization(guards = "digits == 0") - protected RComplexVector round(RComplexVector x, int digits) { + protected RComplexVector round(RAbstractComplexVector x, int digits) { controlVisibility(); double[] result = new double[x.getLength() << 1]; check.enable(x); @@ -138,7 +138,7 @@ public abstract class Round extends RBuiltinNode { } @Specialization(guards = "digits != 0") - protected RComplexVector roundDigits(RComplexVector x, int digits) { + protected RComplexVector roundDigits(RAbstractComplexVector x, int digits) { controlVisibility(); double[] result = new double[x.getLength() << 1]; check.enable(x); @@ -153,5 +153,4 @@ public abstract class Round extends RBuiltinNode { ret.copyAttributesFrom(attrProfiles, x); return ret; } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WithVisible.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WithVisible.java new file mode 100644 index 0000000000000000000000000000000000000000..072c4f9a8242ea0d5bdd6058c0f1c99c82f958db --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/WithVisible.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014, 2016, 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.nodes.builtin.base; + +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.runtime.FastROptions; +import com.oracle.truffle.r.runtime.RBuiltin; +import com.oracle.truffle.r.runtime.RBuiltinKind; +import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.Message; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.context.RContext; +import com.oracle.truffle.r.runtime.data.RDataFactory; +import com.oracle.truffle.r.runtime.data.RList; +import com.oracle.truffle.r.runtime.data.RMissing; +import com.oracle.truffle.r.runtime.data.RStringVector; + +@RBuiltin(name = "withVisible", kind = RBuiltinKind.PRIMITIVE, parameterNames = "x") +public abstract class WithVisible extends RBuiltinNode { + private static final RStringVector LISTNAMES = RDataFactory.createStringVector(new String[]{"value", "visible"}, RDataFactory.COMPLETE_VECTOR); + + @Specialization(guards = "!isRMissing(x)") + protected RList withVisible(Object x) { + assert !FastROptions.IgnoreVisibility.getBooleanValue() : "using withVisible with IgnoreVisibility"; + + Object[] data = new Object[]{x, RRuntime.asLogical(RContext.getInstance().isVisible())}; + // Visibility is changed by the evaluation (else this code would not work), + // so we have to force it back on. + controlVisibility(); + return RDataFactory.createList(data, LISTNAMES); + } + + @Specialization + protected RList withVisible(@SuppressWarnings("unused") RMissing x) { + controlVisibility(); + throw RError.error(this, Message.ARGUMENT_MISSING, "x"); + } +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/forkcluster_overrides.R b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/forkcluster_overrides.R index ad71acfce277f2a3e3b7490c2538550c9775c389..6272309b9133118b7de268c663a6dbe28c0ff210 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/forkcluster_overrides.R +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/forkcluster_overrides.R @@ -1,17 +1,13 @@ -# Copyright (C) 1995-2014 The R Core Team # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This material is distributed under the GNU General Public License +# Version 2. You may review the terms of this license at +# http://www.gnu.org/licenses/gpl-2.0.html # -# This program 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 for more details. +# Copyright (c) 1995-2014, The R Core Team +# Copyright (c) 2016, Oracle and/or its affiliates +# +# All rights reserved. # -# A copy of the GNU General Public License is available at -# http://www.r-project.org/Licenses/ ## Derived from snow and parallel packages diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/mclapply_overrides.R b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/mclapply_overrides.R index fc2862634c9d173148f52c46098e1f6cfd604010..9f8d99a4060788e90f5e7ad69e78b37d7177dd82 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/mclapply_overrides.R +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/parallel/R/mclapply_overrides.R @@ -1,17 +1,13 @@ -# Copyright (C) 1995-2014 The R Core Team # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This material is distributed under the GNU General Public License +# Version 2. You may review the terms of this license at +# http://www.gnu.org/licenses/gpl-2.0.html # -# This program 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 for more details. +# Copyright (c) 1995-2014, The R Core Team +# Copyright (c) 2016, Oracle and/or its affiliates +# +# All rights reserved. # -# A copy of the GNU General Public License is available at -# http://www.r-project.org/Licenses/ ## Derived from snow and parallel packages diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateSlotNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateSlotNode.java index f18b2f5c54407f59935641a2ec6f21402bfb6f93..ce347a2cfa255fc6d6142408a21ca90338b3ef97 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateSlotNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateSlotNode.java @@ -16,13 +16,12 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.NodeChildren; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.r.nodes.attributes.InitAttributesNode; import com.oracle.truffle.r.nodes.attributes.PutAttributeNode; import com.oracle.truffle.r.nodes.attributes.PutAttributeNodeGen; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.data.RAttributable; -import com.oracle.truffle.r.runtime.data.RAttributes; import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.env.REnvironment; @@ -31,8 +30,6 @@ import com.oracle.truffle.r.runtime.nodes.RNode; @NodeChildren({@NodeChild(value = "object", type = RNode.class), @NodeChild(value = "name", type = RNode.class), @NodeChild(value = "value", type = RNode.class)}) public abstract class UpdateSlotNode extends RNode { - private final BranchProfile noAttributes = BranchProfile.create(); - public abstract Object executeUpdate(Object object, String name, Object value); protected PutAttributeNode createAttrUpdate(String name) { @@ -47,13 +44,9 @@ public abstract class UpdateSlotNode extends RNode { @Specialization(guards = {"!isData(name)", "name == cachedName"}) protected Object updateSlotS4Cached(RAttributable object, String name, Object value, // @Cached("name") String cachedName, // - @Cached("createAttrUpdate(cachedName)") PutAttributeNode attributeUpdate) { - RAttributes attributes = object.getAttributes(); - if (attributes == null) { - noAttributes.enter(); - attributes = object.initAttributes(); - } - attributeUpdate.execute(attributes, prepareValue(value)); + @Cached("createAttrUpdate(cachedName)") PutAttributeNode attributeUpdate, // + @Cached("create()") InitAttributesNode initAttributes) { + attributeUpdate.execute(initAttributes.execute(object), prepareValue(value)); return object; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/InitAttributesNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/InitAttributesNode.java index c971810ee0312c3373e045c3fa0021d584b8707f..9c0fd581955018c61facf653b121c28438761fec 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/InitAttributesNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/InitAttributesNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -36,11 +36,11 @@ public final class InitAttributesNode extends RBaseNode { return new InitAttributesNode(); } - public RAttributes execute(RVector vector) { - RAttributes attributes = vector.getAttributes(); + public RAttributes execute(RAttributable attributable) { + RAttributes attributes = attributable.getAttributes(); if (hasAttributes.profile(attributes == null)) { attributes = RAttributes.create(); - vector.initAttributes(attributes); + attributable.initAttributes(attributes); } return attributes; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java index 766c97bdc329b740bf6f6a2c7a7125194715da7b..0b836f3b20bb4957a73c846c89a60b69382932a3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java @@ -130,7 +130,7 @@ public abstract class ClassHierarchyNode extends UnaryNode { } RStringVector classHierarchy = (RStringVector) access.execute(attributes); if (nullAttributeProfile.profile(classHierarchy != null)) { - if (isS4Profile.profile(withS4 && profiledArg.isS4() && classHierarchy.getLength() > 0)) { + if (profiledArg.isS4() && isS4Profile.profile(withS4 && classHierarchy.getLength() > 0)) { if (s4Class == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); s4Class = insert(S4ClassNodeGen.create()); diff --git a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java index 21cf7d43350ebb8ab55e980b54c77a7515d55b94..d0026a63c40987683b6cf0357d500b1d87065cb1 100644 --- a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java +++ b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java @@ -467,8 +467,13 @@ public class CallRFFIHelper { } public static Object TAG(Object e) { - guaranteeInstanceOf(e, RPairList.class); - return ((RPairList) e).getTag(); + if (e instanceof RPairList) { + return ((RPairList) e).getTag(); + } else { + guaranteeInstanceOf(e, RExternalPtr.class); + // at the moment, this can only be used to null out the pointer + return ((RExternalPtr) e).getTag(); + } } public static Object CAR(Object e) { @@ -489,6 +494,17 @@ public class CallRFFIHelper { return cadr; } + public static Object SET_TAG(Object x, Object y) { + if (x instanceof RPairList) { + ((RPairList) x).setTag(y); + } else { + guaranteeInstanceOf(x, RExternalPtr.class); + // at the moment, this can only be used to null out the pointer + ((RExternalPtr) x).setTag(y); + } + return x; // TODO check or y? + } + public static Object SETCAR(Object x, Object y) { guaranteeInstanceOf(x, RPairList.class); ((RPairList) x).setCar(y); 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 5f0607e32e39c82651ded0f554ce204a7f1075f5..158086e24243c1b24ce0e1057dabb3e1ba136516 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 @@ -48971,6 +48971,64 @@ integer(0) #argv <- structure(list(x = c(NA, NA, Inf)), .Names = 'x');do.call('which.min', argv) [1] 3 +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#f <- function(x) { 1 + x }; withVisible(f(1)) +$value +[1] 2 + +$visible +[1] TRUE + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#f <- function(x) { foo <- 1 + x }; withVisible(f(1)) +$value +[1] 2 + +$visible +[1] FALSE + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#withVisible() +Error in withVisible() : argument "x" is missing, with no default + +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#withVisible(1) +$value +[1] 1 + +$visible +[1] TRUE + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#withVisible(x <- 1) +$value +[1] 1 + +$visible +[1] FALSE + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#withVisible({ 1; x <- 1 }) +$value +[1] 1 + +$visible +[1] FALSE + + +##com.oracle.truffle.r.test.builtins.TestBuiltin_withVisible.testwithVisible +#withVisible({ x <- 1; 1 }) +$value +[1] 1 + +$visible +[1] TRUE + + ##com.oracle.truffle.r.test.builtins.TestBuiltin_withdefault.testwithdefault1 #argv <- structure(list(data = structure(list(X = 22.1693750707316, Y = -0.652127930273561, Z = 1.03034043827436, a = -2.66666666666667, b = -10, c = 28), .Names = c('X', 'Y', 'Z', 'a', 'b', 'c')), expr = expression({ dX <- a * X + Y * Z dY <- b * (Y - Z) dZ <- -X * Y + c * Y - Z list(c(dX, dY, dZ)) })), .Names = c('data', 'expr'));do.call('with.default', argv) Error: unexpected symbol in "ructure(list(data = structure(list(X = 22.1693750707316, Y = -0.652127930273561, Z = 1.03034043827436, a = -2.66666666666667, b = -10, c = 28), .Names = c('X', 'Y', 'Z', 'a', 'b', 'c')" @@ -103398,50 +103456,6 @@ a b c d a b c d e 1 2 3 4 5 -##com.oracle.truffle.r.test.library.fastr.TestChannels.testChannels -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 49 } else { ch <- fastr.channel.create(1L); cx <- fastr.context.create("SHARED_NOTHING"); fastr.context.spawn(cx, "ch <- fastr.channel.get(1L); f<-fastr.channel.receive(ch); x<-f(7); fastr.channel.send(ch, x)"); mul<-function(y) y*y; fastr.channel.send(ch, mul); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); x } -[1] 49 - -##com.oracle.truffle.r.test.library.fastr.TestChannels.testChannels -#if (length(grep("FastR", R.Version()$version.string)) != 1) { list(7, FALSE) } else { ch <- fastr.channel.create(1L); cx <- fastr.context.create("SHARED_NOTHING"); fastr.context.spawn(cx, "ch <- fastr.channel.get(1L); env<-fastr.channel.receive(ch); assign('y', 7, pos=env); fastr.channel.send(ch, y)"); fastr.channel.send(ch, .GlobalEnv); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); list(x, exists('y')) } -[[1]] -[1] 7 - -[[2]] -[1] FALSE - - -##com.oracle.truffle.r.test.library.fastr.TestChannels.testChannels -#if (length(grep("FastR", R.Version()$version.string)) != 1) { list(7, FALSE) } else { ch <- fastr.channel.create(1L); cx <- fastr.context.create("SHARED_NOTHING"); fastr.context.spawn(cx, "ch <- fastr.channel.get(1L); msg<-fastr.channel.receive(ch); env<-attr(attr(msg, 'LIST'), 'GLOBAL'); assign('y', 7, pos=env); fastr.channel.send(ch, y)"); l2<-list(c(42)); l<-list(c(7)); attr(l, 'GLOBAL')<-.GlobalEnv; attr(l2, 'LIST')<-l; fastr.channel.send(ch, l2); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); list(x, exists('y')) } -[[1]] -[1] 7 - -[[2]] -[1] FALSE - - -##com.oracle.truffle.r.test.library.fastr.TestChannels.testChannels -#if (length(grep("FastR", R.Version()$version.string)) != 1) { list(7, FALSE) } else { ch <- fastr.channel.create(1L); cx <- fastr.context.create("SHARED_NOTHING"); fastr.context.spawn(cx, "ch <- fastr.channel.get(1L); msg<-fastr.channel.receive(ch); env<-attr(msg, 'GLOBAL'); assign('y', 7, pos=env); fastr.channel.send(ch, y)"); l<-list(c(42)); attr(l, 'GLOBAL')<-.GlobalEnv; fastr.channel.send(ch, l); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); list(x, exists('y')) } -[[1]] -[1] 7 - -[[2]] -[1] FALSE - - -##com.oracle.truffle.r.test.library.fastr.TestChannels.testChannels -#if (length(grep("FastR", R.Version()$version.string)) != 1) { print(c(7L, 42L)) } else { ch <- fastr.channel.create(1L); cx <- fastr.context.create("SHARED_NOTHING"); fastr.context.spawn(cx, "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); x[1]<-7; fastr.channel.send(ch, x)"); y<-c(42); fastr.channel.send(ch, y); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); print(c(x,y)) } -[1] 7 42 - -##com.oracle.truffle.r.test.library.fastr.TestChannels.testChannels -#if (length(grep("FastR", R.Version()$version.string)) != 1) { print(list(7L, 42L)) } else { ch <- fastr.channel.create(1L); cx <- fastr.context.create("SHARED_NOTHING"); fastr.context.spawn(cx, "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); x[1][1]<-7; fastr.channel.send(ch, x)"); y<-list(c(42)); fastr.channel.send(ch, y); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); print(c(x,y)) } -[[1]] -[1] 7 - -[[2]] -[1] 42 - - ##com.oracle.truffle.r.test.library.fastr.TestInteropEval.testInteropEval #if (length(grep("FastR", R.Version()$version.string)) != 1) { 16 } else { Interop.eval('application/x-r', '14 + 2') } [1] 16 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java index c91d37953d692a301170b2b85dfb9760ef4eb793..a089f96f36a1acab73b792cd839bdb55b485b280 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java @@ -39,7 +39,7 @@ import com.oracle.truffle.r.runtime.REnvVars; * Base class for all Java test suites (in the sense of JUnit Java files) * that want to run R tests stored in the file system as R sources. * It is expected that R test source files will be stored in the R sub-directory - * of the directory containing a given JUnit Java file. + * of a directory stored in com.oracle.truffle.r.test/src/com/oracle/truffle/r/test * * The first line of the file may contain some configuration information (as an R comment). * At this point, two keywords are recognized - ContainsError and ContansWarning. Including diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rank.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rank.java index 5cbddabc5a2cc1f56ebc50111de7c88d15a30672..527d4ad2231936c55766ea78b30bde75545f6ac6 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rank.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_rank.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2012-2014, Purdue University - * Copyright (c) 2013, 2015, Oracle and/or its affiliates + * Copyright (c) 2013, 2016, Oracle and/or its affiliates * * All rights reserved. */ diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_withVisible.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_withVisible.java new file mode 100644 index 0000000000000000000000000000000000000000..aa1ea46128c0435d2e80f6014686d621b19bd22f --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_withVisible.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016, 2016, 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.*; + +import com.oracle.truffle.r.test.*; + +public class TestBuiltin_withVisible extends TestBase { + + @Test + public void testwithVisible() { + assertEval("withVisible()"); + assertEval("withVisible(1)"); + assertEval("withVisible(x <- 1)"); + assertEval("withVisible({ x <- 1; 1 })"); + assertEval("withVisible({ 1; x <- 1 })"); + assertEval("f <- function(x) { foo <- 1 + x }; withVisible(f(1))"); + assertEval("f <- function(x) { 1 + x }; withVisible(f(1))"); + } +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels1.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels1.R new file mode 100644 index 0000000000000000000000000000000000000000..150135ebf6d05f269e72d1a419daf98f417952e7 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels1.R @@ -0,0 +1,16 @@ +# test remote updated of atomic vector (must stay private) + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); x[1]<-7; fastr.channel.send(ch, x)" + fastr.context.spawn(cx, code) + y<-c(42) + fastr.channel.send(ch, y) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(c(x,y)) +} else { + print(c(7L, 42L)) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels2.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels2.R new file mode 100644 index 0000000000000000000000000000000000000000..6f256ba1edc098ad5cc5df234914db9744c0e4cb --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels2.R @@ -0,0 +1,16 @@ +# test remote update of a list containing atomic vector (must stay private) + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); x[1][1]<-7; fastr.channel.send(ch, x)" + fastr.context.spawn(cx, code) + y<-list(c(42)) + fastr.channel.send(ch, y) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(c(x,y)) +} else { + print(list(7L, 42L)) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels3.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels3.R new file mode 100644 index 0000000000000000000000000000000000000000..895a598caba26bccfebf63a324eb89771daf1130 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels3.R @@ -0,0 +1,16 @@ +# test sending a function + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); f<-fastr.channel.receive(ch); x<-f(7); fastr.channel.send(ch, x)" + fastr.context.spawn(cx, code) + mul<-function(y) y*y + fastr.channel.send(ch, mul) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(x) +} else { + print(49) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels4.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels4.R new file mode 100644 index 0000000000000000000000000000000000000000..91279d5a4196b5a0652a0ec6bb1a1666df720faa --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels4.R @@ -0,0 +1,15 @@ +# test sending global environment and assigning it remotely (should assign remotely but not locally) + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); env<-fastr.channel.receive(ch); assign('y', 7, pos=env); fastr.channel.send(ch, y)" + fastr.context.spawn(cx, code) + fastr.channel.send(ch, .GlobalEnv) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(list(x, exists('y'))) +} else { + print(list(7, FALSE)) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels5.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels5.R new file mode 100644 index 0000000000000000000000000000000000000000..668e4c70eacb13a8a6275b220368e76f610692df --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels5.R @@ -0,0 +1,17 @@ +# test sending global environment as an attribute and assigning it remotely (should assign remotely but not locally) + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); msg<-fastr.channel.receive(ch); env<-attr(msg, 'GLOBAL'); assign('y', 7, pos=env); fastr.channel.send(ch, y)" + fastr.context.spawn(cx, code) + l<-list(c(42)) + attr(l, 'GLOBAL')<-.GlobalEnv + fastr.channel.send(ch, l) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(list(x, exists('y'))) +} else { + print(list(7, FALSE)) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels6.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels6.R new file mode 100644 index 0000000000000000000000000000000000000000..7f22a1c85ebf803fabafd657b3ce55d2a889ef55 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels6.R @@ -0,0 +1,21 @@ +# test sending global environment as a nested attribute (an attribute of a list which is an attribute +# of another list) and assigning it remotely (should assign remotely but not locally) + + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); msg<-fastr.channel.receive(ch); env<-attr(attr(msg, 'LIST'), 'GLOBAL'); assign('y', 7, pos=env); fastr.channel.send(ch, y)" + fastr.context.spawn(cx, code) + l2<-list(c(42)) + l<-list(c(7)) + attr(l, 'GLOBAL')<-.GlobalEnv + attr(l2, 'LIST')<-l + fastr.channel.send(ch, l2) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(list(x, exists('y'))) +} else { + print(list(7, FALSE)) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels7.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels7.R new file mode 100644 index 0000000000000000000000000000000000000000..51569a1cd887cd0da946160879a6b23d2a3b4941 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels7.R @@ -0,0 +1,17 @@ +# test remote vector transfer for read - should use the same vector + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); y<-x[1]; z<-fastr.identity(x); fastr.channel.send(ch, z)" + fastr.context.spawn(cx, code) + y<-c(7, 42) + z<-fastr.identity(y) + fastr.channel.send(ch, y) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(x == z) +} else { + print(TRUE) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels8.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels8.R new file mode 100644 index 0000000000000000000000000000000000000000..36460b93c8973f1224521b963b93faa88a50e5e0 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels8.R @@ -0,0 +1,17 @@ +# test remote list transfer for read - should use the same vector elements + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); y<-x[[1]][1]; z<-fastr.identity(x[[1]]); fastr.channel.send(ch, z)" + fastr.context.spawn(cx, code) + y<-list(c(7, 42), 1) + z<-fastr.identity(y[[1]]) + fastr.channel.send(ch, y) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(x == z) +} else { + print(TRUE) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels9.R b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels9.R new file mode 100644 index 0000000000000000000000000000000000000000..c4337f2bbcb4cb266de222ce45edb9e8c46ee495 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels9.R @@ -0,0 +1,19 @@ +# test remote list transfer for read - should use the same vector elements despite non-sharable content +# also in the list + +if (length(grep("FastR", R.Version()$version.string)) == 1) { + ch <- fastr.channel.create(1L) + cx <- fastr.context.create("SHARED_NOTHING") + code <- "ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); y<-x[[1]][1]; z<-c(fastr.identity(x[[1]]), fastr.identity(x[[2]])) ; fastr.channel.send(ch, z)" + fastr.context.spawn(cx, code) + y<-list(c(7, 42), function(x) 1) + z<-fastr.identity(y[[1]]) + w<-fastr.identity(y[[2]]) + fastr.channel.send(ch, y) + x<-fastr.channel.receive(ch) + fastr.context.join(cx) + fastr.channel.close(ch) + print(c(x[1] == z, x[2] == w)) +} else { + print(c(TRUE, FALSE)) +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestChannels.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestChannels.java index 0468d7f24709feb665c1338b1a9d40c1f547ab49..5aba93b23a16fac465a256714c3fd24198ebf78b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestChannels.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestChannels.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -22,37 +22,13 @@ */ package com.oracle.truffle.r.test.library.fastr; -import org.junit.*; - import com.oracle.truffle.r.test.*; -// Checkstyle: stop line length check -public class TestChannels extends TestBase { - - @Test - public void testChannels() { - // test remote updated of atomic vector (must stay private) - assertEvalFastR("{ ch <- fastr.channel.create(1L); cx <- fastr.context.create(\"SHARED_NOTHING\"); fastr.context.spawn(cx, \"ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); x[1]<-7; fastr.channel.send(ch, x)\"); y<-c(42); fastr.channel.send(ch, y); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); print(c(x,y)) }", - "print(c(7L, 42L))"); - // test remote update of a list containing atomic vector (must stay private) - assertEvalFastR("{ ch <- fastr.channel.create(1L); cx <- fastr.context.create(\"SHARED_NOTHING\"); fastr.context.spawn(cx, \"ch <- fastr.channel.get(1L); x<-fastr.channel.receive(ch); x[1][1]<-7; fastr.channel.send(ch, x)\"); y<-list(c(42)); fastr.channel.send(ch, y); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); print(c(x,y)) }", - "print(list(7L, 42L))"); - // test sending a function - assertEvalFastR("{ ch <- fastr.channel.create(1L); cx <- fastr.context.create(\"SHARED_NOTHING\"); fastr.context.spawn(cx, \"ch <- fastr.channel.get(1L); f<-fastr.channel.receive(ch); x<-f(7); fastr.channel.send(ch, x)\"); mul<-function(y) y*y; fastr.channel.send(ch, mul); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); x }", - "49"); - // test sending global environment and assigning it remotely (should assign remotely but not - // locally) - assertEvalFastR("{ ch <- fastr.channel.create(1L); cx <- fastr.context.create(\"SHARED_NOTHING\"); fastr.context.spawn(cx, \"ch <- fastr.channel.get(1L); env<-fastr.channel.receive(ch); assign('y', 7, pos=env); fastr.channel.send(ch, y)\"); fastr.channel.send(ch, .GlobalEnv); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); list(x, exists('y')) }", - "list(7, FALSE)"); - // test sending global environment as an attribute and assigning it remotely (should assign - // remotely but not locally) - assertEvalFastR("{ ch <- fastr.channel.create(1L); cx <- fastr.context.create(\"SHARED_NOTHING\"); fastr.context.spawn(cx, \"ch <- fastr.channel.get(1L); msg<-fastr.channel.receive(ch); env<-attr(msg, 'GLOBAL'); assign('y', 7, pos=env); fastr.channel.send(ch, y)\"); l<-list(c(42)); attr(l, 'GLOBAL')<-.GlobalEnv; fastr.channel.send(ch, l); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); list(x, exists('y')) }", - "list(7, FALSE)"); - // test sending global environment as a nested attribute (an attribute of a list which is an - // attribute of another list) and assigning it remotely (should assign remotely but not - // locally) - assertEvalFastR("{ ch <- fastr.channel.create(1L); cx <- fastr.context.create(\"SHARED_NOTHING\"); fastr.context.spawn(cx, \"ch <- fastr.channel.get(1L); msg<-fastr.channel.receive(ch); env<-attr(attr(msg, 'LIST'), 'GLOBAL'); assign('y', 7, pos=env); fastr.channel.send(ch, y)\"); l2<-list(c(42)); l<-list(c(7)); attr(l, 'GLOBAL')<-.GlobalEnv; attr(l2, 'LIST')<-l; fastr.channel.send(ch, l2); x<-fastr.channel.receive(ch); fastr.context.join(cx); fastr.channel.close(ch); list(x, exists('y')) }", - "list(7, FALSE)"); +public class TestChannels extends TestRBase { + @Override + public String getTestDir() { + return "channels"; } + }