File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11# testthat (development version)
22
3+ * ` local_edition() ` now gives a useful error for bad values (#1547 ).
34* testthat now requires R 4.1.
45* ` expect_s4_class() ` now supports unquoting (@stibu81 , #2064 ).
56* ` it() ` now finds the correct evaluation environment in more cases (@averissimo , #2085 ).
Original file line number Diff line number Diff line change @@ -61,8 +61,7 @@ edition_name <- function(x) {
6161# ' @param x Edition Should be a single integer.
6262# ' @param .env Environment that controls scope of changes. For expert use only.
6363local_edition <- function (x , .env = parent.frame()) {
64- stopifnot(is_zap(x ) || (is.numeric(x ) && length(x ) == 1 ))
65-
64+ check_number_whole(x , min = 2 , max = 3 )
6665 local_bindings(edition = x , .env = the , .frame = .env )
6766}
6867
Original file line number Diff line number Diff line change 1+ # checks its inputs
2+
3+ Code
4+ local_edition("x")
5+ Condition
6+ Error in `local_edition()`:
7+ ! `x` must be a whole number, not the string "x".
8+ Code
9+ local_edition(5)
10+ Condition
11+ Error in `local_edition()`:
12+ ! `x` must be a whole number between 2 and 3, not the number 5.
13+
114# deprecation only fired for newer edition
215
316 Code
Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ test_that("can locally override edition", {
66 expect_equal(edition_get(), 2 )
77})
88
9+ test_that(" checks its inputs" , {
10+ expect_snapshot(error = TRUE , {
11+ local_edition(" x" )
12+ local_edition(5 )
13+ })
14+ })
15+
916test_that(" deprecation only fired for newer edition" , {
1017 local_edition(2 )
1118 expect_warning(edition_deprecate(3 , " old stuff" ), NA )
@@ -34,7 +41,8 @@ test_that("edition for non-package dir is 2", {
3441})
3542
3643test_that(" can set the edition via an environment variable" , {
37- local_edition(zap())
44+ local_bindings(edition = zap(), .env = the )
45+
3846 withr :: local_envvar(TESTTHAT_EDITION = 2 )
3947 expect_equal(edition_get(), 2 )
4048
You can’t perform that action at this time.
0 commit comments