test-set: Attach unit tests to objects

Description Usage Arguments Value Examples

Description

This function attaches unit tests in value to an object (typically a function) as an attribute "test".

Usage

1
test(f) <- value

Arguments

f

the function (object) to which the tests are to be attached

value

the test code, a function with no parameters

Value

f with the test attached as attribute "test"

Examples

1
2
3
4
5
6
7
8
9
f <- function(x) x^2

test(f) <- function() {
   context("f")

   test_that("correct result for complex number", {
     expect_equal(f(1i), -1 + 0i)
   })
}

hySpc.testthat documentation built on July 2, 2020, 2:31 a.m.