tests/testthat/test-utils_logic.R

test_that("%||%", {
  expect_equal("a" %||% "b", "a")
  expect_equal(list() %||% "b", "b")
  expect_equal(NULL %||% "b", "b")
})

test_that("%|||%", {
  expect_equal("a" %|||% "b", "a")
  expect_equal(list() %|||% "b", list())
  expect_equal(NULL %|||% "b", "b")
})

test_that("%|||chr%", {
  expect_equal("a" %|||chr% "b", "a")
  expect_equal("" %|||chr% "b", "b")
  expect_equal(list() %|||chr% "b", list())
  expect_equal(NULL %|||chr% "b", NULL)
})


test_that("if_any()", {
  expect_equal(if_any(TRUE, "a", "b"), "a")
  expect_equal(if_any(FALSE, "a", "b"), "b")
})

test_that("non_null()", {
  x <- list(a = 1, b = NULL, c = 3)
  expect_equal(length(x), 3L)
  out <- non_null(x)
  expect_equal(length(out), 2L)
  expect_equal(names(out), c("a", "c"))
})

Try the crew.aws.batch package in your browser

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

crew.aws.batch documentation built on June 9, 2025, 5:09 p.m.