Skip to content

Commit cda3baa

Browse files
krlmlrgithub-actions[bot]
authored andcommitted
[create-pull-request] automated change
1 parent 51ba55e commit cda3baa

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

tests/testthat/_snaps/dplyr-case-match.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
case_match(1, 1 ~ 1L, .default = "x")
2121
Condition
2222
Error in `case_match()`:
23-
! Can't combine `..1 (right)` <integer> and `.default` <character>.
23+
! Can't combine <integer> and `.default` <character>.
2424

2525
# `NULL` formula element throws meaningful error
2626

tests/testthat/_snaps/dplyr-case-when.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
case_when(FALSE ~ 1L, .default = 2:5)
55
Condition
66
Error in `case_when()`:
7-
! `.default` must have size 1, not size 4.
7+
! Can't recycle `.default` (size 4) to size 1.
88

99
# `.default` is part of common type computation
1010

1111
Code
1212
case_when(TRUE ~ 1L, .default = "x")
1313
Condition
1414
Error in `case_when()`:
15-
! Can't combine `..1 (right)` <integer> and `.default` <character>.
15+
! Can't combine <integer> and `.default` <character>.
1616

1717
# passes through `.size` correctly
1818

@@ -35,8 +35,27 @@
3535
Code
3636
case_when(1 ~ NULL)
3737
Condition
38-
Error in `case_when()`:
39-
! `..1 (right)` must be a vector, not `NULL`.
38+
Warning:
39+
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
40+
i This `case_when()` statement can result in subtle silent bugs and is very inefficient.
41+
42+
Please use a series of if statements instead:
43+
44+
```
45+
# Previously
46+
case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default)
47+
48+
# Now
49+
if (scalar_lhs1) {
50+
rhs1
51+
} else if (scalar_lhs2) {
52+
rhs2
53+
} else {
54+
default
55+
}
56+
```
57+
Error in `case_when()`:
58+
! `..1 (left)` must be a logical vector, not an empty numeric vector.
4059

4160
---
4261

@@ -73,7 +92,7 @@
7392
Output
7493
<error/vctrs_error_incompatible_size>
7594
Error in `case_when()`:
76-
! Can't recycle `..1 (left)` (size 2) to match `..1 (right)` (size 3).
95+
! Can't recycle `..1 (right)` (size 3) to match `..2 (right)` (size 2).
7796
Code
7897
(expect_error(case_when(c(TRUE, FALSE) ~ 1, c(FALSE, TRUE, FALSE) ~ 2, c(FALSE,
7998
TRUE, FALSE, NA) ~ 3)))
@@ -83,6 +102,26 @@
83102
! Can't recycle `..1 (left)` (size 2) to match `..2 (left)` (size 3).
84103
Code
85104
(expect_error(case_when(50 ~ 1:3)))
105+
Condition
106+
Warning:
107+
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
108+
i This `case_when()` statement can result in subtle silent bugs and is very inefficient.
109+
110+
Please use a series of if statements instead:
111+
112+
```
113+
# Previously
114+
case_when(scalar_lhs1 ~ rhs1, scalar_lhs2 ~ rhs2, .default = default)
115+
116+
# Now
117+
if (scalar_lhs1) {
118+
rhs1
119+
} else if (scalar_lhs2) {
120+
rhs2
121+
} else {
122+
default
123+
}
124+
```
86125
Output
87126
<error/rlang_error>
88127
Error in `case_when()`:

tests/testthat/_snaps/dplyr-coalesce.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
coalesce(NULL, NULL)
3636
Condition
3737
Error in `coalesce()`:
38-
! `...` can't be empty.
38+
! `...` must contain at least 1 non-`NULL` value.
3939

4040
# inputs must be vectors
4141

tests/testthat/_snaps/dplyr-if-else.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@
2828
if_else(x < 2, bad, x)
2929
Condition
3030
Error in `if_else()`:
31-
! `true` must have size 3, not size 2.
31+
! Can't recycle `true` (size 2) to size 3.
3232

3333
---
3434

3535
Code
3636
if_else(x < 2, x, bad)
3737
Condition
3838
Error in `if_else()`:
39-
! `false` must have size 3, not size 2.
39+
! Can't recycle `false` (size 2) to size 3.
4040

4141
---
4242

4343
Code
4444
if_else(x < 2, x, x, missing = bad)
4545
Condition
4646
Error in `if_else()`:
47-
! `missing` must have size 3, not size 2.
47+
! Can't recycle `missing` (size 2) to size 3.
4848

4949
# must have empty dots
5050

@@ -66,11 +66,3 @@
6666
! Can't convert from `false` <double> to <integer> due to loss of precision.
6767
* Locations: 1
6868

69-
# `size` overrides the `condition` size
70-
71-
Code
72-
if_else(TRUE, 1, 2, size = 2)
73-
Condition
74-
Error in `if_else()`:
75-
! `condition` must have size 2, not size 1.
76-

0 commit comments

Comments
 (0)