inst/unitTests/runittwEnumNames.R

.example.twEnumNames <- function(){
    vec <- c(a="foo", b="bar", "some test"="fasel")
    rm( list=names(vec) )
    i_b <- 4
    myFun <- function(inherits=TRUE){
        #do some fast repeated access to vec
        twEnumNames(vec, inherits)
        vec[i_some.test]
        vec[i_b]
    }
    checkException(myFun()) #existence of i_b
    res <- NULL
    #mtrace(twEnumNames)
    res <- myFun(inherits=FALSE)    # i_b does not exist in myFun
    checkEquals(vec["b"], res )
    checkTrue( !exists("a"))        # twEnumNames was called within myFun, so the variables went out of scope
}

Try the twMisc package in your browser

Any scripts or data that you put into this service are public.

twMisc documentation built on May 2, 2019, 6:11 p.m.