tests/testthat/test-Compose.R

library(functools)
context("Compose()")

test_that("Produces the correct output.", {
  expect_equal(Compose(Identity, Identity)(Identity), Identity(Identity))
  expect_equal(Compose("Identity", "Identity")(Identity), Identity(Identity))
  expect_equal(`%O%`(Identity, Identity)(Identity), Identity(Identity))
  expect_equal(Compose(Identity, Identity)(Identity), `%O%`(Identity, Identity)(Identity))

})

test_that("Produces the correct output type.", {
  expect_is(Compose(Identity, Identity), "function")
  expect_is(Compose("Identity", "Identity"), "function")
  expect_is(`%O%`(Identity, Identity)(Identity), "function")
})

test_that("Produces the correct errors.", {
  expect_error(Compose("a", "b"))
  expect_error(`%O%`("a", "b"))
})

Try the functools package in your browser

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

functools documentation built on May 2, 2019, 5:39 a.m.