tests/testthat/test-echo.R

test_that("echo() works", {
  expect_output(
    expect_warning(
      expect_identical(echo({ 1 }), 1), # nolint: brace_linter.
      regexp = "echo::echo()",
      fixed = TRUE,
      class = "deprecatedWarning"
    )
  )

  expect_output(
    expect_warning(
      echo({ message("m") }, msg = FALSE), # nolint: brace_linter.
      regexp = "echo::echo()",
      fixed = TRUE,
      class = "deprecatedWarning"
    )
  )

  expect_output(
    expect_error(
      expect_warning(
        echo({
          1 + 1
          Sys.sleep(2)
          head(mtcars)
          message(1)
          warning(2)
          stop(3)
        }),
        regexp = "echo::echo()",
        fixed = TRUE,
        class = "deprecatedWarning"
      ),
      regexp = "3",
      class = "simpleError"
    )
  )
})
jmbarbone/jordan documentation built on April 1, 2024, 7:46 p.m.