tests/testthat/test-partialised.R

test_that("dist", {
  library(partialised)

  dist <- function(x, y) {
    sqrt(x ^ 2 + y ^ 2)
  }

  pdist <- new_partialised(dist,
                           list(x = 3))
  expect_equal(pdist(y = 4), 5)

  arguments(pdist)$x <- 6
  expect_equal(pdist(y = 8), 10)

  pdist$y <- 8
  expect_equal(pdist(), 10)
})

Try the partialised package in your browser

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

partialised documentation built on Nov. 4, 2022, 5:08 p.m.