R/function_id.R

Defines functions function_id function_id.soo_function function_id.wrapped_soo_function function_id.soo_function_generator

Documented in function_id

#' Function ID
#'
#' Get a short id for the function that can be used in filenames and
#' such. It is guaranteed that the ID contains only \dQuote{safe}
#' characters in the range {A-Z,a-z,0-9,_,-}.
#'
#' @param fn [\code{\link{soo_function}}] Function to name.
#' @return ID of function. Guaranteed to be unique among all test
#' functions.
#' @export
function_id <- function(fn)
  UseMethod("function_id")

#' @export
#' @method function_id soo_function
function_id.soo_function <- function(fn)
  attr(fn, "id")

#' @export
#' @method function_id wrapped_soo_function
function_id.wrapped_soo_function <- function(fn)
  function_id(inner_function(fn))

#' @export
#' @method function_id soo_function_generator
function_id.soo_function_generator <- function(fn)
  attr(fn, "id")

Try the soobench package in your browser

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

soobench documentation built on Feb. 9, 2020, 5:08 p.m.