tests/testthat/test-lists.R

test_that("list assignment", {
  l <- as.list(iris)

  expect_equal(
    list_assign(l, `names<-`(new_list(length(l)), names(l))),
    `names<-`(list(), character())
  )

  expect_equal(
    list_assign(l, list(x = 1L, Species = NULL, y = 0L, y = NULL)),
    c(l[c(1, 2, 3, 4)], list(x = 1L, y = 0L))
  )

})

Try the cheapr package in your browser

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

cheapr documentation built on June 8, 2025, 11:35 a.m.