Nothing
test_that("perhaps doesn't modify a function if it doesn't error or warn", {
for_all(
a = anything(),
property = function(a)
perhaps(identity, default = 0)(a) %>%
expect_identical(a)
)
})
test_that("perhaps modifies a function to return a default when it has warnings", {
for_all(
a = anything(),
property = function(a)
perhaps(function(b) warning(""), default = a)(NULL) %>%
expect_identical(a)
)
})
test_that("perhaps modifies a function to return a default when it has errors", {
for_all(
a = anything(),
property = function(a)
perhaps(function(b) stop(""), default = a)(NULL) %>%
expect_identical(a)
)
})
test_that("allow_warning allows functions with warnings to return expected", {
for_all(
a = anything(),
property = function(a)
perhaps(function(b) { warning(""); b }, allow_warning = TRUE)(a) %>%
expect_equal(a)
)
})
test_that("perhaps will return the expected value if the predicate returns TRUE", {
for_all(
a = any_atomic(),
property = function(a)
perhaps(identity, ensure = is.atomic, default = 0)(a) %>%
expect_identical(a)
)
})
test_that("perhaps will return the default if the predicate returns FALSE", {
for_all(
a = any_undefined(),
property = function(a)
perhaps(identity, ensure = not_undefined, default = a)(NULL) %>%
expect_identical(a)
)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.