R/test_env_functions.R

Defines functions test_env_functions

Documented in test_env_functions

#' This function is for students.
#' This function tests functions in the current environment.
test_env_functions <- function(elapsedSeconds = 10) {
  table <- list()
  all_function_names <- as.vector(lsf.str(.GlobalEnv))
  for (function_name in all_function_names) {
    if (function_name %in% names(test_cases)) {
      result_list <- c()
      for (test_case in test_cases[[function_name]]) {
        tryCatch({
          result <- with_timeout(eval(parse(text = test_case)), Inf, elapsedSeconds)
        }, error = function(e) {
          result <- FALSE
        }, finally = {
          result_list <- c(result_list, result)
        })
      }
      table[[function_name]] <- result_list
    }
  }
  return(table)
}
emse-p4a-gwu/p4aGrader documentation built on May 16, 2020, 1:43 a.m.