@@ -581,6 +581,14 @@ test_that("replace_values()", {
581581 tbl
582582 )
583583
584+ # from/to with list of vectors - multiple values map to single replacement
585+ compare_dplyr_binding(
586+ .input | >
587+ mutate(result = replace_values(chr , from = list (c(" a" , " b" ), " c" ), to = c(" AB" , " C" ))) | >
588+ collect(),
589+ tbl
590+ )
591+
584592 # unmatched values kept
585593 compare_dplyr_binding(
586594 .input | >
@@ -630,6 +638,11 @@ test_that("replace_values()", {
630638 )
631639
632640 # validation errors
641+ expect_arrow_eval_error(
642+ replace_values(chr , " A" ),
643+ " Each argument to replace_values\\ (\\ ) must be a two-sided formula" ,
644+ class = " validation_error"
645+ )
633646 expect_arrow_eval_error(
634647 replace_values(chr , " a" ~ " A" , from = " b" ),
635648 " Can't use both `...` and `from`/`to` in replace_values\\ (\\ )" ,
@@ -659,6 +672,14 @@ test_that("recode_values()", {
659672 tbl
660673 )
661674
675+ # from/to with list of vectors - multiple values map to single replacement
676+ compare_dplyr_binding(
677+ .input | >
678+ mutate(result = recode_values(chr , from = list (c(" a" , " b" ), " c" ), to = c(" AB" , " C" ))) | >
679+ collect(),
680+ tbl
681+ )
682+
662683 # custom default
663684 compare_dplyr_binding(
664685 .input | >
@@ -697,6 +718,11 @@ test_that("recode_values()", {
697718 " `\\ .\\ .\\ .` can't be empty" ,
698719 class = " validation_error"
699720 )
721+ expect_arrow_eval_error(
722+ recode_values(chr , " A" ),
723+ " Each argument to recode_values\\ (\\ ) must be a two-sided formula" ,
724+ class = " validation_error"
725+ )
700726 expect_arrow_eval_error(
701727 recode_values(chr , " a" ~ " A" , from = " b" ),
702728 " Can't use both `...` and `from`/`to` in recode_values\\ (\\ )" ,
0 commit comments