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:
parent
aca44d9d3a
commit
bb65049517
1 changed files with 50 additions and 0 deletions
50
Examples/test-suite/r/abstract_access_runme.R
Normal file
50
Examples/test-suite/r/abstract_access_runme.R
Normal 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")
|
||||
}
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue