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

Merge pull request #660 in G/fastr from...

Merge pull request #660 in G/fastr from ~LUKAS.STADLER_ORACLE.COM/fastr:feature/meta_tck_tests to master

* commit 'e3853c46':
  implement TCK tests for findMetaObject and findSourceLocation
parents 830e5466 e3853c46
No related branches found
No related tags found
No related merge requests found
......@@ -155,18 +155,20 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> {
@Override
protected Object findMetaObject(RContext context, Object value) {
String ret = "Object";
if (value instanceof RPromise) {
RPromise promise = (RPromise) value;
Object unwrappedValue = value;
if (unwrappedValue instanceof RPromise) {
RPromise promise = (RPromise) unwrappedValue;
if (promise.isEvaluated()) {
value = promise.getValue();
unwrappedValue = promise.getValue();
}
}
value = RRuntime.asAbstractVector(value); // Wrap scalars "Integer", "Double" etc.
if (value instanceof RTypedValue) {
ret = ((RTypedValue) value).getRType().getName();
unwrappedValue = RRuntime.asAbstractVector(unwrappedValue); // Wrap scalars "Integer",
// "Double" etc.
if (unwrappedValue instanceof RTypedValue) {
return ((RTypedValue) unwrappedValue).getRType().getName();
} else {
return "Object";
}
return ret;
}
@Override
......
......@@ -134,6 +134,19 @@ public class FastRTckTest extends TruffleTCK {
"isExecutableOfForeign <- function(o) {\n" +
" .fastr.interop.toBoolean(.fastr.interop.isExecutable(o))\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",
RSource.Internal.TCK_INIT
);
......@@ -473,12 +486,16 @@ public class FastRTckTest extends TruffleTCK {
@Override
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
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.
Finish editing this message first!
Please register or to comment