tests/testthat/test-defaults.R

context("Using object defaults")

pg <- .loadPgExample()
defaultTest <- function(x, defaults) {
    .fillDefaults(defaults)
    x
}

test_that("Setter and getter works", {
    expect_equal(defaults(pg)$kmerSize, .pkg_variables$defaults$kmerSize)
    defaults(pg)$kmerSize <- 1
    expect_equal(defaults(pg)$kmerSize, 1)
    defaults(pg)$newDef <- 'test'
    expect_equal(defaults(pg)$newDef, 'test')
    expect_error(defaults(pg)$translated <- FALSE)
})

test_that("defaults can be used with .fillDefaults", {
    expect_error(defaultTest(defaults=list(y=1)))
    expect_equal(defaultTest(defaults=list(x=1)), 1)
    expect_equal(defaultTest(x=2,defaults=list(x=1)), 2)
})

Try the FindMyFriends package in your browser

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

FindMyFriends documentation built on Nov. 8, 2020, 6:46 p.m.