-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add opts_list for interoperability with options(),withr (#19)
* feat: add opts_list for interoperability with options(),withr * fix: check links * feat: add parameter to configure missing option names behavior
- Loading branch information
Showing
7 changed files
with
217 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
test_that("opts_list produces an option of namespaced option names", { | ||
e <- new.env(parent = baseenv()) | ||
|
||
expect_silent(with(e, options::define_options( | ||
"option quiet", | ||
quiet = TRUE | ||
))) | ||
|
||
l <- expect_silent(with(e, options::opts_list(quiet = FALSE))) | ||
|
||
expect_match(names(l), ".+\\.quiet") | ||
expect_type(l, "list") | ||
expect_equal(l[[1]], FALSE) | ||
}) | ||
|
||
test_that("opts_list returns raw name if not part of namespaced option spec", { | ||
e <- new.env(parent = baseenv()) | ||
expect_silent(with(e, options::define_options( | ||
"option quiet", | ||
quiet = TRUE | ||
))) | ||
|
||
l <- expect_silent(with(e, options::opts_list(quiet = FALSE, max.print = 10))) | ||
|
||
expect_match(names(l)[[1]], ".+\\.quiet") | ||
expect_true("max.print" %in% names(l)) | ||
}) | ||
|
||
test_that("opts_list emit warnings when names missing with check_names warn", { | ||
e <- new.env(parent = baseenv()) | ||
expect_silent(with(e, options::define_options( | ||
"option quiet", | ||
quiet = TRUE | ||
))) | ||
|
||
expect_warning(with(e, { | ||
options::opts_list(quiet = FALSE, max.print = 10, check_names = "warn") | ||
})) | ||
}) | ||
|
||
test_that("opts_list emit error when names missing with check_names stop", { | ||
e <- new.env(parent = baseenv()) | ||
expect_silent(with(e, options::define_options( | ||
"option quiet", | ||
quiet = TRUE | ||
))) | ||
|
||
expect_error(with(e, { | ||
options::opts_list(quiet = FALSE, max.print = 10, check_names = "stop") | ||
})) | ||
}) |