R-developers

Does anybody know how I incorporate the use of the tracker in RUnit
in the unit tests?

I have read the RUnit Vignette, help pages and searched around,
but I could find no examples of using 'inspect' in the unit
test functions. Moreover, doing so, I tried something like

library(RUnit)
myFunction <- function(x) {
        return(x)
}
track <- tracker()
track$init()

test.someTestFunction <- function() {
  y <- 10
  res <- inspect(myFunction(y), track = track)
  checkEquals(res, 10)
}

which works fine, when calling test.someTestFunction() from
the command line, but embedded in a test suite, I get
Error in eval(expr, envir, enclos) : object 'y' not found

Another question/suggestion: The 'inspect' function inserts
track points in the code, and this could perhaps be used
differently. Instead of doing it in a local copy of the code
(as I understand it is done), it could be done in the original
function, like 'trace' can replace the original code, I believe.
Then every subsequent call will be tracked, until inspection is
stopped. I imagine something like

startInspection(myFunction, track = track)
[ or startInspection(myFunction, signature = "numeric", track = track)]
myFunction(10)
stopInspection(myFunction)

Is this already around?

Best, Niels

--
Niels Richard Hansen                     Web:   www.math.ku.dk/~richard 
Associate Professor                      Email: niels.r.han...@math.ku.dk
Department of Mathematical Sciences             nielsrichardhan...@gmail.com
University of Copenhagen                 Skype: nielsrichardhansen.dk   
Universitetsparken 5                     Phone: +1 510 502 8161 
2100 Copenhagen Ø
Denmark

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to