File: test-knitr.R

package info (click to toggle)
r-cran-cpp11 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,428 kB
  • sloc: cpp: 9,732; sh: 14; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
describe("eng_cpp11", {
  it("works when code is not evaluated", {
    skip_on_os("solaris")
    opts <- knitr::opts_chunk$get()
    opts <- utils::modifyList(opts, list(eval = FALSE, engine = "cpp11", code = "1 + 1"))

    expect_equal(
      eng_cpp11(opts),
      "1 + 1"
    )
  })

  it("works when code is evaluated", {
    skip_on_os("solaris")
    opts <- knitr::opts_chunk$get()
    code <- "[[cpp11::register]] int foo() { return 0; }"
    opts <- utils::modifyList(opts, list(eval = TRUE, engine = "cpp11", code = code, quiet = TRUE))

    expect_equal(
      eng_cpp11(opts),
      code
    )
  })
})