50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

fmesher (version 0.3.0)

local_testthat: Unit test helpers

Description

Local helper functions for package unit tests

Usage

local_fm_testthat_assign(x, values, envir = parent.frame())

local_fm_testthat_tolerances( tolerances = c(1e-04, 0.01, 0.1), envir = parent.frame() )

local_fm_testthat_setup(envir = parent.frame())

Value

None

Arguments

x

character; Name of variable to assign to

values

the object to assign to x

envir

environment for exit handlers

tolerances

numeric vector of length 3; [lowtol, midtol, hitol]

Functions

  • local_fm_testthat_assign(): Assign local variable. Useful for easy cleanup of global workspace with withr::deferred_run() when running tests interactively.

  • local_fm_testthat_tolerances(): Assign test tolerances Assign local tolerance variables. Useful for easy cleanup of global workspace with withr::deferred_run() when running tests interactively.

  • local_fm_testthat_setup(): Initialise environment for tests. To be called either at the top of a testfile, or inside tests.

Examples

Run this code
outer_fun <- function() {
  fun <- function(envir = parent.frame()) {
    local_fm_testthat_assign("local_var_name", 1:4, envir = envir)
  }
  fun()
  local_var_name
}
exists("local_var_name")
outer_fun()
exists("local_var_name")

Run the code above in your browser using DataLab