Skip to content

Commit c0e189e

Browse files
committed
Bring over a few tests from vec_case_when()
1 parent 6c12101 commit c0e189e

File tree

3 files changed

+78
-327
lines changed

3 files changed

+78
-327
lines changed

tests/testthat/_snaps/case-when.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
# case_when() conditions must be logical (and aren't cast to logical!)
2+
3+
Code
4+
case_when(1 ~ 2)
5+
Condition
6+
Error in `case_when()`:
7+
! `..1 (left)` must be a logical vector, not the number 1.
8+
9+
---
10+
11+
Code
12+
case_when(TRUE ~ 2, 3.5 ~ 4)
13+
Condition
14+
Error in `case_when()`:
15+
! `..2 (left)` must be a logical vector, not the number 3.5.
16+
17+
# case_when() does not accept classed logical conditions
18+
19+
Code
20+
case_when(x ~ 1)
21+
Condition
22+
Error in `case_when()`:
23+
! `..1 (left)` must be a logical vector, not a <my_logical> object.
24+
25+
# case_when() logical conditions can't be arrays (#6862)
26+
27+
Code
28+
case_when(x ~ y)
29+
Condition
30+
Error in `case_when()`:
31+
! `..1 (left)` must be a logical vector, not a logical matrix.
32+
33+
---
34+
35+
Code
36+
case_when(x ~ y)
37+
Condition
38+
Error in `case_when()`:
39+
! `..1 (left)` must be a logical vector, not a logical 1D array.
40+
141
# `.default` isn't part of recycling
242

343
Code
@@ -33,7 +73,7 @@
3373
# `NULL` formula element throws meaningful error
3474

3575
Code
36-
case_when(1 ~ NULL)
76+
case_when(TRUE ~ NULL)
3777
Condition
3878
Warning:
3979
Calling `case_when()` with size 1 LHS inputs and size >1 RHS inputs was deprecated in dplyr 1.2.0.
@@ -63,7 +103,7 @@
63103
case_when(NULL ~ 1)
64104
Condition
65105
Error in `case_when()`:
66-
! `..1 (left)` must be a vector, not `NULL`.
106+
! `..1 (left)` must be a logical vector, not `NULL`.
67107

68108
# throws chained errors when formula evaluation fails
69109

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

Lines changed: 0 additions & 323 deletions
This file was deleted.

0 commit comments

Comments
 (0)