tests/testthat/test-simplify_parens.R

test_that("simplify_parens doesn't change things that shouldn't change", {
  expect_equal(simplify_parens(~a), ~a)
  expect_equal(simplify_parens(a~b), a~b)
  expect_equal(simplify_parens(as.name("a")), as.name("a"))
  expect_equal(simplify_parens(quote(foo(bar, baz))), quote(foo(bar, baz)))
  expect_equal(simplify_parens(~foo*((qux(bar, baz)))), ~foo*(qux(bar, baz)))
})

test_that("simplify_parens removes some parens", {
  expect_equal(
    simplify_parens(str2lang("(a)")),
    as.name("a")
  )
})

Try the formulops package in your browser

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

formulops documentation built on April 3, 2025, 9:36 p.m.