Skip to content

Commit 2cb4de9

Browse files
author
Pavel Marek
committed
Enable ignored unit tests.
Also ignore error messages in some tests due to incosistent GNU-R behavior, and add some tests. (cherry picked from commit c470744)
1 parent b8ba340 commit 2cb4de9

34 files changed

+165
-134
lines changed

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/S4/TestS4.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void testObjectValueSemantics() {
175175
@Test
176176
public void testActiveBindings() {
177177
assertEval("someSymbol0 <- 1; makeActiveBinding('someSymbol0', function(x) { x }, .GlobalEnv)");
178-
assertEval(Ignored.NewRVersionMigration, Output.IgnoreErrorContext, "lockEnvironment(.GlobalEnv); makeActiveBinding('someSymbol1', function(x) { x }, .GlobalEnv)");
178+
assertEval(Output.IgnoreErrorMessage, "lockEnvironment(.GlobalEnv); makeActiveBinding('someSymbol1', function(x) { x }, .GlobalEnv)");
179179
assertEval("makeActiveBinding('someSymbol2', function(x) { x }, .GlobalEnv); bindingIsActive('someSymbol2', .GlobalEnv)");
180180
assertEval("bindingIsActive('someSymbol3', .GlobalEnv)");
181181
assertEval(".Internal(bindingIsActive(as.name('someSymbol4'), .GlobalEnv))");

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_allvars.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public void testallvars1() {
3535

3636
@Test
3737
public void testallvars2() {
38-
assertEval(Ignored.NewRVersionMigration, "{ fml <- as.formula('v ~ a + b'); fml[[2]] <- NULL; all.vars(fml) }");
38+
assertEval("{ fml <- as.formula('v ~ a + b'); fml[[2]] <- NULL; all.vars(fml) }");
3939
}
4040
}

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascomplex.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ public void testAsComplex() {
112112
assertEval(Ignored.ImplementationError, "{ as.complex(\"+.1e+2-3i\") }");
113113

114114
assertEval("{ as.complex(list(42)) }");
115-
// TODO: Wrong IgnoreErrorContext
116-
assertEval(Ignored.NewRVersionMigration, Output.IgnoreErrorContext, "{ as.complex(list(NULL)) }");
115+
assertEval(Output.IgnoreErrorContext, "{ as.complex(list(NULL)) }");
117116
assertEval(Output.IgnoreWarningContext, "{ as.complex(list(\"foo\")) }");
118117
assertEval("{ as.complex.cls <- function(x) 42; as.complex(structure(c(1,2), class='cls')); }");
119118

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asinteger.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ public void testAsInteger() {
146146
assertEval("{ as.integer(list(integer(),2,3)) }");
147147
assertEval("{ as.integer(list(list(1),2,3)) }");
148148
assertEval("{ as.integer(list(1,2,3,list())) }");
149-
// TODO: Wrong IgnoreErrorContext
150-
assertEval(Ignored.NewRVersionMigration, Output.IgnoreErrorContext, "{ as.integer(list(c(1L, 2L))) }");
149+
assertEval(Output.IgnoreErrorContext, "{ as.integer(list(c(1L, 2L))) }");
151150
assertEval("{ as.integer(10000000000) }");
152151
assertEval("{ as.integer(c(1, 10000000000)) }");
153152
assertEval("{ as.integer(-10000000000) }");

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_bcVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public class TestBuiltin_bcVersion extends TestBase {
2929

3030
@Test
3131
public void testbcVersion1() {
32-
assertEval(Ignored.NewRVersionMigration, ".Internal(bcVersion())");
32+
assertEval(".Internal(bcVersion())");
3333
}
3434
}

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_class.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ public void testclass19() {
124124

125125
@Test
126126
public void testclass20() {
127-
assertEval(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12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24'), c('(Intercept)', 'block2', 'block3', 'block4', 'block5', 'block6', 'N1', 'P1', 'K1', 'N1:P1', 'N1:K1', 'P1:K1', 'N1:P1:K1')), assign = c(0L, 1L, 1L, 1L, 1L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L), contrasts = structure(list(block = 'contr.treatment', N = 'contr.treatment', P = 'contr.treatment', K = 'contr.treatment'), .Names = c('block', 'N', 'P', 'K'))));class(argv[[1]]);");
127+
assertEval("argv <- list(structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(24L, 13L), .Dimnames = list(c('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24'), c('(Intercept)', 'block2', 'block3', 'block4', 'block5', 'block6', 'N1', 'P1', 'K1', 'N1:P1', 'N1:K1', 'P1:K1', 'N1:P1:K1')), assign = c(0L, 1L, 1L, 1L, 1L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L), contrasts = structure(list(block = 'contr.treatment', N = 'contr.treatment', P = 'contr.treatment', K = 'contr.treatment'), .Names = c('block', 'N', 'P', 'K'))));class(argv[[1]]);");
129128
}
130129

131130
@Test
@@ -202,6 +201,22 @@ public void testGetClass() {
202201
assertEval("{ gen<-function(object) 0; setGeneric(\"gen\"); class(gen) }");
203202
}
204203

204+
/**
205+
* From GNU-R version 4.0.0, matrix objects also have class array.
206+
*/
207+
@Test
208+
public void testGetClassFromMatrix() {
209+
assertEval("{ m <- matrix(1:9, ncol=3); class(m) }");
210+
assertEval("{ v <- 1:9; dim(v) <- c(3,3); class(v) }");
211+
assertEval("{ v <- as.double(1:9); dim(v) <- c(3,3); class(v) }");
212+
assertEval("{ v <- 1:9; attr(v, 'dim') <- c(3,3); class(v) }");
213+
// The following test succeeds, but if assign just 'matrix' or 'array' class at one time, it
214+
// fails
215+
assertEval("{ v <- 1:9; class(v) <- c('matrix', 'array') }");
216+
assertEval("{ v <- 1:9; class(v) <- c('matrix') }");
217+
assertEval("{ v <- 1:9; class(v) <- c('array') }");
218+
}
219+
205220
@Test
206221
public void testSetClass() {
207222
assertEval("{ x <- c(1,2,3); class(x) <- NULL; attributes(x); x }");

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_classassign.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void testUpdateClass() {
178178

179179
assertEval("{x<-c(1,2,3,4); dim(x)<-c(2,2); class(x)<-\"array\"; x; class(x)<-\"matrix\"; x;}");
180180

181-
assertEval(Ignored.NewRVersionMigration, "{x<-c(1,2,3,4); dim(x)<-c(2,2); class(x)}");
181+
assertEval("{x<-c(1,2,3,4); dim(x)<-c(2,2); class(x)}");
182182

183183
assertEval("{x<-c(1,2,3,4); dim(x)<-c(2,2); class(x);dim(x)<-c(2,2,1);class(x)}");
184184

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_colMeans.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void testColMeans() {
115115
assertEval("{colMeans(matrix(c(TRUE,FALSE,FALSE,NaN),nrow=2,ncol=2), na.rm = FALSE)}");
116116
assertEval("{colMeans(matrix(c(TRUE,FALSE,FALSE,NA),nrow=2,ncol=2), na.rm = FALSE)}");
117117
// Whichever value(NA or NaN) is first in the row will be returned for that row.
118-
assertEval(Ignored.NewRVersionMigration, "{colMeans(matrix(c(NA,NaN,NaN,NA),ncol=2,nrow=2))}");
118+
assertEval("{colMeans(matrix(c(NA,NaN,NaN,NA),ncol=2,nrow=2))}");
119119
assertEval("{ a = colSums(array(1:24,c(2,3,4))); colMeans(a)}");
120120

121121
assertEval("{colMeans(matrix(c(NaN,4+5i,2+0i,5+10i),nrow=2,ncol=2), na.rm = TRUE)}");

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_cummax.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public void testCumulativeMax() {
8080
assertEval("{ cummax(c(1+1i,2-3i,4+5i)) }");
8181
assertEval("{ cummax(c(1+1i, NA, 2+3i)) }");
8282

83-
assertEval(Ignored.NewRVersionMigration, "values <- c(1,2,NaN,1, NA); cummax(values); cummax(as.integer(values))");
84-
assertEval(Ignored.NewRVersionMigration, "values <- c(1,2,NA,1, NaN); cummax(values); cummax(as.integer(values))");
83+
assertEval("values <- c(1,2,NaN,1, NA); cummax(values); cummax(as.integer(values))");
84+
assertEval("values <- c(1,2,NA,1, NaN); cummax(values); cummax(as.integer(values))");
8585

8686
assertEval("a <- structure(1:3, names=c('a1','a2','a3')); b<-cummax(a); names(b)[1]<-'x'; a; ");
8787
}

com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_cummin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public void testCumulativeMin() {
7979
assertEval("{ cummin(c(1+1i,2-3i,4+5i)) }");
8080
assertEval("{ cummin(c(1+1i, NA, 2+3i)) }");
8181

82-
assertEval(Ignored.NewRVersionMigration, "values <- c(1,2,NaN,1, NA); cummin(values); cummin(as.integer(values))");
83-
assertEval(Ignored.NewRVersionMigration, "values <- c(1,2,NA,1, NaN); cummin(values); cummin(as.integer(values))");
82+
assertEval("values <- c(1,2,NaN,1, NA); cummin(values); cummin(as.integer(values))");
83+
assertEval("values <- c(1,2,NA,1, NaN); cummin(values); cummin(as.integer(values))");
8484

8585
assertEval("a <- structure(1:3, names=c('a1','a2','a3')); b<-cummin(a); names(b)[1]<-'x'; a; ");
8686
}

0 commit comments

Comments
 (0)