I am expanding the doSvUnit.R script so that it will include the examples in its report.
one initial step in the task is associating a test to a function, where the name of the function is in a variable. (my real test function does not only checkTrue, it invokes the examples for the function named funcName. I'm here only showing the concept.)
> funcName <- "double.threshold"
> test(get(funcName)) <- function() checkTrue(TRUE)
Error in test(get(funcName)) <- function() checkTrue(TRUE) :
could not find function "get<-"
>
or even
> test(get("double.threshold")) <- function() checkTrue(TRUE)
Error in test(get("double.threshold")) <- function() checkTrue(TRUE) :
target of assignment expands to non-language object
>
I don't understand the reason behind either error message and I don't understand why I get two different error messages for what I see as the same thing.
thanks to the second error message, I found a workaround by storing the function in an object, but I don't understand why it should be necessary and I am not so sure this is specific to svUnit.
> f <- get(funcName)
> test(f) <- function() checkTrue(TRUE)
>