tests/testthat/test-is_valid.R

test_that("Valid Typst code returns TRUE", {
  valid_code <- c("= Hello World", "This is a Typst document.")
  expect_true(is_valid_typst(valid_code))
})

test_that("Invalid Typst code returns FALSE when error_on_failure = FALSE", {
  invalid_code <- c("= Hello World", "#This is a Typst document.") # Assuming '#' is invalid here
  expect_false(is_valid_typst(invalid_code))
})

test_that("Invalid Typst code throws error when error_on_failure = TRUE", {
  invalid_code <- c("= Hello World", "#This is a Typst document.")
  expect_error(is_valid_typst(invalid_code, error_on_failure = TRUE))
})

Try the tynding package in your browser

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

tynding documentation built on March 31, 2026, 5:06 p.m.