tests/testthat/test-payload.R

context("payload")

test_that("create_env() with payload", {
  env <- create_env(lapply(letters, as.name), paste, "letter")
  expect_equal(env$a, "a letter")
  expect_equal(env$x, "x letter")
  expect_null(env$X)
  expect_equal(length(ls(env)), length(letters))
  expect_error(env$a <- "a", "read-only")
})

test_that("create_env() with named payload", {
  env <- create_env(lapply(letters, as.name), paste0, 1:3, collapse = "")
  expect_equal(env$a, "a1a2a3")
  expect_equal(env$x, "x1x2x3")
  expect_null(env$X)
  expect_equal(length(ls(env)), length(letters))
  expect_error(env$a <- "a", "read-only")
})

Try the bindr package in your browser

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

bindr documentation built on May 2, 2019, 4:22 a.m.