tests/testthat/test-function.R

test_that("can source a function", {
  code <- "SEXP fn(SEXP x) {
             return x;
           }"

  fn <- source_function(code)
  expect_equal(fn(1), 1)
})

test_that("can source a function with blank lines above it", {
  code <- "

    SEXP fn(SEXP x) {
      return x;
    }

  "

  fn <- source_function(code)
  expect_equal(fn(1), 1)
})
DavisVaughan/cbuild documentation built on Dec. 25, 2019, 5:11 a.m.