Skip to content
Snippets Groups Projects
Commit 461c62c8 authored by Zbynek Slajchrt's avatar Zbynek Slajchrt
Browse files

A couple of tests added

parent e541a5a2
No related branches found
No related tags found
No related merge requests found
......@@ -117,12 +117,14 @@ public class FastRInterop {
File file = new File(path);
try {
Builder<IOException, RuntimeException, RuntimeException> sourceBuilder = Source.newBuilder(file).name("").internal();
Builder<IOException, RuntimeException, RuntimeException> sourceBuilder = Source.newBuilder(file).name(file.getName()).internal();
if (mimeType != null) {
sourceBuilder.mimeType(mimeType);
}
Source sourceObject = sourceBuilder.build();
return RContext.getInstance().getEnv().parse(sourceObject);
} catch (IOException e) {
throw RError.error(this, Message.GENERIC, "Error reading file: " + e.getMessage());
} catch (Throwable t) {
throw RError.error(this, Message.GENERIC, "Error while parsing: " + t.getMessage());
}
......
......@@ -4180,7 +4180,7 @@ build FALSE FALSE FALSE FALSE
install FALSE FALSE FALSE FALSE
render FALSE FALSE FALSE FALSE
 
##com.oracle.truffle.r.test.builtins.TestBuiltin_array.testarray11#Ignored.Unknown#
##com.oracle.truffle.r.test.builtins.TestBuiltin_array.testarray11#
#argv <- list(list(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), 8L, list(c('1', '2', '3', '4', '5', '6', '7', '8'))); .Internal(array(argv[[1]], argv[[2]], argv[[3]]))
$`1`
NULL
......@@ -22651,7 +22651,7 @@ attr(,"Rd_tag")
#argv <- list(structure('BunchKaufman', class = structure('signature', package = 'methods'), .Names = 'x', package = 'methods'), structure('Matrix', .Names = 'x', package = 'Matrix', class = structure('signature', package = 'methods')), TRUE, TRUE, TRUE, TRUE, FALSE); .Internal(identical(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]], argv[[6]], argv[[7]]))
[1] FALSE
 
##com.oracle.truffle.r.test.builtins.TestBuiltin_identical.testidentical28#Ignored.Unknown#
##com.oracle.truffle.r.test.builtins.TestBuiltin_identical.testidentical28#Ignored.Unstable#
#argv <- list(structure(list(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), y = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), fac = structure(c(1L, 3L, 2L, 3L, 3L, 1L, 2L, 3L, 2L, 2L), .Label = c('A', 'B', 'C'), class = 'factor')), .Names = c('x', 'y', 'fac'), row.names = c(NA, -10L), class = 'data.frame'), structure(list(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), y = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), fac = structure(c(1L, 3L, 2L, 3L, 3L, 1L, 2L, 3L, 2L, 2L), .Label = c('A', 'B', 'C'), class = 'factor')), .Names = c('x', 'y', 'fac'), row.names = c(NA, 10L), class = 'data.frame'), TRUE, TRUE, TRUE, TRUE, FALSE); .Internal(identical(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]], argv[[6]], argv[[7]]))
[1] TRUE
 
......@@ -48446,7 +48446,7 @@ Error: unexpected symbol in "argv <- list(c('* Edit the help file skeletons in '
[20] "," " "
 
 
##com.oracle.truffle.r.test.builtins.TestBuiltin_strsplit.teststrsplit3#Ignored.Unknown#
##com.oracle.truffle.r.test.builtins.TestBuiltin_strsplit.teststrsplit3#
#argv <- list(' \036 isSeekable() now returns FALSE on connections which have non-default encoding. Although documented to record if ‘in principle’ the connection supports seeking, it seems safer to report FALSE when it may not work.', '[ \t\n]', FALSE, TRUE, FALSE); .Internal(strsplit(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]]))
[[1]]
[1] "" "" "\036" "" "isSeekable()"
......@@ -52760,7 +52760,7 @@ $lrow
attr(,"row.names")
[1] 1
 
##com.oracle.truffle.r.test.builtins.TestBuiltin_unclass.testunclass26#Ignored.Unknown#
##com.oracle.truffle.r.test.builtins.TestBuiltin_unclass.testunclass26#
#argv <- list(structure(list(a = 1), .Dim = 1L, .Dimnames = list('a')));unclass(argv[[1]]);
$a
[1] 1
......@@ -111313,6 +111313,16 @@ a b c d e
#if (length(grep("FastR", R.Version()$version.string)) != 1) { as.character(123) } else { .fastr.interop.eval('application/x-r', 'as.character(123)') }
[1] "123"
 
##com.oracle.truffle.r.test.library.fastr.TestInterop.testInteropEvalFile#
#if (length(grep("FastR", R.Version()$version.string)) != 1) { cat('[1] "Error reading file: /a/b.R"\n') } else { tryCatch(.fastr.interop.evalFile("/a/b.R"), error = function(e) e$message) }
[1] "Error reading file: /a/b.R"
##com.oracle.truffle.r.test.library.fastr.TestInterop.testInteropEvalFile#
#if (length(grep("FastR", R.Version()$version.string)) != 1) { x<-c(1);cat(x) } else { fileConn<-file("testScript.R");writeLines(c("x<-c(1)","cat(x)"), fileConn);close(fileConn);.fastr.interop.evalFile("testScript.R") }
1
##com.oracle.truffle.r.test.library.fastr.TestInterop.testInteropEvalFile#
#if (length(grep("FastR", R.Version()$version.string)) != 1) { x<-c(1);cat(x) } else { fileConn<-file("testScript.R");writeLines(c("x<-c(1)","cat(x)"), fileConn);close(fileConn);.fastr.interop.evalFile("testScript.R","application/x-r") }
1
##com.oracle.truffle.r.test.library.fastr.TestInterop.testInteropExport#
#if (length(grep("FastR", R.Version()$version.string)) != 1) { invisible() } else { .fastr.interop.export('foo', 'foo') }
 
......@@ -111470,7 +111480,7 @@ In rbinom("aa", 10, 0.5) : NAs introduced by coercion
#set.seed(42); rbinom(c(1,2), 11:12, c(0.1, 0.5, 0.9))
[1] 3 9
 
##com.oracle.truffle.r.test.library.stats.TestExternal_rnbinom.testRbinomWithMu#Ignored.Unimplemented#
##com.oracle.truffle.r.test.library.stats.TestExternal_rnbinom.testRbinomWithMu#Ignored.Unstable#
#set.seed(42); rnbinom(100, c(-1, 0, 1, 0.8, 10, NA, NaN, 1/0, -1/0), mu=c(-1, 0, 1, 0.8, 3, 10, NA, NaN, 1/0, -1/0))
[1] NaN NaN 1 1 4 NaN NaN NaN NaN NaN NaN 0 0 0 NaN NaN NaN NaN
[19] NaN NaN NaN 0 0 NaN NaN 5 NaN NaN NaN NaN NaN 0 NaN NaN 5 NaN
......@@ -47,6 +47,14 @@ public class TestInterop extends TestBase {
assertEvalFastR(".fastr.interop.export('foo', new.env())", "invisible()");
}
@Test
public void testInteropEvalFile() {
assertEvalFastR("fileConn<-file(\"testScript.R\");writeLines(c(\"x<-c(1)\",\"cat(x)\"), fileConn);close(fileConn);.fastr.interop.evalFile(\"testScript.R\",\"application/x-r\")",
"x<-c(1);cat(x)");
assertEvalFastR("fileConn<-file(\"testScript.R\");writeLines(c(\"x<-c(1)\",\"cat(x)\"), fileConn);close(fileConn);.fastr.interop.evalFile(\"testScript.R\")", "x<-c(1);cat(x)");
assertEvalFastR("tryCatch(.fastr.interop.evalFile(\"/a/b.R\"), error = function(e) e$message)", "cat('[1] \"Error reading file: /a/b.R\"\\n')");
}
/**
* Used for testing interop functionality.
*/
......
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