Skip to content
Snippets Groups Projects
Commit e3853c46 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

implement TCK tests for findMetaObject and findSourceLocation

parent 6f714a3c
Branches
No related tags found
No related merge requests found
...@@ -155,18 +155,20 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> { ...@@ -155,18 +155,20 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> {
@Override @Override
protected Object findMetaObject(RContext context, Object value) { protected Object findMetaObject(RContext context, Object value) {
String ret = "Object"; Object unwrappedValue = value;
if (value instanceof RPromise) { if (unwrappedValue instanceof RPromise) {
RPromise promise = (RPromise) value; RPromise promise = (RPromise) unwrappedValue;
if (promise.isEvaluated()) { if (promise.isEvaluated()) {
value = promise.getValue(); unwrappedValue = promise.getValue();
} }
} }
value = RRuntime.asAbstractVector(value); // Wrap scalars "Integer", "Double" etc. unwrappedValue = RRuntime.asAbstractVector(unwrappedValue); // Wrap scalars "Integer",
if (value instanceof RTypedValue) { // "Double" etc.
ret = ((RTypedValue) value).getRType().getName(); if (unwrappedValue instanceof RTypedValue) {
return ((RTypedValue) unwrappedValue).getRType().getName();
} else {
return "Object";
} }
return ret;
} }
@Override @Override
......
...@@ -134,6 +134,19 @@ public class FastRTckTest extends TruffleTCK { ...@@ -134,6 +134,19 @@ public class FastRTckTest extends TruffleTCK {
"isExecutableOfForeign <- function(o) {\n" + "isExecutableOfForeign <- function(o) {\n" +
" .fastr.interop.toBoolean(.fastr.interop.isExecutable(o))\n" + " .fastr.interop.toBoolean(.fastr.interop.isExecutable(o))\n" +
"}\n" + "}\n" +
"intValue <- function() 42L\n" +
"intVectorValue <- function() c(42L, 40L)\n" +
"intSequenceValue <- function() 42:50\n" +
"intType <- function() 'integer'\n" +
"doubleValue <- function() 42.1\n" +
"doubleVectorValue <- function() c(42.1, 40)\n" +
"doubleSequenceValue <- function() 42.1:50\n" +
"doubleType <- function() 'double'\n" +
"functionValue <- function() { function(x) 1 }\n" +
"functionType <- function() 'closure'\n" +
"builtinFunctionValue <- function() `+`\n" +
"builtinFunctionType <- function() 'builtin'\n" +
"valueWithSource <- function() intValue\n" +
"for (name in ls()) .fastr.interop.export(name, get(name))\n", "for (name in ls()) .fastr.interop.export(name, get(name))\n",
RSource.Internal.TCK_INIT RSource.Internal.TCK_INIT
); );
...@@ -473,12 +486,16 @@ public class FastRTckTest extends TruffleTCK { ...@@ -473,12 +486,16 @@ public class FastRTckTest extends TruffleTCK {
@Override @Override
protected String[] metaObjects() { protected String[] metaObjects() {
return null; // TBD add proper impl here. return new String[]{
"intValue", "intType", "intVectorValue", "intType", "intSequenceValue", "intType",
"doubleValue", "doubleType", "doubleVectorValue", "doubleType", "doubleSequenceValue", "doubleType",
"functionValue", "functionType",
"builtinFunctionValue", "builtinFunctionType"};
} }
@Override @Override
protected String valueWithSource() { protected String valueWithSource() {
return null; // TBD add proper impl here. return "valueWithSource";
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment