tests/testthat/test-utils.R

test_that("canonical_objs()", {
  expect_equal(
    canonical_objs(
      list(
        magrittr = dplyr::`%>%`,
        testthat = dplyr::`%>%`,
        dplyr = dplyr::`%>%`
      ),
      "%>%"
    ),
    list(magrittr = dplyr::`%>%`)
  )

  # Only using packages that are attached, in order
  expect_equal(
    canonical_objs(
      list(
        testthat = dplyr::`%>%`,
        dplyr = dplyr::`%>%`
      ),
      "%>%"
    ),
    list(testthat = dplyr::`%>%`)
  )

  expect_equal(
    canonical_objs(
      list(
        dplyr = dplyr::`%>%`,
        testthat = dplyr::`%>%`
      ),
      "%>%"
    ),
    list(dplyr = dplyr::`%>%`)
  )
})

Try the conflicted package in your browser

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

conflicted documentation built on Dec. 1, 2026, 9:06 a.m.