tests/testthat/test_getRequirements.R

context("getRequirements")

test_that("getRequirements", {
  ps = makeParamSet()
  # FIXME: BBmisc::namedList still buggy, only return list()
  xs = setNames(list(), character(0L))
  expect_equal(getRequirements(ps), xs)

  r1 = quote(a == 1)
  r2 = quote(a == 2)
  ps = makeParamSet(
    makeIntegerParam("a", default = 1L),
    makeIntegerParam("b", default = 1L, requires = r1),
    makeNumericParam("c", default = 1L, requires = r2)
  )

  expect_equal(getRequirements(ps, remove.null = TRUE), list(b = r1, c = r2))
  expect_equal(getRequirements(ps, remove.null = FALSE), list(a = NULL, b = r1, c = r2))
})

Try the ParamHelpers package in your browser

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

ParamHelpers documentation built on July 4, 2022, 5:07 p.m.