Skip to content

Commit

Permalink
Add allow_infinite to check_number_whole()
Browse files Browse the repository at this point in the history
  • Loading branch information
mgirlich committed Mar 8, 2023
1 parent ec1291a commit ce0f594
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# rlang (development version)

* Added `allow_infinite` argument to `check_number_whole()` (#1588, @mgirlich).

# rlang 1.1.0

## Life cycle changes
Expand Down
6 changes: 5 additions & 1 deletion R/standalone-types-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#
# ## Changelog
#
# 2023-03-08:
# - Added `allow_infinite` argument to `check_number_whole()`.
#
# 2023-02-15:
# - Added `check_logical()`.
#
Expand Down Expand Up @@ -194,6 +197,7 @@ check_number_whole <- function(x,
...,
min = NULL,
max = NULL,
allow_infinite = FALSE,
allow_na = FALSE,
allow_null = FALSE,
arg = caller_arg(x),
Expand All @@ -206,7 +210,7 @@ check_number_whole <- function(x,
allow_decimal = FALSE,
min,
max,
allow_infinite = FALSE,
allow_infinite,
allow_na,
allow_null
))) {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-standalone-types-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ test_that("`check_number_whole()` checks", {
expect_null(check_number_whole(na_dbl, allow_na = TRUE))
expect_null(check_number_whole(na_int, allow_na = TRUE))
expect_null(check_number_whole(NULL, allow_null = TRUE))
expect_null(check_number_whole(Inf, allow_infinite = TRUE))
expect_null(check_number_whole(-Inf, allow_infinite = TRUE))

check_number_whole(0, max = 0)
check_number_whole(0, min = 0)
Expand Down

0 comments on commit ce0f594

Please sign in to comment.