R/codeVerif.R

detectGlobal <- function(realResult,tolerance=0,theoResult="",result=TRUE){
  functionNames <- strsplit(deparse(substitute(realResult)),"\\(")[[1]][1]
  if(identical(theoResult,"")==FALSE){
    if( isTRUE(all.equal( realResult , theoResult ))!=result ){
      cat("WARNING(PreTest2) in    ",functionNames,":",deparse(substitute(realResult)), " == ",theoResult," is not ",result,"\a\n\a")
    }
  }else{}
  if(length(findGlobals(get(functionNames),FALSE)$variables)  > tolerance){
    cat("WARNIGS(detectGlobal) in ",functionNames,": These are the globals:",findGlobals(get(functionNames),FALSE)$variables,"\a\n")
  }else{}
}


tryBug <- function(...){
   res <- try(...)
   if(class(res)!="try-error"){
       stop("This line SHOULD give an error, whereas it does not !")
   }else{}
   return(invisible)
}

Try the packS4 package in your browser

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

packS4 documentation built on May 2, 2019, 9:25 a.m.