tests/testthat/test-relative-import.r

context('relative imports')

test_that('Imports are absolute by default', {
    old_opts = options(box.path = getwd())
    on.exit(options(old_opts))

    box::use(mod/nested/relative_a)
    expect_equal(relative_a$a_which(), '/a')
})

test_that('Relative import are always local', {
    old_opts = options(box.path = getwd())
    on.exit(options(old_opts))

    box::use(mod/nested/relative_a)
    expect_equal(relative_a$local_a_which(), 'nested/a')
})

Try the box package in your browser

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

box documentation built on May 2, 2023, 9:14 a.m.