tests/testthat/test-fcompose.R

test_that("fcompose works with numeric functions", {
  f <- fcompose(sqrt, function(x) x^2, function(x) x + 1)
  expect_equal(f(4), 5)
})

test_that("fcompose fails with no input functions", {
  expect_error(fcompose(), "At least one function must be provided.")
})


test_that("fcompose returns original function if one is passed", {
  f <- fcompose(function(x) x + 1)
  expect_equal(f(3), 4)
})

Try the functionals package in your browser

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

functionals documentation built on Aug. 8, 2025, 7:32 p.m.