From ac315f3f1f43b95c17d8f02ab49bbfd56b14e300 Mon Sep 17 00:00:00 2001 From: Michael Haupt <michael.haupt@oracle.com> Date: Thu, 30 Jan 2014 16:46:08 +0100 Subject: [PATCH] enable passing tests --- .../com/oracle/truffle/r/test/ExpectedTestOutput.test | 10 ++++++++++ .../truffle/r/test/simple/TestSimpleFunctions.java | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) 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 5cd0f73190..18c6f6335e 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 @@ -6877,6 +6877,10 @@ logical(0) #{ myapp <- function(f, x, y) { f(x,y) } ; myapp(function(x,y) { x + y }, 1, 2) ; myapp(sum, 1, 2) } [1] 3 +##com.oracle.truffle.r.test.simple.TestSimpleFunctions.testDefinitions +#x<-function(){1};x +function(){1} + ##com.oracle.truffle.r.test.simple.TestSimpleFunctions.testDefinitions #{ "%plus%" <- function(a,b) a+b ; 3 %plus% 4 } [1] 7 @@ -6885,6 +6889,12 @@ logical(0) #{ "-"(1) } [1] -1 +##com.oracle.truffle.r.test.simple.TestSimpleFunctions.testDefinitions +#{ 'my<-' <- function(x, value) { attr(x, "myattr") <- value ; x } ; z <- 1; my(z) <- "hello" ; z } +[1] 1 +attr(,"myattr") +[1] "hello" + ##com.oracle.truffle.r.test.simple.TestSimpleFunctions.testDefinitionsNamedAndDefault #{ f <- sum ; f(1:10) } [1] 55 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleFunctions.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleFunctions.java index bcde0e423c..f8b20c92dd 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleFunctions.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleFunctions.java @@ -63,22 +63,21 @@ public class TestSimpleFunctions extends TestBase { public void testDefinitions() { assertEval("{ \"%plus%\" <- function(a,b) a+b ; 3 %plus% 4 }"); assertEval("{ \"-\"(1) }"); + assertEval("x<-function(){1};x"); + + // replacement function + assertEval("{ 'my<-' <- function(x, value) { attr(x, \"myattr\") <- value ; x } ; z <- 1; my(z) <- \"hello\" ; z }"); } @Test @Ignore public void testDefinitionsIgnore() { - assertEvalNoOutput("x<-function(){1}"); - // function matching, builtins assertEval("{ x <- function(a,b) { a^b } ; f <- function() { x <- \"sum\" ; sapply(1, x, 2) } ; f() }"); assertEval("{ x <- function(a,b) { a^b } ; g <- function() { x <- \"sum\" ; f <- function() { sapply(1, x, 2) } ; f() } ; g() }"); assertEval("{ x <- function(a,b) { a^b } ; f <- function() { x <- 211 ; sapply(1, x, 2) } ; f() }"); assertEval("{ x <- function(a,b) { a^b } ; dummy <- sum ; f <- function() { x <- \"dummy\" ; sapply(1, x, 2) } ; f() }"); assertEval("{ x <- function(a,b) { a^b } ; dummy <- sum ; f <- function() { x <- \"dummy\" ; dummy <- 200 ; sapply(1, x, 2) } ; f() }"); - - // replacement function - assertEval("{ 'my<-' <- function(x, value) { attr(x, \"myattr\") <- value ; x } ; z <- 1; my(z) <- \"hello\" ; z }"); } @Test -- GitLab