tests/testthat/test-peek_inside.R

test_that("D() can look inside simple functions", {
  expect_equal(body(D(a*x + b ~ x)), quote(a))
  f <- makeFun(a*x + b ~ .)
  expect_equal(body(D(f(x) ~ x)), quote(a))
})

test_that("antiD() can look inside simple functions", {
  soln <- quote((x^2 * a + 2 * x * b)/2 + C)
  expect_equal(body(antiD(a*x + b ~ x)), soln)
  f <- makeFun(a*x + b ~ .)
  expect_equal(body(antiD(f(x) ~ x)), soln)
})

Try the mosaicCalc package in your browser

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

mosaicCalc documentation built on Sept. 11, 2024, 9:10 p.m.