tests/testthat/test-source_dir.R

test_that("source_dir()", {
  res <- source_dir("test_dir", pattern = "hello", chdir = TRUE, wrap = FALSE)
  expect_equal(res[[1]](), "Hello World")

  res <- source_dir(normalizePath("test_dir"), pattern = "hello", chdir = TRUE, wrap = FALSE)
  expect_equal(res[[1]](), "Hello World")

  res <- source_dir("test_dir", pattern = "hello", chdir = FALSE, wrap = FALSE)
  expect_equal(res[[1]](), "Hello World")

  res <- source_dir(normalizePath("test_dir"), pattern = "hello", chdir = FALSE, wrap = FALSE)
  expect_equal(res[[1]](), "Hello World")
})

Try the testthat package in your browser

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

testthat documentation built on Oct. 6, 2023, 5:10 p.m.