ENH R accessor processing test

Test of accessors generated via the new internal structures.
This test confirms that the old incorrect accessors are not
present and runs the correct version, confirming the values.
This commit is contained in:
Richard Beare 2019-08-30 22:31:46 +10:00
commit bb65049517

View file

@ -0,0 +1,50 @@
clargs <- commandArgs(trailing=TRUE)
source(file.path(clargs[1], "unittest.R"))
dyn.load(paste("abstract_access", .Platform$dynlib.ext, sep=""))
source("abstract_access.R")
dd <- D()
unittest(1, dd$z())
unittest(1, dd$do_x())
## Original version allowed dd$z <- 2
tryCatch({
dd$z <- 2
}, error = function(e) {
message("Correct - no dollar assignment method found")
}
)
tryCatch({
dd[["z"]] <- 2
}, error = function(e) {
message("Correct - no dollar assignment method found")
}
)
## The methods are attached to the parent class - see if we can get
## them
tryCatch({
m1 <- getMethod('$', "_p_A")
}, error = function(e) {
stop("No $ method found - there should be one")
}
)
## These methods should not be present
## They correspond to the tests that are expected
## to fail above.
tryCatch({
m2 <- getMethod('$<-', "_p_A")
}, error = function(e) {
message("Correct - no dollar assignment method found")
}
)
tryCatch({
m3 <- getMethod('[[<-', "_p_A")
}, error = function(e) {
message("Correct - no list assignment method found")
}
)