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 ed03a6ef4ed6f6cfe0518fa7de055f0b0ed9eb1a..7768931c5e2f2fa0464e9e404d1d71540c1663ed 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 @@ -6285,6 +6285,27 @@ character(0) #{ toupper(c()) } character(0) +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testCol +#{ ma <- cbind(x = 1:10, y = (-4:5)^2) ; col(ma) } + [,1] [,2] + [1,] 1 2 + [2,] 1 2 + [3,] 1 2 + [4,] 1 2 + [5,] 1 2 + [6,] 1 2 + [7,] 1 2 + [8,] 1 2 + [9,] 1 2 +[10,] 1 2 + +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testCol +#{ ma <- matrix(1:12, 3, 4) ; col(ma) } + [,1] [,2] [,3] [,4] +[1,] 1 2 3 4 +[2,] 1 2 3 4 +[3,] 1 2 3 4 + ##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testColMeans #{ a = colSums(array(1:24,c(2,3,4))); colMeans(a)} [1] 7 19 31 43 @@ -8678,6 +8699,17 @@ NULL #{x <- 10;class(x) <- c("a", "b");inherits(x, c("c", "q", "b"), TRUE) ;} [1] 0 0 2 +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testInteraction +#{ a <- gl(2, 4, 8) ; b <- gl(2, 2, 8, labels = c("ctrl", "treat")) ; interaction(a, b) } +[1] 1.ctrl 1.ctrl 1.treat 1.treat 2.ctrl 2.ctrl 2.treat 2.treat +Levels: 1.ctrl 2.ctrl 1.treat 2.treat + +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testInteraction +#{ a <- gl(2, 4, 8) ; b <- gl(2, 2, 8, labels = c("ctrl", "treat")) ; s <- gl(2, 1, 8, labels = c("M", "F")) ; interaction(a, b, s, sep = ":") } +[1] 1:ctrl:M 1:ctrl:F 1:treat:M 1:treat:F 2:ctrl:M 2:ctrl:F 2:treat:M +[8] 2:treat:F +8 Levels: 1:ctrl:M 2:ctrl:M 1:treat:M 2:treat:M 1:ctrl:F ... 2:treat:F + ##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testInvisible #{ f <- function() { invisible(23) } ; f() } @@ -13267,6 +13299,33 @@ Error: object 'y' not found #{ sort(c(3,10,2)) } [1] 2 3 10 +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testSplit +#{ fu <- c(1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,1) ; split(1:20,fu) } +$`1` +[1] 1 4 7 10 13 16 19 20 + +$`2` + [1] 2 3 5 6 8 9 11 12 14 15 17 18 + + +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testSplit +#{ ma <- cbind(x = 1:10, y = (-4:5)^2) ; split(ma, col(ma)) } +$`1` + [1] 1 2 3 4 5 6 7 8 9 10 + +$`2` + [1] 16 9 4 1 0 1 4 9 16 25 + + +##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testSplit +#{ split(1:10, 1:2) } +$`1` +[1] 1 3 5 7 9 + +$`2` +[1] 2 4 6 8 10 + + ##com.oracle.truffle.r.test.simple.TestSimpleBuiltins.testSprintf #{ sprintf("%03d", 1:3) } [1] "001" "002" "003" diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java index 9b0455125ca3d8c3b70d08b06205e5940cf3c436..aa5c62f0f6c9f80729d29bf7413dbb9e8ac9f1a3 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java @@ -6043,6 +6043,21 @@ public class AllTests extends TestBase { assertEvalError("{ m <- matrix(c(5,-5,-5,3),2,2) ; chol(m) }"); } + @Test + public void TestSimpleBuiltins_testCol_96f5c5aecdd0b8a3d2888f918ea77f7f() { + assertEval("{ ma <- matrix(1:12, 3, 4) ; col(ma) }"); + } + + @Test + public void TestSimpleBuiltins_testCol_2aed206e17a5da2a3c6f617daeeacca0() { + assertEval("{ ma <- cbind(x = 1:10, y = (-4:5)^2) ; col(ma) }"); + } + + @Test + public void TestSimpleBuiltins_testColIgnore_8406be06fb724e25d072bc0cda3c46f9() { + assertEval("{ col(c(1,2,3)) }"); + } + @Test public void TestSimpleBuiltins_testColMeans_e6a4306e7b057179d8d3f30f3161484e() { assertEval("{colMeans(matrix(c(3,4,2,5)))}"); @@ -8573,6 +8588,16 @@ public class AllTests extends TestBase { assertEval("{x <- 10;class(x) <- c(\"a\", \"b\");inherits(x, \"a\", 1) ;}"); } + @Test + public void TestSimpleBuiltins_testInteraction_cc946aa5f7a0393338bf3a58fefb26a7() { + assertEval("{ a <- gl(2, 4, 8) ; b <- gl(2, 2, 8, labels = c(\"ctrl\", \"treat\")) ; interaction(a, b) }"); + } + + @Test + public void TestSimpleBuiltins_testInteraction_f0540e2d1f6d9ab64d558ef96133818f() { + assertEval("{ a <- gl(2, 4, 8) ; b <- gl(2, 2, 8, labels = c(\"ctrl\", \"treat\")) ; s <- gl(2, 1, 8, labels = c(\"M\", \"F\")) ; interaction(a, b, s, sep = \":\") }"); + } + @Test public void TestSimpleBuiltins_testInvisible_8469019c606ff78421cea952d395fa6b() { assertEval("{ f <- function() { invisible(23) } ; toString(f()) }"); @@ -13623,6 +13648,31 @@ public class AllTests extends TestBase { assertEval("{ x <- 1; f <- function() { source(\"test/r/simple/data/tree2/incx.r\", local=TRUE) ; x } ; c(f(), x) }"); } + @Test + public void TestSimpleBuiltins_testSplit_54724c7a16d9d337779ddd57f66b9fe9() { + assertEval("{ split(1:10, 1:2) }"); + } + + @Test + public void TestSimpleBuiltins_testSplit_fe14a6d85fd278368fa7d655f817309e() { + assertEval("{ ma <- cbind(x = 1:10, y = (-4:5)^2) ; split(ma, col(ma)) }"); + } + + @Test + public void TestSimpleBuiltins_testSplit_3209000db7f5918307889e642d7e1e57() { + assertEval("{ fu <- c(1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,1) ; split(1:20,fu) }"); + } + + @Test + public void TestSimpleBuiltins_testSplitIgnore_d2ccf1c31b984c75491ff8fbb39ab104() { + assertEval("{ n <- 2; nn <- 4 ; g <- factor(round(n * runif(n * nn))) ; x <- rnorm(n * nn) + sqrt(as.numeric(g)) ; xg <- split(x, g) ; xg }"); + } + + @Test + public void TestSimpleBuiltins_testSplitIgnore_4e3d6c8535597da99914e35ab11a6947() { + assertEval("{ fu <- c(\"a\",\"b\") ; split(1:8,fu) }"); + } + @Test public void TestSimpleBuiltins_testSprintf_1e77471269b0c978614b8f4d37953714() { assertEval("{ sprintf(\"0x%x\",1L) }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java index 7e93942d8a5bdf23339f364521506407cece9076..1a4675db3df8e3ba56e6370010ae5dc99deb7770 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java @@ -363,6 +363,11 @@ public class FailingTests extends TestBase { assertEvalError("{ m <- matrix(c(5,-5,-5,3),2,2) ; chol(m) }"); } + @Ignore + public void TestSimpleBuiltins_testColIgnore_8406be06fb724e25d072bc0cda3c46f9() { + assertEval("{ col(c(1,2,3)) }"); + } + @Ignore public void TestSimpleBuiltins_testColMeansIgnore_1e146b3cdde30114bb9bdd12bbfd4a51() { assertEval("{colMeans(matrix(c(NaN,4+5i,2+0i,5+10i),nrow=2,ncol=2), na.rm = TRUE)}"); @@ -1553,6 +1558,16 @@ public class FailingTests extends TestBase { assertEval("{ x <- 1; f <- function() { source(\"test/r/simple/data/tree2/incx.r\", local=TRUE) ; x } ; c(f(), x) }"); } + @Ignore + public void TestSimpleBuiltins_testSplitIgnore_d2ccf1c31b984c75491ff8fbb39ab104() { + assertEval("{ n <- 2; nn <- 4 ; g <- factor(round(n * runif(n * nn))) ; x <- rnorm(n * nn) + sqrt(as.numeric(g)) ; xg <- split(x, g) ; xg }"); + } + + @Ignore + public void TestSimpleBuiltins_testSplitIgnore_4e3d6c8535597da99914e35ab11a6947() { + assertEval("{ fu <- c(\"a\",\"b\") ; split(1:8,fu) }"); + } + @Ignore public void TestSimpleBuiltins_testSqrtBroken_dda9ccdc11f9f5afbe9854145501c5e5() { assertEval("{ sqrt(c(a=9,b=81)) }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleBuiltins.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleBuiltins.java index c465bbe1098064b47b8f07f68af78517bd1e177f..7b5a43f148d77d29f37939bee478b7a489524141 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleBuiltins.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleBuiltins.java @@ -3974,4 +3974,41 @@ public class TestSimpleBuiltins extends TestBase { assertEval("{ x <- cumsum(cumsum(1:10)) ; diff(x, lag = 2) }"); assertEval("{ x <- cumsum(cumsum(1:10)) ; diff(x, differences = 2) }"); } + + @Test + @Ignore + public void testInteraction() { + assertEval("{ a <- gl(2, 4, 8) ; b <- gl(2, 2, 8, labels = c(\"ctrl\", \"treat\")) ; interaction(a, b) }"); + assertEval("{ a <- gl(2, 4, 8) ; b <- gl(2, 2, 8, labels = c(\"ctrl\", \"treat\")) ; s <- gl(2, 1, 8, labels = c(\"M\", \"F\")) ; interaction(a, b, s, sep = \":\") }"); + } + + @Test + public void testSplit() { + assertEval("{ split(1:10, 1:2) }"); + assertEval("{ ma <- cbind(x = 1:10, y = (-4:5)^2) ; split(ma, col(ma)) }"); + assertEval("{ fu <- c(1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,1) ; split(1:20,fu) }"); + } + + @Test + @Ignore + public void testSplitIgnore() { + // requires as.double support for factors + assertEval("{ n <- 2; nn <- 4 ; g <- factor(round(n * runif(n * nn))) ; x <- rnorm(n * nn) + sqrt(as.numeric(g)) ; xg <- split(x, g) ; xg }"); + // requires first-class levels access in factors + assertEval("{ fu <- c(\"a\",\"b\") ; split(1:8,fu) }"); + } + + @Test + public void testCol() { + assertEval("{ ma <- matrix(1:12, 3, 4) ; col(ma) }"); + assertEval("{ ma <- cbind(x = 1:10, y = (-4:5)^2) ; col(ma) }"); + } + + @Test + @Ignore + public void testColIgnore() { + // reports wrong source section + assertEval("{ col(c(1,2,3)) }"); + } + }