Skip to content
Snippets Groups Projects
Commit 8e191956 authored by Tomas Stupka's avatar Tomas Stupka
Browse files

replaced FastRTckTest with c.o.truffle.r.test.tck

parent 821f05a3
No related branches found
No related tags found
No related merge requests found
Showing
with 619 additions and 507 deletions
......@@ -246,15 +246,18 @@ public class ExtractVectorNodeTest extends TestBase {
@Theory
public void testCompletenessAfterExtraction(RType targetType) {
RAbstractVector vector = generateVector(targetType, 4, false);
execInContext(() -> {
RAbstractVector vector = generateVector(targetType, 4, false);
assumeTrue(targetType != RType.List);
assumeThat(vector.isComplete(), is(false));
// extract some non NA elements
int[] positions = targetType == RType.Complex ? new int[]{1, 3} : new int[]{1, 2};
RAbstractVector result = executeExtract(ElementAccessMode.SUBSET, vector, RDataFactory.createIntVector(positions, true));
assumeTrue(targetType != RType.List);
assumeThat(vector.isComplete(), is(false));
// extract some non NA elements
int[] positions = targetType == RType.Complex ? new int[]{1, 3} : new int[]{1, 2};
RAbstractVector result = executeExtract(ElementAccessMode.SUBSET, vector, RDataFactory.createIntVector(positions, true));
assertThat(result.isComplete(), is(true));
assertThat(result.isComplete(), is(true));
return null;
});
}
@Theory
......
com.oracle.truffle.r.test.tck.RTCKLanguageProvider
fib_fun <- function(n) {
if (n < 2) {
return(n)
} else {
return(fib_fun(n - 1) + fib_fun(n - 2))
}
}
function() {
return (fib_fun(20))
}
function() {
TRUE
mandel_fun = function(z) {
c = z
maxiter = 80
for (n in 1:maxiter) {
if (Mod(z) > 2) return(n-1)
z = z^2+c
}
return(maxiter)
}
Mandel = function(x) {
re = seq(-2,0.5,.1)
im = seq(-1,1,.1)
M = matrix(0.0,nrow=length(re),ncol=length(im))
count = 1
for (r in re) {
for (i in im) {
M[count] = mandel_fun(complex(real=r,imag=i))
count = count + 1
}
}
return(sum(M))
}
function() {
return (Mandel(c()))
}
PiSum <- function(x) {
t = 0.0
for (j in 1:500) {
t = 0.0
for (k in 1:10000) {
t = t + 1.0/(k*k)
}
}
return(abs(t-1.644834071848065) < 1e-12)
}
function() {
return(PiSum(c()));
}
qsort = function(a) {
qsort_kernel = function(lo, hi) {
i = lo
j = hi
while (i < hi) {
pivot = a[floor((lo+hi)/2)]
while (i <= j) {
while (a[i] < pivot) i = i + 1
while (a[j] > pivot) j = j - 1
if (i <= j) {
t = a[i]
a[i] <<- a[j]
a[j] <<- t
i = i + 1;
j = j - 1;
}
}
if (lo < j) qsort_kernel(lo, j)
lo = i
j = hi
}
}
qsort_kernel(1, length(a))
return(a)
}
Quicksort = function(n) {
v = runif(n)
result = qsort(v)
return (!is.unsorted(result))
}
function () {
Quicksort(1000);
}
RandMatMul <- function(n) {
A <- matrix(runif(n*n), ncol=n, nrow=n)
B <- matrix(runif(n*n), ncol=n, nrow=n)
result <- A %*% B
return (all(result >= 0))
}
function() {
return (RandMatMul(100))
}
RandMatStat = function(t) {
set.seed(10)
n = 5
v = matrix(0, nrow=t)
w = matrix(0, nrow=t)
for (i in 1:t) {
a = matrix(rnorm(n*n), ncol=n, nrow=n)
b = matrix(rnorm(n*n), ncol=n, nrow=n)
c = matrix(rnorm(n*n), ncol=n, nrow=n)
d = matrix(rnorm(n*n), ncol=n, nrow=n)
P = cbind(a,b,c,d)
Q = rbind(cbind(a,b),cbind(c,d))
v[i] = sum(diag((t(P)%*%P)^4))
w[i] = sum(diag((t(Q)%*%Q)^4))
}
s1 = apply(v,2,sd)/mean(v)
s2 = apply(w,2,sd)/mean(w)
return (round(s1, digits=7) == 0.8324299 && round(s2, digits=7) == 0.7440433)
}
function() {
return (RandMatStat(1000))
}
/*
* Copyright (c) 2015, 2017, 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.tck;
public class FastRTckTest /* extends TruffleTCK */ {
// disabled
// @Test
// public void testVerifyPresence() {
// PolyglotEngine vm = PolyglotEngine.newBuilder().build();
// assertTrue("Our language is present", vm.getLanguages().containsKey("text/x-r"));
// }
//
// // @formatter:off
// private static final String INITIALIZATION_CODE =
// "fourtyTwo <- function() {\n" +
// " 42L\n" +
// "}\n" +
// "plus <- function(a, b) {\n" +
// " a + b\n" +
// "}\n" +
// "identity <- function(a) {\n" +
// " a\n" +
// "}\n" +
// "apply <- function(f) {\n" +
// " f(18L, 32L) + 10L\n" +
// "}\n" +
// "null <- function() {\n" +
// " NULL\n" +
// "}\n" +
// "counter <- 0L\n" +
// "count <- function() {\n" +
// " counter <<- counter + 1L\n" +
// "}\n" +
// "complexAdd <- function(a, b) {\n" +
// " a$imaginary <- a$imaginary + b$imaginary\n" +
// " a$real <- a$real + b$real\n" +
// "}\n" +
// "countUpWhile <- function(fn) {\n" +
// " counter <- 0\n" +
// " while (T) {\n" +
// " if (!fn(counter)) {\n" +
// " break\n" +
// " }\n" +
// " counter <- counter + 1\n" +
// " }\n" +
// "}\n" +
// "complexSumReal <- function(a) {\n" +
// " sum <- 0\n" +
// " for (i in 1:length(a)) {\n" +
// " sum <- sum + a[i]$real\n" +
// " }\n" +
// " return(sum)\n" +
// "}\n" +
// "complexCopy <- function(a, b) {\n" +
// " for (i in 0:(length(b)-1)) {\n" +
// " a[i]$real <- b[i]$real\n" +
// " a[i]$imaginary <- b[i]$imaginary\n" +
// " }\n" +
// "}\n" +
// "valuesObject <- function() {\n" +
// " list('byteValue'=0L, 'shortValue'=0L, 'intValue'=0L, 'longValue'=0L, 'floatValue'=0, 'doubleValue'=0, 'charValue'=48L, 'stringValue'='', 'booleanValue'=FALSE)\n" +
// "}\n" +
// "addNumbersFunction <- function() {\n" +
// " function(a, b) a + b\n" +
// "}\n" +
// "objectWithValueProperty <- function() {\n" +
// " list(value = 42L)\n" +
// "}\n" +
// "callFunction <- function(f) {\n" +
// " f(41L, 42L)\n" +
// "}\n" +
// "objectWithElement <- function(f) {\n" +
// " c(0L, 0L, 42L, 0L)\n" +
// "}\n" +
// "objectWithValueAndAddProperty <- function(f) {\n" +
// " e <- new.env()\n" +
// " e$value <- 0L\n" +
// " e$add <- function(inc) { e$value <- e$value + inc; e$value }\n" +
// " e\n" +
// "}\n" +
// "callMethod <- function(f) {\n" +
// " f(41L, 42L)\n" +
// "}\n" +
// "readElementFromForeign <- function(f) {\n" +
// " f[[3L]]\n" +
// "}\n" +
// "writeElementToForeign <- function(f) {\n" +
// " f[[3L]] <- 42L\n" +
// "}\n" +
// "readValueFromForeign <- function(o) {\n" +
// " o$value\n" +
// "}\n" +
// "writeValueToForeign <- function(o) {\n" +
// " o$value <- 42L\n" +
// "}\n" +
// "getSizeOfForeign <- function(o) {\n" +
// " length(o)\n" +
// "}\n" +
// "isNullOfForeign <- function(o) {\n" +
// " .fastr.interop.toBoolean(is.external.null(o))\n" +
// "}\n" +
// "hasSizeOfForeign <- function(o) {\n" +
// " .fastr.interop.toBoolean(is.external.array(o))\n" +
// "}\n" +
// "isExecutableOfForeign <- function(o) {\n" +
// " .fastr.interop.toBoolean(is.external.executable(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" +
// "objectWithKeyInfoAttributes <- function() { list(rw=1, invocable=function(){ 'invoked' }) }\n" +
// "for (name in ls()) export(name, get(name))\n";
// // @formatter:on
//
// private static final Source INITIALIZATION =
// Source.newBuilder(INITIALIZATION_CODE).name("TCK").mimeType(RRuntime.R_APP_MIME).build();
//
// @Override
// protected PolyglotEngine prepareVM(Builder builder) throws Exception {
// PolyglotEngine engine = builder.build();
// engine.eval(INITIALIZATION).get();
// return engine;
// }
//
// @Override
// protected String mimeType() {
// return "text/x-r";
// }
//
// @Override
// protected String fourtyTwo() {
// return "fourtyTwo";
// }
//
// @Override
// protected String plusInt() {
// return "plus";
// }
//
// @Override
// protected String identity() {
// return "identity";
// }
//
// @Override
// protected String returnsNull() {
// return "null";
// }
//
// @Override
// protected String applyNumbers() {
// return "apply";
// }
//
// @Override
// protected String countInvocations() {
// return "count";
// }
//
// @Override
// protected String complexAdd() {
// return "complexAdd";
// }
//
// @Override
// protected String complexSumReal() {
// return "complexSumReal";
// }
//
// @Override
// protected String complexCopy() {
// return "complexCopy";
// }
//
// @Override
// protected String invalidCode() {
// return "main <- function() {\n";
// }
//
// @Override
// protected String valuesObject() {
// return "valuesObject";
// }
//
// @Override
// protected String countUpWhile() {
// return "countUpWhile";
// }
//
// @Override
// protected String addToArray() {
// // TODO not yet supported
// return null;
// }
//
// @Override
// protected String getSizeOfForeign() {
// return "getSizeOfForeign";
// }
//
// @Override
// protected String isNullForeign() {
// return "isNullOfForeign";
// }
//
// @Override
// protected String hasSizeOfForeign() {
// return "hasSizeOfForeign";
// }
//
// @Override
// protected String isExecutableOfForeign() {
// return "isExecutableOfForeign";
// }
//
// @Override
// protected String readValueFromForeign() {
// return "readValueFromForeign";
// }
//
// @Override
// protected String writeValueToForeign() {
// return "writeValueToForeign";
// }
//
// @Override
// protected String callFunction() {
// return "callFunction";
// }
//
// @Override
// protected String objectWithElement() {
// return "objectWithElement";
// }
//
// @Override
// protected String objectWithValueAndAddProperty() {
// return "objectWithValueAndAddProperty";
// }
//
// @Override
// protected String callMethod() {
// return "callMethod";
// }
//
// @Override
// protected String readElementFromForeign() {
// return "readElementFromForeign";
// }
//
// @Override
// protected String writeElementToForeign() {
// return "writeElementToForeign";
// }
//
// @Override
// protected String objectWithValueProperty() {
// return "objectWithValueProperty";
// }
//
// @Override
// protected String functionAddNumbers() {
// return "addNumbersFunction";
// }
//
// @Override
// public void readWriteBooleanValue() throws Exception {
// // TODO not yet supported
// }
//
// @Override
// public void readWriteCharValue() throws Exception {
// // TODO not yet supported
// }
//
// @Override
// public void readWriteShortValue() throws Exception {
// // TODO not yet supported
// }
//
// @Override
// public void readWriteByteValue() throws Exception {
// // TODO not yet supported
// }
//
// @Override
// public void readWriteFloatValue() throws Exception {
// // TODO not yet supported
// }
//
// @Override
// public void testAddComplexNumbersWithMethod() throws Exception {
// // TODO not yet supported
// }
//
// @Override
// @Test
// public void testNull() {
// // disabled because we don't provide a Java "null" value in R
// }
//
// @Override
// @Test
// public void testNullInCompoundObject() {
// // disabled because we don't provide a Java "null" value in R
// }
//
// @Override
// @Test
// public void testPlusWithIntsOnCompoundObject() throws Exception {
// // TODO support this test case.
// }
//
// @Override
// @Test
// public void testMaxOrMinValue() throws Exception {
// // TODO support this test case.
// }
//
// @Override
// @Test
// public void testMaxOrMinValue2() throws Exception {
// // TODO support this test case.
// }
//
// @Override
// @Test
// public void testFortyTwoWithCompoundObject() throws Exception {
// // TODO support this test case.
// }
//
// @Override
// public void testPlusWithFloat() throws Exception {
// // no floats in FastR
// }
//
// @Override
// public void testPrimitiveReturnTypeFloat() throws Exception {
// // no floats in FastR
// }
//
// @Override
// public void testPlusWithOneNegativeShort() throws Exception {
// // no floats in FastR
// }
//
// @Override
// public void testPlusWithDoubleFloatSameAsInt() throws Exception {
// // no floats in FastR
// }
//
// @Override
// public void testPlusWithLongMaxIntMinInt() throws Exception {
// // no longs in FastR
// }
//
// @Override
// public void testPlusWithLong() throws Exception {
// // no longs in FastR
// }
//
// @Override
// public void testPrimitiveReturnTypeLong() throws Exception {
// // no longs in FastR
// }
//
// @Override
// public void testPlusWithBytes() throws Exception {
// // no bytes in FastR
// }
//
// @Override
// public void testPlusWithOneNegativeByte() throws Exception {
// // no bytes in FastR
// }
//
// @Override
// public void testPlusWithShort() throws Exception {
// // no shorts in FastR
// }
//
// @Override
// public void testPrimitiveReturnTypeShort() throws Exception {
// // no shorts in FastR
// }
//
// @Override
// public void testGlobalObjectIsAccessible() throws Exception {
// // no global object in fastr.
// }
//
// @Override
// public void testNullCanBeCastToAnything() throws Exception {
// // TODO support
// }
//
// @Override
// public void multiplyTwoVariables() throws Exception {
// // TODO support
// }
//
// @Override
// public void testEvaluateSource() throws Exception {
// // TODO support
// }
//
// @Override
// public void testCopyComplexNumbersA() {
// // TODO determine the semantics of assignments to a[i]$b
// }
//
// @Override
// public void testCopyComplexNumbersB() {
// // TODO determine the semantics of assignments to a[i]$b
// }
//
// @Override
// public void testCopyStructuredComplexToComplexNumbersA() {
// // TODO determine the semantics of assignments to a[i]$b
// }
//
// @Override
// public void testAddComplexNumbers() {
// // TODO determine the semantics of assignments to a[i]$b
// }
//
// @Override
// public void testWriteToObjectWithElement() throws Exception {
// // TODO mismatch between mutable and immutable data types
// }
//
// @Override
// public void testObjectWithValueAndAddProperty() throws Exception {
// // TODO mismatch between mutable and immutable data types
// }
//
// @Override
// public void testCallMethod() throws Exception {
// // R does not have method calls
// }
//
// @Override
// public String multiplyCode(String firstName, String secondName) {
// return firstName + '*' + secondName;
// }
//
// @Override
// protected String[] metaObjects() {
// return new String[]{
// "intValue", "intType", "intVectorValue", "intType", "intSequenceValue", "intType",
// "doubleValue", "doubleType", "doubleVectorValue", "doubleType", "doubleSequenceValue",
// "doubleType",
// "functionValue", "functionType",
// "builtinFunctionValue", "builtinFunctionType"};
// }
//
// @Override
// protected String valueWithSource() {
// return "valueWithSource";
// }
//
// @Override
// protected String objectWithKeyInfoAttributes() {
// return "objectWithKeyInfoAttributes";
// }
}
......@@ -316,7 +316,7 @@ def _simple_generated_unit_tests():
return map(_test_subpackage, ['engine.shell', 'engine.interop', 'library.base', 'library.grid', 'library.fastrGrid', 'library.methods', 'library.stats', 'library.tools', 'library.utils', 'library.fastr', 'builtins', 'functions', 'parser', 'rffi', 'rng', 'runtime.data', 'S4'])
def _simple_unit_tests():
return _simple_generated_unit_tests() + [_test_subpackage('tck')]
return _simple_generated_unit_tests() + ['com.oracle.truffle.tck.tests']
def _nodes_unit_tests():
return ['com.oracle.truffle.r.nodes.test', 'com.oracle.truffle.r.nodes.access.vector']
......
......@@ -29,7 +29,7 @@ suite = {
{
"name" : "truffle",
"subdir" : True,
"version" : "e3ce4c4abc668fd637e64a467a8d5b999c2fbdae",
"version" : "05b61f9fa9dceebec447f3ec3656c8cc5be215dd",
"urls" : [
{"url" : "https://github.com/graalvm/graal", "kind" : "git"},
{"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},
......@@ -324,6 +324,16 @@ suite = {
"workingSets" : "FastR",
},
"com.oracle.truffle.r.test.tck" : {
"sourceDirs" : ["src"],
"dependencies" : [
"mx:JUNIT",
"sdk:POLYGLOT_TCK",
],
"checkstyle" : "com.oracle.truffle.r.runtime",
"javaCompliance" : "1.8",
"workingSets" : "FastR,Test",
},
},
"distributions" : {
......@@ -389,6 +399,20 @@ suite = {
],
},
"TRUFFLE_R_TCK" : {
"description" : "TCK tests provider",
"dependencies" : [
"com.oracle.truffle.r.test.tck"
],
"exclude" : [
"mx:JUNIT",
],
"distDependencies" : [
"sdk:POLYGLOT_TCK",
],
"maven" : False
},
"FASTR_RELEASE<rffi>": {
"description" : "a binary release of FastR",
"dependencies" : ["com.oracle.truffle.r.release"],
......
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