fuzz_function {fuzzr}R Documentation

Fuzz-test a function

Description

Evaluate how a function responds to unexpected or non-standard inputs.

Usage

fuzz_function(fun, arg_name, ..., tests = test_all(), check_args = TRUE,
  progress = interactive())

p_fuzz_function(fun, .l, check_args = TRUE, progress = interactive())

Arguments

fun

A function.

arg_name

Quoted name of the argument to fuzz test.

...

Other non-dynamic arguments to pass to fun. These will be repeated for every one of the tests.

tests

Which fuzz tests to run. Accepts a named list of inputs, defaulting to test_all.

check_args

Check if arg_name and any arguments passed as ... are accepted by fun. Set to FALSE if you need to pass arguments to a function that accepts arguments via ....

progress

Show a progress bar while running tests?

.l

A named list of tests.

Details

fuzz_function provides a simple interface to fuzz test a single argument of a function by passing the function, name of the argument, static values of other required arguments, and a named list of test values.

p_fuzz_function takes a nested list of arguments paired with lists of tests to run on each argument, and will evaluate every combination of argument and provided test.

Value

A fuzz_results object.

Note

The user will be asked to confirm before proceeding if the combinations of potential tests exceeds 500,000.

See Also

fuzz_results and as.data.frame.fuzz_results to access fuzz test results.

Examples

# Evaluate the 'formula' argument of lm, passing additional required variables
fr <- fuzz_function(lm, "formula", data = iris)

# When evaluating a function that takes ..., set check_args to FALSE
fr <- fuzz_function(paste, "x", check_args = FALSE)

# Pass tests to multiple arguments via a named list
test_args <- list(
   data = test_df(),
   subset = test_all(),
   # Specify custom tests with a new named list
   formula = list(all_vars = Sepal.Length ~ ., one_var = mpg ~ .))
fr <- p_fuzz_function(lm, test_args)

[Package fuzzr version 0.2.2 Index]