diff --git a/tests/testthat/_snaps/dplyr-case-match.md b/tests/testthat/_snaps/dplyr-case-match.md index 5d4bee45a..79e55bcc4 100644 --- a/tests/testthat/_snaps/dplyr-case-match.md +++ b/tests/testthat/_snaps/dplyr-case-match.md @@ -4,7 +4,7 @@ case_match(1) Condition Error in `case_match()`: - ! At least one condition must be supplied. + ! `...` can't be empty. --- @@ -12,7 +12,7 @@ case_match(1, NULL) Condition Error in `case_match()`: - ! At least one condition must be supplied. + ! `...` can't be empty. # `.default` is part of common type computation @@ -20,7 +20,7 @@ case_match(1, 1 ~ 1L, .default = "x") Condition Error in `case_match()`: - ! Can't combine `..1 (right)` and `.default` . + ! Can't combine and `.default` . # `NULL` formula element throws meaningful error @@ -29,6 +29,7 @@ Condition Error in `case_match()`: ! `..1 (right)` must be a vector, not `NULL`. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. --- @@ -37,6 +38,7 @@ Condition Error in `case_match()`: ! `..1 (left)` must be a vector, not `NULL`. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. # throws chained errors when formula evaluation fails diff --git a/tests/testthat/_snaps/dplyr-case-when.md b/tests/testthat/_snaps/dplyr-case-when.md index 0945263f7..98269f411 100644 --- a/tests/testthat/_snaps/dplyr-case-when.md +++ b/tests/testthat/_snaps/dplyr-case-when.md @@ -4,7 +4,7 @@ case_when(FALSE ~ 1L, .default = 2:5) Condition Error in `case_when()`: - ! `.default` must have size 1, not size 4. + ! Can't recycle `.default` (size 4) to size 1. # `.default` is part of common type computation @@ -12,7 +12,7 @@ case_when(TRUE ~ 1L, .default = "x") Condition Error in `case_when()`: - ! Can't combine `..1 (right)` and `.default` . + ! Can't combine and `.default` . # passes through `.size` correctly @@ -35,8 +35,27 @@ Code case_when(1 ~ NULL) Condition - Error in `case_when()`: - ! `..1 (right)` must be a vector, not `NULL`. + Warning: + Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0. + i This `case_when()` statement can result in subtle silent bugs and is very inefficient. + + Please use a series of if statements instead: + + ``` + # Previously + case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default) + + # Now + if (scalar_lhs1) { + rhs1 + } else if (scalar_lhs2) { + rhs2 + } else { + default + } + ``` + Error in `case_when()`: + ! `..1 (left)` must be a logical vector, not an empty numeric vector. --- @@ -73,7 +92,7 @@ Output Error in `case_when()`: - ! Can't recycle `..1 (left)` (size 2) to match `..1 (right)` (size 3). + ! Can't recycle `..1 (right)` (size 3) to match `..2 (right)` (size 2). Code (expect_error(case_when(c(TRUE, FALSE) ~ 1, c(FALSE, TRUE, FALSE) ~ 2, c(FALSE, TRUE, FALSE, NA) ~ 3))) @@ -83,6 +102,26 @@ ! Can't recycle `..1 (left)` (size 2) to match `..2 (left)` (size 3). Code (expect_error(case_when(50 ~ 1:3))) + Condition + Warning: + Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0. + i This `case_when()` statement can result in subtle silent bugs and is very inefficient. + + Please use a series of if statements instead: + + ``` + # Previously + case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default) + + # Now + if (scalar_lhs1) { + rhs1 + } else if (scalar_lhs2) { + rhs2 + } else { + default + } + ``` Output Error in `case_when()`: @@ -104,17 +143,17 @@ Output Error in `case_when()`: - ! At least one condition must be supplied. + ! `...` can't be empty. Code (expect_error(case_when(NULL))) Output Error in `case_when()`: - ! At least one condition must be supplied. + ! `...` can't be empty. Code (expect_error(case_when(~ 1:2))) Output Error in `case_when()`: - ! Case 1 (`~1:2`) must be a two-sided formula. + ! Case 1 (`~1:2`) must be a two-sided formula, not a one-sided formula. diff --git a/tests/testthat/_snaps/dplyr-coalesce.md b/tests/testthat/_snaps/dplyr-coalesce.md index f78e286df..476cdd4f6 100644 --- a/tests/testthat/_snaps/dplyr-coalesce.md +++ b/tests/testthat/_snaps/dplyr-coalesce.md @@ -35,7 +35,7 @@ coalesce(NULL, NULL) Condition Error in `coalesce()`: - ! `...` can't be empty. + ! `...` must contain at least 1 non-`NULL` value. # inputs must be vectors @@ -44,6 +44,7 @@ Condition Error in `coalesce()`: ! `..2` must be a vector, not an environment. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. # names in error messages are indexed correctly diff --git a/tests/testthat/_snaps/dplyr-consecutive-id.md b/tests/testthat/_snaps/dplyr-consecutive-id.md index 5a8fcdf2c..9a6904682 100644 --- a/tests/testthat/_snaps/dplyr-consecutive-id.md +++ b/tests/testthat/_snaps/dplyr-consecutive-id.md @@ -20,4 +20,5 @@ Condition Error in `consecutive_id()`: ! `..1` must be a vector, not a function. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. diff --git a/tests/testthat/_snaps/dplyr-desc.md b/tests/testthat/_snaps/dplyr-desc.md index 5f5d4f164..5de21ac02 100644 --- a/tests/testthat/_snaps/dplyr-desc.md +++ b/tests/testthat/_snaps/dplyr-desc.md @@ -5,4 +5,5 @@ Condition Error in `desc()`: ! `x` must be a vector, not a function. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. diff --git a/tests/testthat/_snaps/dplyr-if-else.md b/tests/testthat/_snaps/dplyr-if-else.md index cb779fdff..2fadae8eb 100644 --- a/tests/testthat/_snaps/dplyr-if-else.md +++ b/tests/testthat/_snaps/dplyr-if-else.md @@ -28,7 +28,7 @@ if_else(x < 2, bad, x) Condition Error in `if_else()`: - ! `true` must have size 3, not size 2. + ! Can't recycle `true` (size 2) to size 3. --- @@ -36,7 +36,7 @@ if_else(x < 2, x, bad) Condition Error in `if_else()`: - ! `false` must have size 3, not size 2. + ! Can't recycle `false` (size 2) to size 3. --- @@ -44,7 +44,7 @@ if_else(x < 2, x, x, missing = bad) Condition Error in `if_else()`: - ! `missing` must have size 3, not size 2. + ! Can't recycle `missing` (size 2) to size 3. # must have empty dots @@ -66,11 +66,3 @@ ! Can't convert from `false` to due to loss of precision. * Locations: 1 -# `size` overrides the `condition` size - - Code - if_else(TRUE, 1, 2, size = 2) - Condition - Error in `if_else()`: - ! `condition` must have size 2, not size 1. - diff --git a/tests/testthat/_snaps/dplyr-lead-lag.md b/tests/testthat/_snaps/dplyr-lead-lag.md index ef2bce01d..b054534d8 100644 --- a/tests/testthat/_snaps/dplyr-lead-lag.md +++ b/tests/testthat/_snaps/dplyr-lead-lag.md @@ -59,6 +59,7 @@ Condition Error in `lead()`: ! `x` must be a vector, not an environment. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. --- @@ -67,4 +68,5 @@ Condition Error in `lag()`: ! `x` must be a vector, not an environment. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. diff --git a/tests/testthat/_snaps/dplyr-n-distinct.md b/tests/testthat/_snaps/dplyr-n-distinct.md index ad43e4584..c31dd7967 100644 --- a/tests/testthat/_snaps/dplyr-n-distinct.md +++ b/tests/testthat/_snaps/dplyr-n-distinct.md @@ -17,4 +17,5 @@ Condition Error in `n_distinct()`: ! `..1` must be a vector, not a function. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. diff --git a/tests/testthat/_snaps/dplyr-na-if.md b/tests/testthat/_snaps/dplyr-na-if.md index b153cb3a6..aa224b31f 100644 --- a/tests/testthat/_snaps/dplyr-na-if.md +++ b/tests/testthat/_snaps/dplyr-na-if.md @@ -38,6 +38,7 @@ Condition Error in `na_if()`: ! `x` must be a vector, not an environment. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. --- @@ -46,4 +47,5 @@ Condition Error in `na_if()`: ! `y` must be a vector, not an environment. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. diff --git a/tests/testthat/_snaps/dplyr-nth-value.md b/tests/testthat/_snaps/dplyr-nth-value.md index f4def1989..377dc08ba 100644 --- a/tests/testthat/_snaps/dplyr-nth-value.md +++ b/tests/testthat/_snaps/dplyr-nth-value.md @@ -61,6 +61,7 @@ Condition Error in `vec_size()`: ! `x` must be a vector, not an environment. + i Read our FAQ about scalar types (`?vctrs::faq_error_scalar_type`) to learn more. # `order_by` must be the same size as `x`