tests/testthat/test_getRequiredParamNames.R

context("getRequiredParamNames")

test_that("getRequiredParamNames", {
  ps = makeParamSet(
    makeIntegerParam("a", default = 1L),
    makeIntegerParam("b", default = 1L, requires = quote(a == 1)),
    makeIntegerParam("c", default = 1L, requires = quote(a == 2 && b == 1))
  )

  expect_equal(getRequiredParamNames(ps), c("a", "b"))
  ps2 = filterParams(ps, ids = c("b", "c"))
  expect_equal(getRequiredParamNames(ps2), c("a", "b"))

  ps2 = filterParams(ps, ids = c("c"))
  expect_equal(getRequiredParamNames(ps2), c("a", "b"))

  ps2 = filterParams(ps, ids = character(0))
  expect_equal(getRequiredParamNames(ps2), character(0))
})

Try the ParamHelpers package in your browser

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

ParamHelpers documentation built on March 26, 2020, 7:40 p.m.