Skip to content

Commit 58604eb

Browse files
committed
Skip ALTREP tests on R < 3.5
1 parent 5b1c443 commit 58604eb

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

inst/tests/tests.Rraw

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,29 +2290,31 @@ test(754.04, DT[, b := a][3, b := 6L], data.table(a=INT(4,2,3),b=INT(4,2,6)))
22902290
test(754.05, DT[, a := as.numeric(a), verbose=TRUE], output="Direct plonk.*no copy")
22912291
RHS = as.integer(DT$a)
22922292
test(754.06, DT[, a:= RHS, verbose=TRUE], output="RHS for item 1 has been duplicated")
2293-
# Expand ALTREPS in assign.c, #5400
2294-
# String conversion gets deferred
2295-
## first, a regression test of R itself -- we want to make sure our own test continues to be useful & testing its intended purpose
2296-
test(754.07, {a = 1:10; .Internal(inspect(a)); b = as.character(a); .Internal(inspect(b))}, output = "\\bcompact\\b.*\\bdeferred string conversion\\b")
2297-
test(754.08, DT[, a := as.character(a), verbose=TRUE], output="RHS for item 1 has been duplicated")
2298-
# Executing the code inside of test expands the ALTREP so we repeat the code
2299-
# in order to check the result after a further assignment
2300-
DT = data.table(a=1:3)
2301-
DT[, b := as.character(a)]
2302-
DT[, a := 5L]
2303-
test(754.09, DT, data.table(a=5L, b=as.character(1:3)))
2304-
# This function returns an ALTREP wrapper if the input is at least length 64
2305-
testFun = function(x) {
2306-
x[FALSE] = 1
2307-
x
2293+
if (getRversion() >= "3.5.0") { # TODO(R>=3.5.0): test unconditionally
2294+
# Expand ALTREPS in assign.c, #5400
2295+
# String conversion gets deferred
2296+
## first, a regression test of R itself -- we want to make sure our own test continues to be useful & testing its intended purpose
2297+
test(754.07, {a = 1:10; .Internal(inspect(a)); b = as.character(a); .Internal(inspect(b))}, output = "\\bcompact\\b.*\\bdeferred string conversion\\b")
2298+
test(754.08, DT[, a := as.character(a), verbose=TRUE], output="RHS for item 1 has been duplicated")
2299+
# Executing the code inside of test expands the ALTREP so we repeat the code
2300+
# in order to check the result after a further assignment
2301+
DT = data.table(a=1:3)
2302+
DT[, b := as.character(a)]
2303+
DT[, a := 5L]
2304+
test(754.09, DT, data.table(a=5L, b=as.character(1:3)))
2305+
# This function returns an ALTREP wrapper if the input is at least length 64
2306+
testFun = function(x) {
2307+
x[FALSE] = 1
2308+
x
2309+
}
2310+
DT = data.table(id=1:64, col1=0, col2=0)
2311+
test(754.10, DT[, col1 := testFun(col2), verbose = TRUE], output="RHS for item 1 has been duplicated")
2312+
DT = data.table(id=1:64, col1=0, col2=0)
2313+
DT[, col1 := testFun(col2)]
2314+
DT[, col2 := 999]
2315+
test(754.11, DT, data.table(id=1:64, col1=0, col2=999))
2316+
rm(testFun)
23082317
}
2309-
DT = data.table(id=1:64, col1=0, col2=0)
2310-
test(754.10, DT[, col1 := testFun(col2), verbose = TRUE], output="RHS for item 1 has been duplicated")
2311-
DT = data.table(id=1:64, col1=0, col2=0)
2312-
DT[, col1 := testFun(col2)]
2313-
DT[, col2 := 999]
2314-
test(754.11, DT, data.table(id=1:64, col1=0, col2=999))
2315-
rm(testFun)
23162318

23172319
# Used to test warning on redundant by (#2282) but by=.EACHI has now superseded
23182320
DT = data.table(a=letters[1:3],b=rep(c("d","e"),each=3),x=1:6,key=c('a', 'b'))

0 commit comments

Comments
 (0)