From 55913992ad117177cecdef35576e98e457c8ca0e Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 17 Dec 2021 11:24:52 +0100 Subject: [PATCH 1/3] Update snapshots with latest rlang --- DESCRIPTION | 2 +- tests/testthat/_snaps/across.md | 122 ++++---- tests/testthat/_snaps/all-equal.md | 6 +- tests/testthat/_snaps/arrange.md | 16 +- tests/testthat/_snaps/bind.md | 36 ++- tests/testthat/_snaps/case-when.md | 18 +- tests/testthat/_snaps/coalesce.md | 6 +- tests/testthat/_snaps/colwise-filter.md | 6 +- tests/testthat/_snaps/colwise-mutate.md | 14 +- tests/testthat/_snaps/colwise-select.md | 24 +- tests/testthat/_snaps/colwise.md | 9 +- tests/testthat/_snaps/conditions.md | 125 ++++---- tests/testthat/_snaps/context.md | 21 +- tests/testthat/_snaps/deprec-combine.md | 9 +- tests/testthat/_snaps/deprec-dbi.md | 3 +- tests/testthat/_snaps/deprec-do.md | 15 +- tests/testthat/_snaps/deprec-funs.md | 9 +- tests/testthat/_snaps/deprec-src-local.md | 9 +- tests/testthat/_snaps/distinct.md | 15 +- tests/testthat/_snaps/filter.md | 68 +++-- tests/testthat/_snaps/group-by.md | 22 +- tests/testthat/_snaps/group_map.md | 12 +- tests/testthat/_snaps/grouped-df.md | 49 ++-- tests/testthat/_snaps/if-else.md | 15 +- tests/testthat/_snaps/join-cols.md | 30 +- tests/testthat/_snaps/join-rows.md | 3 +- tests/testthat/_snaps/lead-lag.md | 27 +- tests/testthat/_snaps/mutate.md | 68 +++-- tests/testthat/_snaps/na-if.md | 6 +- tests/testthat/_snaps/nth-value.md | 3 +- tests/testthat/_snaps/order-by.md | 6 +- tests/testthat/_snaps/recode.md | 18 +- tests/testthat/_snaps/rows.md | 24 +- tests/testthat/_snaps/rowwise.md | 30 +- tests/testthat/_snaps/sample.md | 48 +-- tests/testthat/_snaps/select.md | 18 +- tests/testthat/_snaps/sets.md | 15 +- tests/testthat/_snaps/slice.md | 337 +++++++++++----------- tests/testthat/_snaps/summarise.md | 66 +++-- tests/testthat/_snaps/transmute.md | 9 +- tests/testthat/_snaps/utils.md | 11 +- tests/testthat/_snaps/window.md | 3 +- 42 files changed, 784 insertions(+), 569 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a27994a417..e7f5ace224 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Imports: magrittr (>= 1.5), methods, R6, - rlang (>= 0.99.0.9001), + rlang (>= 0.99.0.9003), tibble (>= 2.1.3), tidyselect (>= 1.1.1), utils, diff --git a/tests/testthat/_snaps/across.md b/tests/testthat/_snaps/across.md index e6363eca7e..e353ad2efe 100644 --- a/tests/testthat/_snaps/across.md +++ b/tests/testthat/_snaps/across.md @@ -5,76 +5,78 @@ Output Error in `summarise()`: - Problem while computing `..1 = across(where(is.numeric), 42)`. + ! Problem while computing `..1 = across(where(is.numeric), 42)`. Caused by error in `across()`: - `.fns` must be NULL, a function, a formula, or a list of functions/formulas. + ! `.fns` must be NULL, a function, a formula, or a list of functions/formulas. Code (expect_error(tibble(x = 1) %>% summarise(across(y, mean)))) Output Error in `summarise()`: - Problem while computing `..1 = across(y, mean)`. + ! Problem while computing `..1 = across(y, mean)`. Caused by error in `across()`: - Can't subset columns that don't exist. - x Column `y` doesn't exist. + ! Can't subset columns that don't exist. + x Column `y` doesn't exist. Code (expect_error(tibble(x = 1) %>% summarise(res = across(where(is.numeric), 42)))) Output Error in `summarise()`: - Problem while computing `res = across(where(is.numeric), 42)`. + ! Problem while computing `res = across(where(is.numeric), 42)`. Caused by error in `across()`: - `.fns` must be NULL, a function, a formula, or a list of functions/formulas. + ! `.fns` must be NULL, a function, a formula, or a list of functions/formulas. Code (expect_error(tibble(x = 1) %>% summarise(z = across(y, mean)))) Output Error in `summarise()`: - Problem while computing `z = across(y, mean)`. + ! Problem while computing `z = across(y, mean)`. Caused by error in `across()`: - Can't subset columns that don't exist. - x Column `y` doesn't exist. + ! Can't subset columns that don't exist. + x Column `y` doesn't exist. Code (expect_error(tibble(x = 1) %>% summarise(res = sum(if_any(where(is.numeric), 42))))) Output Error in `summarise()`: - Problem while computing `res = sum(if_any(where(is.numeric), 42))`. + ! Problem while computing `res = sum(if_any(where(is.numeric), 42))`. Caused by error in `if_any()`: - `.fns` must be NULL, a function, a formula, or a list of functions/formulas. + ! `.fns` must be NULL, a function, a formula, or a list of functions/formulas. Code (expect_error(tibble(x = 1) %>% summarise(res = sum(if_all(~ mean(.x)))))) Output Error in `summarise()`: - Problem while computing `res = sum(if_all(~mean(.x)))`. + ! Problem while computing `res = sum(if_all(~mean(.x)))`. Caused by error in `if_all()`: - Must supply a column selection. - i You most likely meant: `if_all(everything(), ~mean(.x))`. - i The first argument `.cols` selects a set of columns. - i The second argument `.fns` operates on each selected columns. + ! Must supply a column selection. + i You most likely meant: `if_all(everything(), ~mean(.x))`. + i The first argument `.cols` selects a set of columns. + i The second argument `.fns` operates on each selected columns. Code (expect_error(tibble(x = 1) %>% summarise(res = sum(if_any(~ mean(.x)))))) Output Error in `summarise()`: - Problem while computing `res = sum(if_any(~mean(.x)))`. + ! Problem while computing `res = sum(if_any(~mean(.x)))`. Caused by error in `if_any()`: - Must supply a column selection. - i You most likely meant: `if_any(everything(), ~mean(.x))`. - i The first argument `.cols` selects a set of columns. - i The second argument `.fns` operates on each selected columns. + ! Must supply a column selection. + i You most likely meant: `if_any(everything(), ~mean(.x))`. + i The first argument `.cols` selects a set of columns. + i The second argument `.fns` operates on each selected columns. Code (expect_error(across())) Output - Error in `across()`: Must be used inside dplyr verbs. + Error in `across()`: + ! Must be used inside dplyr verbs. Code (expect_error(c_across())) Output - Error in `c_across()`: Must be used inside dplyr verbs. + Error in `c_across()`: + ! Must be used inside dplyr verbs. Code error_fn <- (function(.) { if (all(. > 10)) { @@ -88,55 +90,55 @@ Output Error in `summarise()`: - Problem while computing `..1 = across(everything(), error_fn)`. + ! Problem while computing `..1 = across(everything(), error_fn)`. Caused by error in `across()`: - Problem while computing column `y`. + ! Problem while computing column `y`. Caused by error in `error_fn()`: - too small + ! too small Code (expect_error(tibble(x = 1:10, y = 11:20) %>% mutate(across(everything(), error_fn)))) Output Error in `mutate()`: - Problem while computing `..1 = across(everything(), error_fn)`. + ! Problem while computing `..1 = across(everything(), error_fn)`. Caused by error in `across()`: - Problem while computing column `y`. + ! Problem while computing column `y`. Caused by error in `error_fn()`: - too small + ! too small Code (expect_error(tibble(x = 1:10, y = 11:20) %>% summarise(force(across(everything(), error_fn))))) Output Error in `summarise()`: - Problem while computing `..1 = force(across(everything(), error_fn))`. + ! Problem while computing `..1 = force(across(everything(), error_fn))`. Caused by error in `across()`: - Problem while computing column `y`. + ! Problem while computing column `y`. Caused by error in `error_fn()`: - too small + ! too small Code (expect_error(tibble(x = 1:10, y = 11:20) %>% mutate(force(across(everything(), error_fn))))) Output Error in `mutate()`: - Problem while computing `..1 = force(across(everything(), error_fn))`. + ! Problem while computing `..1 = force(across(everything(), error_fn))`. Caused by error in `across()`: - Problem while computing column `y`. + ! Problem while computing column `y`. Caused by error in `error_fn()`: - too small + ! too small Code (expect_error(tibble(x = 1) %>% summarise(across(everything(), list(f = mean, f = mean))))) Output Error in `summarise()`: - Problem while computing `..1 = across(everything(), list(f = mean, f = mean))`. + ! Problem while computing `..1 = across(everything(), list(f = mean, f = mean))`. Caused by error in `across()`: - Names must be unique. - x These names are duplicated: - * "x_f" at locations 1 and 2. + ! Names must be unique. + x These names are duplicated: + * "x_f" at locations 1 and 2. # if_any() and if_all() aborts when predicate mistakingly used in .cols= (#5732) @@ -145,43 +147,43 @@ Output Error in `filter()`: - Problem while expanding `..1 = if_any(~.x > 5)`. + ! Problem while expanding `..1 = if_any(~.x > 5)`. Caused by error in `if_any()`: - Must supply a column selection. - i You most likely meant: `if_any(everything(), ~.x > 5)`. - i The first argument `.cols` selects a set of columns. - i The second argument `.fns` operates on each selected columns. + ! Must supply a column selection. + i You most likely meant: `if_any(everything(), ~.x > 5)`. + i The first argument `.cols` selects a set of columns. + i The second argument `.fns` operates on each selected columns. Code (expect_error(filter(df, if_all(~ .x > 5)))) Output Error in `filter()`: - Problem while expanding `..1 = if_all(~.x > 5)`. + ! Problem while expanding `..1 = if_all(~.x > 5)`. Caused by error in `if_all()`: - Must supply a column selection. - i You most likely meant: `if_all(everything(), ~.x > 5)`. - i The first argument `.cols` selects a set of columns. - i The second argument `.fns` operates on each selected columns. + ! Must supply a column selection. + i You most likely meant: `if_all(everything(), ~.x > 5)`. + i The first argument `.cols` selects a set of columns. + i The second argument `.fns` operates on each selected columns. Code (expect_error(filter(df, !if_any(~ .x > 5)))) Output Error in `filter()`: - Problem while computing `..1 = !if_any(~.x > 5)`. + ! Problem while computing `..1 = !if_any(~.x > 5)`. Caused by error in `if_any()`: - Must supply a column selection. - i You most likely meant: `if_any(everything(), ~.x > 5)`. - i The first argument `.cols` selects a set of columns. - i The second argument `.fns` operates on each selected columns. + ! Must supply a column selection. + i You most likely meant: `if_any(everything(), ~.x > 5)`. + i The first argument `.cols` selects a set of columns. + i The second argument `.fns` operates on each selected columns. Code (expect_error(filter(df, !if_all(~ .x > 5)))) Output Error in `filter()`: - Problem while computing `..1 = !if_all(~.x > 5)`. + ! Problem while computing `..1 = !if_all(~.x > 5)`. Caused by error in `if_all()`: - Must supply a column selection. - i You most likely meant: `if_all(everything(), ~.x > 5)`. - i The first argument `.cols` selects a set of columns. - i The second argument `.fns` operates on each selected columns. + ! Must supply a column selection. + i You most likely meant: `if_all(everything(), ~.x > 5)`. + i The first argument `.cols` selects a set of columns. + i The second argument `.fns` operates on each selected columns. diff --git a/tests/testthat/_snaps/all-equal.md b/tests/testthat/_snaps/all-equal.md index 4ed7c4cb3c..9d3c54ca8c 100644 --- a/tests/testthat/_snaps/all-equal.md +++ b/tests/testthat/_snaps/all-equal.md @@ -100,13 +100,15 @@ (expect_error(union(tibble(a = 1), tibble(a = "1")))) Output - Error in `union()`: `x` and `y` are not compatible. + Error in `union()`: + ! `x` and `y` are not compatible. x Incompatible types for column `a`: double vs character. Code (expect_error(union(tibble(a = 1, b = 2), tibble(a = "1", b = "2")))) Output - Error in `union()`: `x` and `y` are not compatible. + Error in `union()`: + ! `x` and `y` are not compatible. x Incompatible types for column `a`: double vs character. x Incompatible types for column `b`: double vs character. diff --git a/tests/testthat/_snaps/arrange.md b/tests/testthat/_snaps/arrange.md index 489fd3b7e9..ca3180b812 100644 --- a/tests/testthat/_snaps/arrange.md +++ b/tests/testthat/_snaps/arrange.md @@ -5,23 +5,24 @@ Output Error in `arrange()`: - Problem with the implicit `transmute()` step. + ! Problem with the implicit `transmute()` step. Caused by error in `transmute()`: - Can't transform a data frame with duplicate names. + ! Can't transform a data frame with duplicate names. Code (expect_error(tibble(x = 1) %>% arrange(y))) Output Error in `arrange()`: - Problem with the implicit `transmute()` step. - x Problem while computing `..1 = y`. + ! Problem with the implicit `transmute()` step. + x Problem while computing `..1 = y`. Caused by error: - object 'y' not found + ! object 'y' not found Code (expect_error(tibble(x = 1) %>% arrange(rep(x, 2)))) Output - Error in `arrange()`: Problem with the implicit `transmute()` step. + Error in `arrange()`: + ! Problem with the implicit `transmute()` step. x Problem while computing `..1 = rep(x, 2)`. i `..1` must be size 1, not 2. @@ -32,5 +33,6 @@ (expect_error(arrange(df, desc(x, y)))) Output - Error in `arrange()`: `desc()` must be called with exactly one argument. + Error in `arrange()`: + ! `desc()` must be called with exactly one argument. diff --git a/tests/testthat/_snaps/bind.md b/tests/testthat/_snaps/bind.md index 3108d005dd..68b05f72d4 100644 --- a/tests/testthat/_snaps/bind.md +++ b/tests/testthat/_snaps/bind.md @@ -26,19 +26,22 @@ (expect_error(bind_rows(df1, df2, .id = 5))) Output - Error in `bind_rows()`: `.id` must be a scalar string, not a double vector of length 1. + Error in `bind_rows()`: + ! `.id` must be a scalar string, not a double vector of length 1. Code ll <- list(1:5, env(a = 1)) (expect_error(bind_rows(ll))) Output - Error in `bind_rows()`: Argument 1 must have names. + Error in `bind_rows()`: + ! Argument 1 must have names. Code ll <- list(tibble(a = 1:5), env(a = 1)) (expect_error(bind_rows(ll))) Output - Error in `bind_rows()`: Argument 2 must be a data frame or a named atomic vector. + Error in `bind_rows()`: + ! Argument 2 must be a data frame or a named atomic vector. Code df1 <- tibble(a = factor("a")) df2 <- tibble(a = 1L) @@ -46,12 +49,14 @@ (expect_error(bind_rows(df1, df2))) Output - Error in `bind_rows()`: Can't combine `..1$a` > and `..2$a` . + Error in `bind_rows()`: + ! Can't combine `..1$a` > and `..2$a` . Code (expect_error(bind_rows(df1, df3))) Output - Error in `bind_rows()`: Can't combine `..1$a` > and `..2$a` . + Error in `bind_rows()`: + ! Can't combine `..1$a` > and `..2$a` . Code df1 <- tibble(b = c(1, 2)) df2 <- tibble(b = c(1L, 2L)) @@ -60,37 +65,44 @@ (expect_error(bind_rows(df1, df3))) Output - Error in `bind_rows()`: Can't combine `..1$b` and `..2$b` >. + Error in `bind_rows()`: + ! Can't combine `..1$b` and `..2$b` >. Code (expect_error(bind_rows(df1, df4))) Output - Error in `bind_rows()`: Can't combine `..1$b` and `..2$b` . + Error in `bind_rows()`: + ! Can't combine `..1$b` and `..2$b` . Code (expect_error(bind_rows(df2, df3))) Output - Error in `bind_rows()`: Can't combine `..1$b` and `..2$b` >. + Error in `bind_rows()`: + ! Can't combine `..1$b` and `..2$b` >. Code (expect_error(bind_rows(df2, df4))) Output - Error in `bind_rows()`: Can't combine `..1$b` and `..2$b` . + Error in `bind_rows()`: + ! Can't combine `..1$b` and `..2$b` . Code # # unnamed vectors (expect_error(bind_rows(1:2))) Output - Error in `bind_rows()`: Argument 1 must have names. + Error in `bind_rows()`: + ! Argument 1 must have names. Code # # incompatible size (expect_error(bind_cols(a = 1:2, mtcars))) Output - Error in `bind_cols()`: Can't recycle `a` (size 2) to match `..2` (size 32). + Error in `bind_cols()`: + ! Can't recycle `a` (size 2) to match `..2` (size 32). Code (expect_error(bind_cols(mtcars, a = 1:3))) Output - Error in `bind_cols()`: Can't recycle `..1` (size 32) to match `a` (size 3). + Error in `bind_cols()`: + ! Can't recycle `..1` (size 32) to match `a` (size 3). diff --git a/tests/testthat/_snaps/case-when.md b/tests/testthat/_snaps/case-when.md index 0b5237cebf..82569b30be 100644 --- a/tests/testthat/_snaps/case-when.md +++ b/tests/testthat/_snaps/case-when.md @@ -4,31 +4,37 @@ (expect_error(case_when(c(TRUE, FALSE) ~ 1:3, c(FALSE, TRUE) ~ 1:2))) Output - Error in `case_when()`: `c(TRUE, FALSE) ~ 1:3` must be length 2 or one, not 3. + Error in `case_when()`: + ! `c(TRUE, FALSE) ~ 1:3` must be length 2 or one, not 3. Code (expect_error(case_when(c(TRUE, FALSE) ~ 1, c(FALSE, TRUE, FALSE) ~ 2, c(FALSE, TRUE, FALSE, NA) ~ 3))) Output - Error in `case_when()`: `c(FALSE, TRUE, FALSE) ~ 2`, `c(FALSE, TRUE, FALSE, NA) ~ 3` must be length 2 or one, not 3, 4. + Error in `case_when()`: + ! `c(FALSE, TRUE, FALSE) ~ 2`, `c(FALSE, TRUE, FALSE, NA) ~ 3` must be length 2 or one, not 3, 4. Code (expect_error(case_when(50 ~ 1:3))) Output - Error in `case_when()`: LHS of case 1 (`50`) must be a logical vector, not a double vector. + Error in `case_when()`: + ! LHS of case 1 (`50`) must be a logical vector, not a double vector. Code (expect_error(case_when(paste(50)))) Output - Error in `case_when()`: Case 1 (`paste(50)`) must be a two-sided formula, not a character vector. + Error in `case_when()`: + ! Case 1 (`paste(50)`) must be a two-sided formula, not a character vector. Code (expect_error(case_when())) Output - Error in `case_when()`: No cases provided. + Error in `case_when()`: + ! No cases provided. Code (expect_error(case_when(~ 1:2))) Output - Error in `case_when()`: Formulas must be two-sided. + Error in `case_when()`: + ! Formulas must be two-sided. diff --git a/tests/testthat/_snaps/coalesce.md b/tests/testthat/_snaps/coalesce.md index 0de618fa4b..60cd2a5c60 100644 --- a/tests/testthat/_snaps/coalesce.md +++ b/tests/testthat/_snaps/coalesce.md @@ -4,10 +4,12 @@ (expect_error(coalesce(1:2, 1:3))) Output - Error in `coalesce()`: Can't recycle `..1` (size 2) to match `..2` (size 3). + Error in `coalesce()`: + ! Can't recycle `..1` (size 2) to match `..2` (size 3). Code (expect_error(coalesce(1:2, letters[1:2]))) Output - Error in `coalesce()`: Can't combine `..1` and `..2` . + Error in `coalesce()`: + ! Can't combine `..1` and `..2` . diff --git a/tests/testthat/_snaps/colwise-filter.md b/tests/testthat/_snaps/colwise-filter.md index ca05c080c6..c683434547 100644 --- a/tests/testthat/_snaps/colwise-filter.md +++ b/tests/testthat/_snaps/colwise-filter.md @@ -4,10 +4,12 @@ (expect_error(filter_if(mtcars, is_character, all_vars(. > 0)))) Output - Error in `filter_if()`: `.predicate` must match at least one column. + Error in `filter_if()`: + ! `.predicate` must match at least one column. Code (expect_error(filter_all(mtcars, list(~ . > 0)))) Output - Error in `filter_all()`: `.vars_predicate` must be a function or a call to `all_vars()` or `any_vars()`, not a list. + Error in `filter_all()`: + ! `.vars_predicate` must be a function or a call to `all_vars()` or `any_vars()`, not a list. diff --git a/tests/testthat/_snaps/colwise-mutate.md b/tests/testthat/_snaps/colwise-mutate.md index 0f08a8f256..7b6b826b46 100644 --- a/tests/testthat/_snaps/colwise-mutate.md +++ b/tests/testthat/_snaps/colwise-mutate.md @@ -12,7 +12,8 @@ (expect_error(mutate_at(tibble(), "test", ~1))) Output - Error in `mutate_at()`: Can't subset columns that don't exist. + Error in `mutate_at()`: + ! Can't subset columns that don't exist. x Column `test` doesn't exist. Code tbl <- tibble(gr1 = rep(1:2, 4), gr2 = rep(1:2, each = 4), x = 1:8) @@ -20,22 +21,23 @@ (expect_error(summarise_at(tbl, vars(gr1), mean))) Output - Error in `summarise_at()`: Can't subset columns that don't exist. + Error in `summarise_at()`: + ! Can't subset columns that don't exist. x Column `gr1` doesn't exist. Code (expect_error(mutate_all(mtcars, length, 0, 0))) Output Error in `mutate()`: - Problem while computing `mpg = .Primitive("length")(mpg, 0, 0)`. + ! Problem while computing `mpg = .Primitive("length")(mpg, 0, 0)`. Caused by error: - 3 arguments passed to 'length' which requires 1 + ! 3 arguments passed to 'length' which requires 1 Code (expect_error(mutate_all(mtcars, mean, na.rm = TRUE, na.rm = TRUE))) Output Error in `mutate()`: - Problem while computing `mpg = (function (x, ...) ...`. + ! Problem while computing `mpg = (function (x, ...) ...`. Caused by error in `mean.default()`: - formal argument "na.rm" matched by multiple actual arguments + ! formal argument "na.rm" matched by multiple actual arguments diff --git a/tests/testthat/_snaps/colwise-select.md b/tests/testthat/_snaps/colwise-select.md index 4321c836f6..f027eb22e3 100644 --- a/tests/testthat/_snaps/colwise-select.md +++ b/tests/testthat/_snaps/colwise-select.md @@ -5,44 +5,52 @@ (expect_error(df %>% rename_all())) Output - Error in `rename_all()`: `.funs` must specify a renaming function. + Error in `rename_all()`: + ! `.funs` must specify a renaming function. Code (expect_error(df %>% rename_if(is_integerish))) Output - Error in `rename_if()`: `.funs` must specify a renaming function. + Error in `rename_if()`: + ! `.funs` must specify a renaming function. Code (expect_error(df %>% rename_at(vars(x:y)))) Output - Error in `rename_at()`: `.funs` must specify a renaming function. + Error in `rename_at()`: + ! `.funs` must specify a renaming function. Code (expect_error(df %>% rename_all(list(tolower, toupper)))) Output - Error in `rename_all()`: `.funs` must contain one renaming function, not 2. + Error in `rename_all()`: + ! `.funs` must contain one renaming function, not 2. Code (expect_error(df %>% select_all(list(tolower, toupper)))) Output - Error in `select_all()`: `.funs` must contain one renaming function, not 2. + Error in `select_all()`: + ! `.funs` must contain one renaming function, not 2. Code (expect_error(df %>% select_if(function(.x) 1))) Output - Error in `select_if()`: `.p` is invalid. + Error in `select_if()`: + ! `.p` is invalid. x `.p` should return a single logical. i `.p` returns a for column `x`. Code (expect_error(df %>% select_if(function(.x) c(TRUE, TRUE)))) Output - Error in `select_if()`: `.p` is invalid. + Error in `select_if()`: + ! `.p` is invalid. x `.p` should return a single logical. i `.p` returns a size 2 for column `x`. Code (expect_error(data.frame() %>% select_all(.funs = 42))) Output - Error in `select_all()`: `.funs` must be a one sided formula, a function, or a function name. + Error in `select_all()`: + ! `.funs` must be a one sided formula, a function, or a function name. diff --git a/tests/testthat/_snaps/colwise.md b/tests/testthat/_snaps/colwise.md index 12c6fd015c..71419e6334 100644 --- a/tests/testthat/_snaps/colwise.md +++ b/tests/testthat/_snaps/colwise.md @@ -4,16 +4,19 @@ (expect_error(tbl_at_vars(iris, raw(3)))) Output - Error: `.vars` must be a character/numeric vector or a `vars()` object, not a raw vector. + Error: + ! `.vars` must be a character/numeric vector or a `vars()` object, not a raw vector. Code (expect_error(tbl_if_vars(iris, list(identity, force), environment()))) Output - Error: `.predicate` must have length 1, not 2. + Error: + ! `.predicate` must have length 1, not 2. Code .funs <- as_fun_list(list(identity, force), caller_env()) (expect_error(tbl_if_vars(iris, .funs, environment()))) Output - Error: `.predicate` must have length 1, not 2. + Error: + ! `.predicate` must have length 1, not 2. diff --git a/tests/testthat/_snaps/conditions.md b/tests/testthat/_snaps/conditions.md index 6fae446d14..399ace21f6 100644 --- a/tests/testthat/_snaps/conditions.md +++ b/tests/testthat/_snaps/conditions.md @@ -4,81 +4,84 @@ mutate(mtcars, invisible(999 + "")) Condition Error in `mutate()`: - Problem while computing `..1`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code summarise(mtcars, invisible(999 + "")) Condition Error in `summarise()`: - Problem while computing `..1`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code filter(mtcars, invisible(999 + "")) Condition Error in `filter()`: - Problem while computing `..1`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code arrange(mtcars, invisible(999 + "")) Condition Error in `arrange()`: - Problem with the implicit `transmute()` step. - x Problem while computing `..1`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem with the implicit `transmute()` step. + x Problem while computing `..1`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code select(mtcars, invisible(999 + "")) Condition - Error in `select()`: non-numeric argument to binary operator + Error in `select()`: + ! non-numeric argument to binary operator Code slice(mtcars, invisible(999 + "")) Condition Error in `slice()`: - Problem while evaluating `..1`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while evaluating `..1`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code mutate(mtcars, var = invisible(999 + "")) Condition Error in `mutate()`: - Problem while computing `var`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `var`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code summarise(mtcars, var = invisible(999 + "")) Condition Error in `summarise()`: - Problem while computing `var`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `var`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code filter(mtcars, var = invisible(999 + "")) Condition - Error in `filter()`: We detected a named input. + Error in `filter()`: + ! We detected a named input. i This usually means that you've used `=` instead of `==`. i Did you mean `var == invisible(999 + "")`? Code arrange(mtcars, var = invisible(999 + "")) Condition Error in `arrange()`: - Problem with the implicit `transmute()` step. - x Problem while computing `..1`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem with the implicit `transmute()` step. + x Problem while computing `..1`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator Code select(mtcars, var = invisible(999 + "")) Condition - Error in `select()`: non-numeric argument to binary operator + Error in `select()`: + ! non-numeric argument to binary operator Code slice(mtcars, var = invisible(999 + "")) Condition Error in `slice()`: - Problem while evaluating `var`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while evaluating `var`. + Caused by error in `999 + ""`: + ! non-numeric argument to binary operator # can pass verb-level error call @@ -86,57 +89,58 @@ mutate(mtcars, 1 + "") Condition Error in `foo()`: - Problem while computing `..1 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code transmute(mtcars, 1 + "") Condition Error in `foo()`: - Problem while computing `..1 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code summarise(mtcars, 1 + "") Condition Error in `foo()`: - Problem while computing `..1 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code summarise(group_by(mtcars, cyl), 1 + "") Condition Error in `foo()`: - Problem while computing `..1 = 1 + ""`. - i The error occurred in group 1: cyl = 4. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1 = 1 + ""`. + i The error occurred in group 1: cyl = 4. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code filter(mtcars, 1 + "") Condition Error in `foo()`: - Problem while computing `..1 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `..1 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code arrange(mtcars, 1 + "") Condition Error in `foo()`: - Problem with the implicit `transmute()` step. - x Problem while computing `..1 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem with the implicit `transmute()` step. + x Problem while computing `..1 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code select(mtcars, 1 + "") Condition - Error in `foo()`: non-numeric argument to binary operator + Error in `foo()`: + ! non-numeric argument to binary operator Code slice(mtcars, 1 + "") Condition Error in `foo()`: - Problem while evaluating `..1 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while evaluating `..1 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator # can pass verb-level error call (example case) @@ -144,12 +148,13 @@ my_verb(mtcars, 1 + "", am) Condition Error in `my_verb()`: - Problem while computing `.result = (1 + "") * am`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while computing `.result = (1 + "") * am`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code my_verb(mtcars, cyl, c(am, vs)) Condition - Error in `my_verb()`: Problem while computing `.result = cyl * c(am, vs)`. + Error in `my_verb()`: + ! Problem while computing `.result = cyl * c(am, vs)`. i `.result` must be size 32 or 1, not 64. diff --git a/tests/testthat/_snaps/context.md b/tests/testthat/_snaps/context.md index faf84788c7..0d9bd80a1a 100644 --- a/tests/testthat/_snaps/context.md +++ b/tests/testthat/_snaps/context.md @@ -4,35 +4,42 @@ (expect_error(n())) Output - Error in `n()`: Must be used inside dplyr verbs. + Error in `n()`: + ! Must be used inside dplyr verbs. Code (expect_error(cur_data())) Output - Error in `cur_data()`: Must be used inside dplyr verbs. + Error in `cur_data()`: + ! Must be used inside dplyr verbs. Code (expect_error(cur_data_all())) Output - Error in `cur_data_all()`: Must be used inside dplyr verbs. + Error in `cur_data_all()`: + ! Must be used inside dplyr verbs. Code (expect_error(cur_column())) Output - Error in `cur_column()`: Must be used inside `across()`. + Error in `cur_column()`: + ! Must be used inside `across()`. Code (expect_error(cur_group())) Output - Error in `cur_group()`: Must be used inside dplyr verbs. + Error in `cur_group()`: + ! Must be used inside dplyr verbs. Code (expect_error(cur_group_id())) Output - Error in `cur_group_id()`: Must be used inside dplyr verbs. + Error in `cur_group_id()`: + ! Must be used inside dplyr verbs. Code (expect_error(cur_group_rows())) Output - Error in `cur_group_rows()`: Must be used inside dplyr verbs. + Error in `cur_group_rows()`: + ! Must be used inside dplyr verbs. diff --git a/tests/testthat/_snaps/deprec-combine.md b/tests/testthat/_snaps/deprec-combine.md index cc9dc761a3..9eaf13b8d2 100644 --- a/tests/testthat/_snaps/deprec-combine.md +++ b/tests/testthat/_snaps/deprec-combine.md @@ -3,7 +3,8 @@ Code combine() Condition - Warning: `combine()` was deprecated in dplyr 1.0.0. + Warning: + `combine()` was deprecated in dplyr 1.0.0. Please use `vctrs::vec_c()` instead. Output logical(0) @@ -14,10 +15,12 @@ (expect_error(combine("a", 1))) Output - Error in `combine()`: Can't combine `..1` and `..2` . + Error in `combine()`: + ! Can't combine `..1` and `..2` . Code (expect_error(combine(factor("a"), 1L))) Output - Error in `combine()`: Can't combine `..1` > and `..2` . + Error in `combine()`: + ! Can't combine `..1` > and `..2` . diff --git a/tests/testthat/_snaps/deprec-dbi.md b/tests/testthat/_snaps/deprec-dbi.md index 2d6a2956d5..2228ea22b6 100644 --- a/tests/testthat/_snaps/deprec-dbi.md +++ b/tests/testthat/_snaps/deprec-dbi.md @@ -4,5 +4,6 @@ (expect_error(src_sqlite(":memory:"))) Output - Error in `src_sqlite()`: `path` must already exist, unless `create` = TRUE. + Error in `src_sqlite()`: + ! `path` must already exist, unless `create` = TRUE. diff --git a/tests/testthat/_snaps/deprec-do.md b/tests/testthat/_snaps/deprec-do.md index 2096fde0b0..b55bd7f211 100644 --- a/tests/testthat/_snaps/deprec-do.md +++ b/tests/testthat/_snaps/deprec-do.md @@ -4,25 +4,30 @@ (expect_error(df %>% do(head, tail))) Output - Error in `do()`: Can only supply one unnamed argument, not 2. + Error in `do()`: + ! Can only supply one unnamed argument, not 2. Code (expect_error(df %>% ungroup() %>% do(1))) Output - Error in `do()`: Result must be a data frame, not numeric. + Error in `do()`: + ! Result must be a data frame, not numeric. Code (expect_error(df %>% do(1))) Output - Error in `do()`: Results 1, 2, 3 must be data frames, not numeric. + Error in `do()`: + ! Results 1, 2, 3 must be data frames, not numeric. Code (expect_error(df %>% do("a"))) Output - Error in `do()`: Results 1, 2, 3 must be data frames, not character. + Error in `do()`: + ! Results 1, 2, 3 must be data frames, not character. Code (expect_error(df %>% do(x = 1, 2))) Output - Error in `do()`: Arguments must either be all named or all unnamed. + Error in `do()`: + ! Arguments must either be all named or all unnamed. diff --git a/tests/testthat/_snaps/deprec-funs.md b/tests/testthat/_snaps/deprec-funs.md index 3bd24ae93e..96afe1f7a3 100644 --- a/tests/testthat/_snaps/deprec-funs.md +++ b/tests/testthat/_snaps/deprec-funs.md @@ -3,7 +3,8 @@ Code funs(fn = bar) Condition - Warning: `funs()` was deprecated in dplyr 0.8.0. + Warning: + `funs()` was deprecated in dplyr 0.8.0. Please use a list of either functions or lambdas: # Simple named list: @@ -26,10 +27,12 @@ }))) Output - Error in `funs()`: `function(si) { mp[si] }` must be a function name (quoted or unquoted) or an unquoted call, not `function`. + Error in `funs()`: + ! `function(si) { mp[si] }` must be a function name (quoted or unquoted) or an unquoted call, not `function`. Code (expect_error(funs(~ mp[.]))) Output - Error in `funs()`: `~mp[.]` must be a function name (quoted or unquoted) or an unquoted call, not `~`. + Error in `funs()`: + ! `~mp[.]` must be a function name (quoted or unquoted) or an unquoted call, not `~`. diff --git a/tests/testthat/_snaps/deprec-src-local.md b/tests/testthat/_snaps/deprec-src-local.md index 152ba7a0b3..1e7bcd5d64 100644 --- a/tests/testthat/_snaps/deprec-src-local.md +++ b/tests/testthat/_snaps/deprec-src-local.md @@ -4,12 +4,14 @@ (expect_error(src_df("base", new.env()))) Output - Error in `src_local()`: Exactly one of `pkg` and `env` must be non-NULL, not 2. + Error in `src_local()`: + ! Exactly one of `pkg` and `env` must be non-NULL, not 2. Code (expect_error(src_df())) Output - Error in `src_local()`: Exactly one of `pkg` and `env` must be non-NULL, not 0. + Error in `src_local()`: + ! Exactly one of `pkg` and `env` must be non-NULL, not 0. Code env <- new.env(parent = emptyenv()) env$x <- 1 @@ -17,5 +19,6 @@ (expect_error(copy_to(src_env, tibble(x = 1), name = "x"))) Output - Error in `copy_to()`: Object with `name` = `x` must not already exist, unless `overwrite` = TRUE. + Error in `copy_to()`: + ! Object with `name` = `x` must not already exist, unless `overwrite` = TRUE. diff --git a/tests/testthat/_snaps/distinct.md b/tests/testthat/_snaps/distinct.md index 4f86a22333..a86e3ca7fa 100644 --- a/tests/testthat/_snaps/distinct.md +++ b/tests/testthat/_snaps/distinct.md @@ -5,29 +5,32 @@ (expect_error(df %>% distinct(aa, x))) Output - Error in `distinct()`: Must use existing variables. + Error in `distinct()`: + ! Must use existing variables. x `aa` not found in `.data`. Code (expect_error(df %>% distinct(aa, bb))) Output - Error in `distinct()`: Must use existing variables. + Error in `distinct()`: + ! Must use existing variables. x `aa` not found in `.data`. x `bb` not found in `.data`. Code (expect_error(df %>% distinct(.data$aa))) Output - Error in `distinct()`: Must use existing variables. + Error in `distinct()`: + ! Must use existing variables. x `aa` not found in `.data`. Code (expect_error(df %>% distinct(y = a + 1))) Output Error in `distinct()`: - Problem adding computed columns. + ! Problem adding computed columns. Caused by error in `mutate()`: - Problem while computing `y = a + 1`. + ! Problem while computing `y = a + 1`. Caused by error: - object 'a' not found + ! object 'a' not found diff --git a/tests/testthat/_snaps/filter.md b/tests/testthat/_snaps/filter.md index 35441e88fc..a71b3f4515 100644 --- a/tests/testthat/_snaps/filter.md +++ b/tests/testthat/_snaps/filter.md @@ -4,126 +4,142 @@ (expect_error(iris %>% group_by(Species) %>% filter(1:n()))) Output - Error in `filter()`: Problem while computing `..1 = 1:n()`. + Error in `filter()`: + ! Problem while computing `..1 = 1:n()`. x Input `..1` must be a logical vector, not a integer. i The error occurred in group 1: Species = setosa. Code (expect_error(iris %>% filter(1:n()))) Output - Error in `filter()`: Problem while computing `..1 = 1:n()`. + Error in `filter()`: + ! Problem while computing `..1 = 1:n()`. x Input `..1` must be a logical vector, not a integer. Code (expect_error(filter(data.frame(x = 1:2), matrix(c(TRUE, FALSE, TRUE, FALSE), nrow = 2)))) Output - Error in `filter()`: Problem while computing `..1 = matrix(c(TRUE, FALSE, TRUE, FALSE), nrow = 2)`. + Error in `filter()`: + ! Problem while computing `..1 = matrix(c(TRUE, FALSE, TRUE, FALSE), nrow = 2)`. x Input `..1` must be a logical vector, not a logical[,2]. Code (expect_error(iris %>% group_by(Species) %>% filter(c(TRUE, FALSE)))) Output - Error in `filter()`: Problem while computing `..1 = c(TRUE, FALSE)`. + Error in `filter()`: + ! Problem while computing `..1 = c(TRUE, FALSE)`. x Input `..1` must be of size 50 or 1, not size 2. i The error occurred in group 1: Species = setosa. Code (expect_error(iris %>% rowwise(Species) %>% filter(c(TRUE, FALSE)))) Output - Error in `filter()`: Problem while computing `..1 = c(TRUE, FALSE)`. + Error in `filter()`: + ! Problem while computing `..1 = c(TRUE, FALSE)`. x Input `..1` must be of size 1, not size 2. i The error occurred in row 1. Code (expect_error(iris %>% filter(c(TRUE, FALSE)))) Output - Error in `filter()`: Problem while computing `..1 = c(TRUE, FALSE)`. + Error in `filter()`: + ! Problem while computing `..1 = c(TRUE, FALSE)`. x Input `..1` must be of size 150 or 1, not size 2. Code (expect_error(iris %>% group_by(Species) %>% filter(data.frame(c(TRUE, FALSE)))) ) Output - Error in `filter()`: Problem while computing `..1 = data.frame(c(TRUE, FALSE))`. + Error in `filter()`: + ! Problem while computing `..1 = data.frame(c(TRUE, FALSE))`. x Input `..1` must be of size 50 or 1, not size 2. i The error occurred in group 1: Species = setosa. Code (expect_error(iris %>% rowwise() %>% filter(data.frame(c(TRUE, FALSE))))) Output - Error in `filter()`: Problem while computing `..1 = data.frame(c(TRUE, FALSE))`. + Error in `filter()`: + ! Problem while computing `..1 = data.frame(c(TRUE, FALSE))`. x Input `..1` must be of size 1, not size 2. i The error occurred in row 1. Code (expect_error(iris %>% filter(data.frame(c(TRUE, FALSE))))) Output - Error in `filter()`: Problem while computing `..1 = data.frame(c(TRUE, FALSE))`. + Error in `filter()`: + ! Problem while computing `..1 = data.frame(c(TRUE, FALSE))`. x Input `..1` must be of size 150 or 1, not size 2. Code (expect_error(tibble(x = 1) %>% filter(c(TRUE, TRUE)))) Output - Error in `filter()`: Problem while computing `..1 = c(TRUE, TRUE)`. + Error in `filter()`: + ! Problem while computing `..1 = c(TRUE, TRUE)`. x Input `..1` must be of size 1, not size 2. Code (expect_error(iris %>% group_by(Species) %>% filter(data.frame(Sepal.Length > 3, 1:n())))) Output - Error in `filter()`: Problem while computing `..1 = data.frame(Sepal.Length > 3, 1:n())`. + Error in `filter()`: + ! Problem while computing `..1 = data.frame(Sepal.Length > 3, 1:n())`. x Input `..1$X1.n..` must be a logical vector, not a integer. i The error occurred in group 1: Species = setosa. Code (expect_error(iris %>% filter(data.frame(Sepal.Length > 3, 1:n())))) Output - Error in `filter()`: Problem while computing `..1 = data.frame(Sepal.Length > 3, 1:n())`. + Error in `filter()`: + ! Problem while computing `..1 = data.frame(Sepal.Length > 3, 1:n())`. x Input `..1$X1.n..` must be a logical vector, not a integer. Code (expect_error(mtcars %>% filter(`_x`))) Output Error in `filter()`: - Problem while computing `..1 = _x`. + ! Problem while computing `..1 = _x`. Caused by error: - object '_x' not found + ! object '_x' not found Code (expect_error(mtcars %>% group_by(cyl) %>% filter(`_x`))) Output Error in `filter()`: - Problem while computing `..1 = _x`. - i The error occurred in group 1: cyl = 4. + ! Problem while computing `..1 = _x`. + i The error occurred in group 1: cyl = 4. Caused by error: - object '_x' not found + ! object '_x' not found Code (expect_error(filter(mtcars, x = 1))) Output - Error in `filter()`: We detected a named input. + Error in `filter()`: + ! We detected a named input. i This usually means that you've used `=` instead of `==`. i Did you mean `x == 1`? Code (expect_error(filter(mtcars, y > 2, z = 3))) Output - Error in `filter()`: We detected a named input. + Error in `filter()`: + ! We detected a named input. i This usually means that you've used `=` instead of `==`. i Did you mean `z == 3`? Code (expect_error(filter(mtcars, TRUE, x = 1))) Output - Error in `filter()`: We detected a named input. + Error in `filter()`: + ! We detected a named input. i This usually means that you've used `=` instead of `==`. i Did you mean `x == 1`? Code (expect_error(filter(ts(1:10)))) Output - Error in `filter()`: Incompatible data source. + Error in `filter()`: + ! Incompatible data source. x `.data` is a object, not a data source. i Did you want to use `stats::filter()`? Code @@ -131,20 +147,22 @@ Output Error in `filter()`: - Problem while computing `..1 = stop("{")`. + ! Problem while computing `..1 = stop("{")`. Caused by error: - { + ! { Code data.frame(x = 1, y = 1) %>% filter(across(everything(), ~ .x > 0)) Condition - Warning: Using `across()` in `filter()` is deprecated, use `if_any()` or `if_all()`. + Warning: + Using `across()` in `filter()` is deprecated, use `if_any()` or `if_all()`. Output x y 1 1 1 Code data.frame(x = 1, y = 1) %>% filter(data.frame(x > 0, y > 0)) Condition - Warning: data frame results in `filter()` are deprecated, use `if_any()` or `if_all()`. + Warning: + data frame results in `filter()` are deprecated, use `if_any()` or `if_all()`. Output x y 1 1 1 diff --git a/tests/testthat/_snaps/group-by.md b/tests/testthat/_snaps/group-by.md index 0ae3d9c18f..035a6b9ae7 100644 --- a/tests/testthat/_snaps/group-by.md +++ b/tests/testthat/_snaps/group-by.md @@ -19,31 +19,33 @@ (expect_error(df %>% group_by(unknown))) Output - Error in `group_by()`: Must group by variables found in `.data`. + Error in `group_by()`: + ! Must group by variables found in `.data`. x Column `unknown` is not found. Code (expect_error(df %>% ungroup(x))) Output - Error in `ungroup()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `ungroup()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = x + i Did you forget to name an argument? Code (expect_error(df %>% group_by(x, y) %>% ungroup(z))) Output - Error in `ungroup()`: Can't subset columns that don't exist. + Error in `ungroup()`: + ! Can't subset columns that don't exist. x Column `z` doesn't exist. Code (expect_error(df %>% group_by(z = a + 1))) Output Error in `group_by()`: - Problem adding computed columns. + ! Problem adding computed columns. Caused by error in `mutate()`: - Problem while computing `z = a + 1`. + ! Problem while computing `z = a + 1`. Caused by error: - object 'a' not found + ! object 'a' not found diff --git a/tests/testthat/_snaps/group_map.md b/tests/testthat/_snaps/group_map.md index f6e4c90fdf..6e48863899 100644 --- a/tests/testthat/_snaps/group_map.md +++ b/tests/testthat/_snaps/group_map.md @@ -5,22 +5,26 @@ ) Output - Error in `group_modify()`: The returned data frame cannot contain the original grouping variables: cyl. + Error in `group_modify()`: + ! The returned data frame cannot contain the original grouping variables: cyl. Code (expect_error(mtcars %>% group_by(cyl) %>% group_modify(~10))) Output - Error in `group_modify()`: The result of `.f` must be a data frame. + Error in `group_modify()`: + ! The result of `.f` must be a data frame. Code (expect_error(iris %>% group_by(Species) %>% group_modify(head1))) Output - Error in `group_modify()`: `.f` must accept at least two arguments. + Error in `group_modify()`: + ! `.f` must accept at least two arguments. i You can use `...` to absorb unused components. Code (expect_error(iris %>% group_by(Species) %>% group_map(head1))) Output - Error in `group_map()`: `.f` must accept at least two arguments. + Error in `group_map()`: + ! `.f` must accept at least two arguments. i You can use `...` to absorb unused components. diff --git a/tests/testthat/_snaps/grouped-df.md b/tests/testthat/_snaps/grouped-df.md index 6af06d3ac0..28f19a2b3e 100644 --- a/tests/testthat/_snaps/grouped-df.md +++ b/tests/testthat/_snaps/grouped-df.md @@ -4,76 +4,89 @@ (expect_error(validate_grouped_df(df1))) Output - Error in `validate_grouped_df()`: The `.rows` column must be list of one-based integer vectors. + Error in `validate_grouped_df()`: + ! The `.rows` column must be list of one-based integer vectors. Code (expect_error(group_data(df1))) Output Error in `group_data()`: - `.data` must be a valid object. + ! `.data` must be a valid object. Caused by error in `validate_grouped_df()`: - The `.rows` column must be list of one-based integer vectors. + ! The `.rows` column must be list of one-based integer vectors. Code (expect_error(validate_grouped_df(df2))) Output - Error in `validate_grouped_df()`: The last column of the `groups` attribute must be called `.rows`. + Error in `validate_grouped_df()`: + ! The last column of the `groups` attribute must be called `.rows`. Code (expect_error(validate_grouped_df(df2))) Output - Error in `validate_grouped_df()`: The last column of the `groups` attribute must be called `.rows`. + Error in `validate_grouped_df()`: + ! The last column of the `groups` attribute must be called `.rows`. Code (expect_error(validate_grouped_df(df3))) Output - Error in `validate_grouped_df()`: The `groups` attribute must be a data frame. + Error in `validate_grouped_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(validate_grouped_df(df4))) Output - Error in `validate_grouped_df()`: The `groups` attribute must be a data frame. + Error in `validate_grouped_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(validate_grouped_df(df5))) Output - Error in `validate_grouped_df()`: Corrupt `grouped_df` using old (< 0.8.0) format. + Error in `validate_grouped_df()`: + ! Corrupt `grouped_df` using old (< 0.8.0) format. i Strip off old grouping with `ungroup()`. Code (expect_error(validate_grouped_df(df6, check_bounds = TRUE))) Output - Error in `validate_grouped_df()`: out of bounds indices. + Error in `validate_grouped_df()`: + ! out of bounds indices. Code (expect_error(validate_grouped_df(df7, check_bounds = TRUE))) Output - Error in `validate_grouped_df()`: out of bounds indices. + Error in `validate_grouped_df()`: + ! out of bounds indices. Code (expect_error(validate_grouped_df(df8, check_bounds = TRUE))) Output - Error in `validate_grouped_df()`: out of bounds indices. + Error in `validate_grouped_df()`: + ! out of bounds indices. Code (expect_error(validate_grouped_df(df10))) Output - Error in `validate_grouped_df()`: The `groups` attribute must be a data frame. + Error in `validate_grouped_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(validate_grouped_df(df11))) Output - Error in `validate_grouped_df()`: The `groups` attribute must be a data frame. + Error in `validate_grouped_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(new_grouped_df(tibble(x = 1:10), tibble(other = list(1:2))))) Output - Error in `new_grouped_df()`: The last column of `groups` must be called ".rows". + Error in `new_grouped_df()`: + ! The last column of `groups` must be called ".rows". Code (expect_error(new_grouped_df(10))) Output - Error in `new_grouped_df()`: `x` must be a data frame. + Error in `new_grouped_df()`: + ! `x` must be a data frame. # helper gives meaningful error messages @@ -81,10 +94,12 @@ (expect_error(grouped_df(data.frame(x = 1), "y", FALSE))) Output - Error in `compute_groups()`: `vars` missing from `data`: `y`. + Error in `compute_groups()`: + ! `vars` missing from `data`: `y`. Code (expect_error(grouped_df(data.frame(x = 1), 1))) Output - Error in `grouped_df()`: `vars` must be a character vector. + Error in `grouped_df()`: + ! `vars` must be a character vector. diff --git a/tests/testthat/_snaps/if-else.md b/tests/testthat/_snaps/if-else.md index d7a1bae5ab..a499b3ea2f 100644 --- a/tests/testthat/_snaps/if-else.md +++ b/tests/testthat/_snaps/if-else.md @@ -4,27 +4,32 @@ (expect_error(if_else(1:10, 1, 2))) Output - Error in `if_else()`: `condition` must be a logical vector, not an integer vector. + Error in `if_else()`: + ! `condition` must be a logical vector, not an integer vector. Code (expect_error(if_else(1:3 < 2, 1:2, 1:3))) Output - Error in `if_else()`: `true` must be length 3 (length of `condition`) or one, not 2. + Error in `if_else()`: + ! `true` must be length 3 (length of `condition`) or one, not 2. Code (expect_error(if_else(1:3 < 2, 1:3, 1:2))) Output - Error in `if_else()`: `false` must be length 3 (length of `condition`) or one, not 2. + Error in `if_else()`: + ! `false` must be length 3 (length of `condition`) or one, not 2. Code (expect_error(if_else(1:3 < 2, 1, 1L))) Output - Error in `if_else()`: `false` must be a double vector, not an integer vector. + Error in `if_else()`: + ! `false` must be a double vector, not an integer vector. Code x <- factor("x") y <- ordered("x") (expect_error(if_else(1:3 < 2, x, y))) Output - Error in `if_else()`: `false` must have class `factor`, not class `ordered/factor`. + Error in `if_else()`: + ! `false` must have class `factor`, not class `ordered/factor`. diff --git a/tests/testthat/_snaps/join-cols.md b/tests/testthat/_snaps/join-cols.md index 32bf19c762..8d3481bf62 100644 --- a/tests/testthat/_snaps/join-cols.md +++ b/tests/testthat/_snaps/join-cols.md @@ -4,13 +4,15 @@ (expect_error(join_cols(c("x", "y"), c("y", "y")))) Output - Error: Input columns in `y` must be unique. + Error: + ! Input columns in `y` must be unique. x Problem with `y`. Code (expect_error(join_cols(c("y", "y"), c("x", "y")))) Output - Error: Input columns in `x` must be unique. + Error: + ! Input columns in `x` must be unique. x Problem with `y`. Code xy <- c("x", "y") @@ -21,45 +23,53 @@ (expect_error(join_cols(xy, c("a", "b")))) Output - Error: `by` must be supplied when `x` and `y` have no common variables. + Error: + ! `by` must be supplied when `x` and `y` have no common variables. i use by = character()` to perform a cross-join. Code (expect_error(join_cols(xy, xy, by = FALSE))) Output - Error: `by` must be a (named) character vector, list, or NULL, not a logical vector. + Error: + ! `by` must be a (named) character vector, list, or NULL, not a logical vector. Code (expect_error(join_cols(xy, xy, by = list(1, 2)))) Output - Error: join columns must be character vectors. + Error: + ! join columns must be character vectors. Code (expect_error(join_cols(xy, xy, by = c("x", "x")))) Output - Error: Join columns must be unique. + Error: + ! Join columns must be unique. x Problem at position 2. Code (expect_error(join_cols(xy, xy, by = c("x", NA)))) Output - Error: Join columns must be not NA. + Error: + ! Join columns must be not NA. x Problem at position 2. Code (expect_error(join_cols(xy, xy, by = c("aaa", "bbb")))) Output - Error: Join columns must be present in data. + Error: + ! Join columns must be present in data. x Problem with `aaa` and `bbb`. Code (expect_error(join_cols(xy, xy, by = "x", suffix = "x"))) Output - Error: `suffix` must be a character vector of length 2. + Error: + ! `suffix` must be a character vector of length 2. i `suffix` is a character vector of length 1. Code (expect_error(join_cols(xy, xy, by = "x", suffix = c("", NA)))) Output - Error: `suffix` can't be NA. + Error: + ! `suffix` can't be NA. diff --git a/tests/testthat/_snaps/join-rows.md b/tests/testthat/_snaps/join-rows.md index 2c96a8d1db..eb9afcee2a 100644 --- a/tests/testthat/_snaps/join-rows.md +++ b/tests/testthat/_snaps/join-rows.md @@ -4,7 +4,8 @@ (expect_error(join_rows(data.frame(x = 1), data.frame(x = factor("a"))))) Output - Error: Can't join on `x$x` x `y$x` because of incompatible types. + Error: + ! Can't join on `x$x` x `y$x` because of incompatible types. i `x$x` is of type >. i `y$x` is of type >>. diff --git a/tests/testthat/_snaps/lead-lag.md b/tests/testthat/_snaps/lead-lag.md index e3995f3b33..2cc5c39d86 100644 --- a/tests/testthat/_snaps/lead-lag.md +++ b/tests/testthat/_snaps/lead-lag.md @@ -5,47 +5,56 @@ (expect_error(lead(letters, -1))) Output - Error in `lead()`: `n` must be a positive integer, not a double vector of length 1. + Error in `lead()`: + ! `n` must be a positive integer, not a double vector of length 1. Code (expect_error(lead(letters, "1"))) Output - Error in `lead()`: `n` must be a positive integer, not a character vector of length 1. + Error in `lead()`: + ! `n` must be a positive integer, not a character vector of length 1. Code (expect_error(lag(letters, -1))) Output - Error in `lag()`: `n` must be a positive integer, not a double vector of length 1. + Error in `lag()`: + ! `n` must be a positive integer, not a double vector of length 1. Code (expect_error(lag(letters, "1"))) Output - Error in `lag()`: `n` must be a positive integer, not a character vector of length 1. + Error in `lag()`: + ! `n` must be a positive integer, not a character vector of length 1. Code # # ts (expect_error(lag(ts(1:10)))) Output - Error in `lag()`: `x` must be a vector, not a ts object, do you want `stats::lag()`? + Error in `lag()`: + ! `x` must be a vector, not a ts object, do you want `stats::lag()`? Code # # incompatible default (expect_error(lag(c("1", "2", "3"), default = FALSE))) Output - Error in `lag()`: Can't combine `default` and `x` . + Error in `lag()`: + ! Can't combine `default` and `x` . Code (expect_error(lead(c("1", "2", "3"), default = FALSE))) Output - Error in `lead()`: Can't combine `default` and `x` . + Error in `lead()`: + ! Can't combine `default` and `x` . Code (expect_error(lag(c("1", "2", "3"), default = character()))) Output - Error in `lag()`: `default` must be size 1, not size 0 + Error in `lag()`: + ! `default` must be size 1, not size 0 Code (expect_error(lead(c("1", "2", "3"), default = character()))) Output - Error in `lead()`: `default` must be size 1, not size 0 + Error in `lead()`: + ! `default` must be size 1, not size 0 diff --git a/tests/testthat/_snaps/mutate.md b/tests/testthat/_snaps/mutate.md index 0d8a68685e..248c469c75 100644 --- a/tests/testthat/_snaps/mutate.md +++ b/tests/testthat/_snaps/mutate.md @@ -6,43 +6,47 @@ Output Error in `mutate()`: - Problem while computing `a = sum(y)`. + ! Problem while computing `a = sum(y)`. Caused by error: - object 'y' not found + ! object 'y' not found Code (expect_error(tbl %>% group_by(x) %>% mutate(y = NULL, a = sum(y)))) Output Error in `mutate()`: - Problem while computing `a = sum(y)`. - i The error occurred in group 1: x = 1. + ! Problem while computing `a = sum(y)`. + i The error occurred in group 1: x = 1. Caused by error: - object 'y' not found + ! object 'y' not found Code (expect_error(tibble(x = 1) %>% mutate(y = mean))) Output - Error in `mutate()`: Problem while computing `y = mean`. + Error in `mutate()`: + ! Problem while computing `y = mean`. x `y` must be a vector, not a function. Code df <- tibble(g = c(1, 1, 2, 2, 2), x = 1:5) (expect_error(df %>% mutate(out = env(a = 1)))) Output - Error in `mutate()`: Problem while computing `out = env(a = 1)`. + Error in `mutate()`: + ! Problem while computing `out = env(a = 1)`. x `out` must be a vector, not an environment. Code (expect_error(df %>% group_by(g) %>% mutate(out = env(a = 1)))) Output - Error in `mutate()`: Problem while computing `out = env(a = 1)`. + Error in `mutate()`: + ! Problem while computing `out = env(a = 1)`. x `out` must be a vector, not an environment. i The error occurred in group 1: g = 1. Code (expect_error(df %>% rowwise() %>% mutate(out = rnorm))) Output - Error in `mutate()`: Problem while computing `out = rnorm`. + Error in `mutate()`: + ! Problem while computing `out = rnorm`. x `out` must be a vector, not a function. i Did you mean: `out = list(rnorm)` ? i The error occurred in row 1. @@ -52,38 +56,42 @@ Output Error in `mutate()`: - Problem while computing `val = ifelse(x < 3, "foo", 2)`. + ! Problem while computing `val = ifelse(x < 3, "foo", 2)`. Caused by error: - `val` must return compatible vectors across groups. - i Result type for group 1 (x = 1): . - i Result type for group 3 (x = 3): . + ! `val` must return compatible vectors across groups. + i Result type for group 1 (x = 1): . + i Result type for group 3 (x = 3): . Code (expect_error(tibble(a = 1:3, b = 4:6) %>% group_by(a) %>% mutate(if (a == 1) NULL else "foo"))) Output - Error in `mutate()`: Problem while computing `..1 = if (a == 1) NULL else "foo"`. + Error in `mutate()`: + ! Problem while computing `..1 = if (a == 1) NULL else "foo"`. x `..1` must return compatible vectors across groups. i Cannot combine NULL and non NULL results. Code (expect_error(data.frame(x = c(2, 2, 3, 3)) %>% mutate(int = 1:5))) Output - Error in `mutate()`: Problem while computing `int = 1:5`. + Error in `mutate()`: + ! Problem while computing `int = 1:5`. i `int` must be size 4 or 1, not 5. Code (expect_error(data.frame(x = c(2, 2, 3, 3)) %>% group_by(x) %>% mutate(int = 1: 5))) Output - Error in `mutate()`: Problem while computing `int = 1:5`. + Error in `mutate()`: + ! Problem while computing `int = 1:5`. i `int` must be size 2 or 1, not 5. i The error occurred in group 1: x = 2. Code (expect_error(data.frame(x = c(2, 3, 3)) %>% group_by(x) %>% mutate(int = 1:5))) Output - Error in `mutate()`: Problem while computing `int = 1:5`. + Error in `mutate()`: + ! Problem while computing `int = 1:5`. i `int` must be size 1, not 5. i The error occurred in group 1: x = 2. Code @@ -91,7 +99,8 @@ ) Output - Error in `mutate()`: Problem while computing `int = 1:5`. + Error in `mutate()`: + ! Problem while computing `int = 1:5`. i `int` must be size 1, not 5. i Did you mean: `int = list(1:5)` ? i The error occurred in row 1. @@ -99,7 +108,8 @@ (expect_error(tibble(y = list(1:3, "a")) %>% rowwise() %>% mutate(y2 = y))) Output - Error in `mutate()`: Problem while computing `y2 = y`. + Error in `mutate()`: + ! Problem while computing `y2 = y`. i `y2` must be size 1, not 3. i Did you mean: `y2 = list(y)` ? i The error occurred in row 1. @@ -107,32 +117,34 @@ (expect_error(data.frame(x = 1:10) %>% mutate(y = 11:20, y = 1:2))) Output - Error in `mutate()`: Problem while computing `y = 1:2`. + Error in `mutate()`: + ! Problem while computing `y = 1:2`. i `y` must be size 10 or 1, not 2. Code (expect_error(tibble(a = 1) %>% mutate(c = .data$b))) Output Error in `mutate()`: - Problem while computing `c = .data$b`. + ! Problem while computing `c = .data$b`. Caused by error in `.data$b`: - Column `b` not found in `.data`. + ! Column `b` not found in `.data`. Code (expect_error(tibble(a = 1:3) %>% group_by(a) %>% mutate(c = .data$b))) Output Error in `mutate()`: - Problem while computing `c = .data$b`. - i The error occurred in group 1: a = 1. + ! Problem while computing `c = .data$b`. + i The error occurred in group 1: a = 1. Caused by error in `.data$b`: - Column `b` not found in `.data`. + ! Column `b` not found in `.data`. Code lazy <- (function(x) list(enquo(x))) res <- tbl %>% rowwise() %>% mutate(z = lazy(x), .keep = "unused") (expect_error(eval_tidy(res$z[[1]]))) Output - Error: Obsolete data mask. + Error: + ! Obsolete data mask. x Too late to resolve `x` after the end of `dplyr::mutate()`. i Did you save an object that uses `x` lazily in a column in the `dplyr::mutate()` expression ? Code @@ -140,7 +152,7 @@ Output Error in `mutate()`: - Problem while computing `..1 = stop("{")`. + ! Problem while computing `..1 = stop("{")`. Caused by error: - { + ! { diff --git a/tests/testthat/_snaps/na-if.md b/tests/testthat/_snaps/na-if.md index 32e66ea061..9697b73a86 100644 --- a/tests/testthat/_snaps/na-if.md +++ b/tests/testthat/_snaps/na-if.md @@ -4,10 +4,12 @@ (expect_error(na_if(1:3, 1:2))) Output - Error in `na_if()`: `y` must be length 3 (same as `x`) or one, not 2. + Error in `na_if()`: + ! `y` must be length 3 (same as `x`) or one, not 2. Code (expect_error(na_if(1, 1:2))) Output - Error in `na_if()`: `y` must be length 1 (same as `x`), not 2. + Error in `na_if()`: + ! `y` must be length 1 (same as `x`), not 2. diff --git a/tests/testthat/_snaps/nth-value.md b/tests/testthat/_snaps/nth-value.md index 01d9165205..df4527a91f 100644 --- a/tests/testthat/_snaps/nth-value.md +++ b/tests/testthat/_snaps/nth-value.md @@ -4,5 +4,6 @@ (expect_error(nth(1:10, "x"))) Output - Error in `nth()`: `n` must be a single integer. + Error in `nth()`: + ! `n` must be a single integer. diff --git a/tests/testthat/_snaps/order-by.md b/tests/testthat/_snaps/order-by.md index 8b27a56a43..c6a706c371 100644 --- a/tests/testthat/_snaps/order-by.md +++ b/tests/testthat/_snaps/order-by.md @@ -4,11 +4,13 @@ (expect_error(order_by(mtcars, 10))) Output - Error in `order_by()`: `call` must be a function call, not a double vector. + Error in `order_by()`: + ! `call` must be a function call, not a double vector. Code (expect_error(order_by(mtcars, cyl))) Output - Error in `order_by()`: `call` must be a function call, not a symbol. + Error in `order_by()`: + ! `call` must be a function call, not a symbol. i Did you mean `arrange(mtcars, cyl)`? diff --git a/tests/testthat/_snaps/recode.md b/tests/testthat/_snaps/recode.md index aef3c5dff2..f0f9ae9386 100644 --- a/tests/testthat/_snaps/recode.md +++ b/tests/testthat/_snaps/recode.md @@ -4,30 +4,36 @@ (expect_error(recode(factor("a"), a = 5, .missing = 10))) Output - Error in `recode()`: `.missing` is not supported for factors. + Error in `recode()`: + ! `.missing` is not supported for factors. Code (expect_error(recode("a", b = 5, "c"))) Output - Error in `recode()`: Argument 3 must be named. + Error in `recode()`: + ! Argument 3 must be named. Code (expect_error(recode(factor("a"), b = 5, "c"))) Output - Error in `recode()`: Argument 3 must be named. + Error in `recode()`: + ! Argument 3 must be named. Code (expect_error(recode(1:5))) Output - Error in `recode()`: No replacements provided. + Error in `recode()`: + ! No replacements provided. Code (expect_error(recode("a"))) Output - Error in `recode()`: No replacements provided. + Error in `recode()`: + ! No replacements provided. Code (expect_error(recode(factor("a")))) Output - Error in `recode()`: No replacements provided. + Error in `recode()`: + ! No replacements provided. diff --git a/tests/testthat/_snaps/rows.md b/tests/testthat/_snaps/rows.md index a6fd7e01e6..9b4bb8c94f 100644 --- a/tests/testthat/_snaps/rows.md +++ b/tests/testthat/_snaps/rows.md @@ -14,48 +14,56 @@ Matching, by = "a" Output - Error in `rows_insert()`: Attempting to insert duplicate rows. + Error in `rows_insert()`: + ! Attempting to insert duplicate rows. Code (expect_error(rows_insert(data[c(1, 1), ], tibble(a = 3)))) Message Matching, by = "a" Output - Error in `rows_insert()`: `x` key values must be unique. + Error in `rows_insert()`: + ! `x` key values must be unique. Code (expect_error(rows_insert(data, tibble(a = 4, b = "z"), by = "e"))) Output - Error in `rows_insert()`: All `by` columns must exist in `x`. + Error in `rows_insert()`: + ! All `by` columns must exist in `x`. Code (expect_error(rows_insert(data, tibble(d = 4)))) Message Matching, by = "d" Output - Error in `rows_insert()`: All columns in `y` must exist in `x`. + Error in `rows_insert()`: + ! All columns in `y` must exist in `x`. Code (expect_error(rows_update(data, tibble(a = 2:3, b = "z"), by = c("a", "b")))) Output - Error in `rows_update()`: Attempting to update missing rows. + Error in `rows_update()`: + ! Attempting to update missing rows. Code (expect_error(rows_patch(data, tibble(a = 2:3, b = "z"), by = c("a", "b")))) Output - Error in `rows_patch()`: Can't patch missing row. + Error in `rows_patch()`: + ! Can't patch missing row. Code (expect_error(rows_delete(data, tibble(a = 2:4)))) Message Matching, by = "a" Output - Error in `rows_delete()`: Can't delete missing row. + Error in `rows_delete()`: + ! Can't delete missing row. Code (expect_error(rows_delete(data, tibble(a = 2:3, b = "b"), by = c("a", "b")))) Output - Error in `rows_delete()`: Can't delete missing row. + Error in `rows_delete()`: + ! Can't delete missing row. Code rows_delete(data, tibble(a = 2:3)) Message diff --git a/tests/testthat/_snaps/rowwise.md b/tests/testthat/_snaps/rowwise.md index 2b073c6f71..23800793a4 100644 --- a/tests/testthat/_snaps/rowwise.md +++ b/tests/testthat/_snaps/rowwise.md @@ -19,32 +19,38 @@ (expect_error(validate_rowwise_df(df1))) Output - Error in `validate_rowwise_df()`: The `.rows` column must be a list of size 1, one-based integer vectors with the right value. + Error in `validate_rowwise_df()`: + ! The `.rows` column must be a list of size 1, one-based integer vectors with the right value. Code (expect_error(validate_rowwise_df(df2))) Output - Error in `validate_rowwise_df()`: The last column of the `groups` attribute must be called `.rows`. + Error in `validate_rowwise_df()`: + ! The last column of the `groups` attribute must be called `.rows`. Code (expect_error(validate_rowwise_df(df3))) Output - Error in `validate_rowwise_df()`: The `groups` attribute must be a data frame. + Error in `validate_rowwise_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(validate_rowwise_df(df4))) Output - Error in `validate_rowwise_df()`: The `groups` attribute must be a data frame. + Error in `validate_rowwise_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(validate_rowwise_df(df7))) Output - Error in `validate_rowwise_df()`: The `.rows` column must be a list of size 1, one-based integer vectors with the right value. + Error in `validate_rowwise_df()`: + ! The `.rows` column must be a list of size 1, one-based integer vectors with the right value. Code (expect_error(attr(df8, "groups")$.rows <- 1:8)) Output - Error: Assigned data `1:8` must be compatible with existing data. + Error: + ! Assigned data `1:8` must be compatible with existing data. x Existing data has 10 rows. x Assigned data has 8 rows. i Only vectors of size 1 are recycled. @@ -52,21 +58,25 @@ (expect_error(validate_rowwise_df(df10))) Output - Error in `validate_rowwise_df()`: The `groups` attribute must be a data frame. + Error in `validate_rowwise_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(validate_rowwise_df(df11))) Output - Error in `validate_rowwise_df()`: The `groups` attribute must be a data frame. + Error in `validate_rowwise_df()`: + ! The `groups` attribute must be a data frame. Code (expect_error(new_rowwise_df(tibble(x = 1:10), tibble(".rows" := list(1:5, -1L)))) ) Output - Error in `new_rowwise_df()`: `group_data` must be a tibble without a `.rows` column. + Error in `new_rowwise_df()`: + ! `group_data` must be a tibble without a `.rows` column. Code (expect_error(new_rowwise_df(tibble(x = 1:10), 1:10))) Output - Error in `new_rowwise_df()`: `group_data` must be a tibble without a `.rows` column. + Error in `new_rowwise_df()`: + ! `group_data` must be a tibble without a `.rows` column. diff --git a/tests/testthat/_snaps/sample.md b/tests/testthat/_snaps/sample.md index 721c1b458e..fcbe4e928c 100644 --- a/tests/testthat/_snaps/sample.md +++ b/tests/testthat/_snaps/sample.md @@ -7,39 +7,41 @@ Output Error in `sample_n()`: - Problem while computing indices. - i The error occurred in group 1: g = 1. + ! Problem while computing indices. + i The error occurred in group 1: g = 1. Caused by error in `sample.int()`: - too few positive probabilities + ! too few positive probabilities Code (expect_error(sample_frac(grp, 1, weight = y))) Output Error in `sample_frac()`: - Problem while computing indices. - i The error occurred in group 1: g = 1. + ! Problem while computing indices. + i The error occurred in group 1: g = 1. Caused by error in `sample.int()`: - too few positive probabilities + ! too few positive probabilities Code (expect_error(mtcars %>% group_by(cyl) %>% sample_n(10))) Output Error in `sample_n()`: - Problem while computing indices. - i The error occurred in group 2: cyl = 6. + ! Problem while computing indices. + i The error occurred in group 2: cyl = 6. Caused by error: - `size` must be less than or equal to 7 (size of data). - i set `replace = TRUE` to use sampling with replacement. + ! `size` must be less than or equal to 7 (size of data). + i set `replace = TRUE` to use sampling with replacement. Code (expect_error(sample_n(list()))) Output - Error in `sample_n()`: `tbl` must be a data frame, not a list. + Error in `sample_n()`: + ! `tbl` must be a data frame, not a list. Code (expect_error(sample_frac(list()))) Output - Error in `sample_frac()`: `tbl` must be a data frame, not a list. + Error in `sample_frac()`: + ! `tbl` must be a data frame, not a list. Code # # respects weight df <- data.frame(x = 1:2, y = c(0, 1)) @@ -47,34 +49,34 @@ Output Error in `sample_n()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error in `sample.int()`: - too few positive probabilities + ! too few positive probabilities Code (expect_error(sample_frac(df, 2))) Output Error in `sample_frac()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - `size` of sampled fraction must be less or equal to one. - i set `replace = TRUE` to use sampling with replacement. + ! `size` of sampled fraction must be less or equal to one. + i set `replace = TRUE` to use sampling with replacement. Code (expect_error(sample_frac(df %>% group_by(y), 2))) Output Error in `sample_frac()`: - Problem while computing indices. - i The error occurred in group 1: y = 0. + ! Problem while computing indices. + i The error occurred in group 1: y = 0. Caused by error: - `size` of sampled fraction must be less or equal to one. - i set `replace = TRUE` to use sampling with replacement. + ! `size` of sampled fraction must be less or equal to one. + i set `replace = TRUE` to use sampling with replacement. Code (expect_error(sample_frac(df, 1, weight = y))) Output Error in `sample_frac()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error in `sample.int()`: - too few positive probabilities + ! too few positive probabilities diff --git a/tests/testthat/_snaps/select.md b/tests/testthat/_snaps/select.md index d266df43d1..2769375b8a 100644 --- a/tests/testthat/_snaps/select.md +++ b/tests/testthat/_snaps/select.md @@ -29,7 +29,8 @@ (expect_error(select(mtcars, 1 + ""))) Output - Error in `select()`: non-numeric argument to binary operator + Error in `select()`: + ! non-numeric argument to binary operator # dplyr_col_select() aborts when `[` implementation is broken @@ -37,14 +38,16 @@ (expect_error(select(df1, 1:2))) Output - Error in `select()`: Can't subset columns that don't exist. + Error in `select()`: + ! Can't subset columns that don't exist. x Location 2 doesn't exist. i There are only 1 column. Code (expect_error(select(df1, 0))) Output - Error in `select()`: Can't reconstruct data frame. + Error in `select()`: + ! Can't reconstruct data frame. x The `[` method for class must return a data frame. i It returned a . @@ -54,21 +57,24 @@ (expect_error(select(df1, 2))) Output - Error in `select()`: Can't subset columns that don't exist. + Error in `select()`: + ! Can't subset columns that don't exist. x Location 2 doesn't exist. i There are only 1 column. Code (expect_error(select(df1, 1))) Output - Error in `select()`: Can't reconstruct data frame. + Error in `select()`: + ! Can't reconstruct data frame. x The `[` method for class must return a data frame. i It returned a . Code (expect_error(select(df2, 1))) Output - Error in `select()`: Can't reconstruct data frame. + Error in `select()`: + ! Can't reconstruct data frame. x The `[` method for class must return a data frame with 1 column. i It returned a of 0 columns. diff --git a/tests/testthat/_snaps/sets.md b/tests/testthat/_snaps/sets.md index 9cc0ede9e7..06d58eec20 100644 --- a/tests/testthat/_snaps/sets.md +++ b/tests/testthat/_snaps/sets.md @@ -9,32 +9,37 @@ (expect_error(intersect(alfa, beta))) Output - Error in `intersect()`: `x` and `y` are not compatible. + Error in `intersect()`: + ! `x` and `y` are not compatible. x Cols in `y` but not `x`: `data2`. x Cols in `x` but not `y`: `data`. Code (expect_error(intersect(alfa, 1))) Output - Error in `intersect()`: `y` must be a data frame. + Error in `intersect()`: + ! `y` must be a data frame. Code (expect_error(intersect(alfa, gamma))) Output - Error in `intersect()`: `x` and `y` are not compatible. + Error in `intersect()`: + ! `x` and `y` are not compatible. x Incompatible types for column `land`: character vs integer. Code (expect_error(union(alfa, beta))) Output - Error in `union()`: `x` and `y` are not compatible. + Error in `union()`: + ! `x` and `y` are not compatible. x Cols in `y` but not `x`: `data2`. x Cols in `x` but not `y`: `data`. Code (expect_error(setdiff(alfa, beta))) Output - Error in `setdiff()`: `x` and `y` are not compatible. + Error in `setdiff()`: + ! `x` and `y` are not compatible. x Cols in `y` but not `x`: `data2`. x Cols in `x` but not `y`: `data`. diff --git a/tests/testthat/_snaps/slice.md b/tests/testthat/_snaps/slice.md index d6b61a7d62..c3c36ccb1a 100644 --- a/tests/testthat/_snaps/slice.md +++ b/tests/testthat/_snaps/slice.md @@ -5,58 +5,58 @@ Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Can't convert to . - Cannot decrease dimensions. + ! Can't convert to . + Cannot decrease dimensions. Code (expect_error(slice(gdf, matrix(c(1, 2), ncol = 2)))) Output Error in `slice()`: - Problem while computing indices. - i The error occurred in group 1: x = 1. + ! Problem while computing indices. + i The error occurred in group 1: x = 1. Caused by error: - Can't convert to . - Cannot decrease dimensions. + ! Can't convert to . + Cannot decrease dimensions. Code (expect_error(slice(df, "a"))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Invalid result of type . - i Indices must be positive or negative integers. + ! Invalid result of type . + i Indices must be positive or negative integers. Code (expect_error(slice(gdf, "a"))) Output Error in `slice()`: - Problem while computing indices. - i The error occurred in group 1: x = 1. + ! Problem while computing indices. + i The error occurred in group 1: x = 1. Caused by error: - Invalid result of type . - i Indices must be positive or negative integers. + ! Invalid result of type . + i Indices must be positive or negative integers. Code (expect_error(slice(df, c(1, -1)))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Indices must be all positive or all negative. - i Got 1 positives, 1 negatives. + ! Indices must be all positive or all negative. + i Got 1 positives, 1 negatives. Code (expect_error(slice(gdf, c(1, -1)))) Output Error in `slice()`: - Problem while computing indices. - i The error occurred in group 1: x = 1. + ! Problem while computing indices. + i The error occurred in group 1: x = 1. Caused by error: - Indices must be all positive or all negative. - i Got 1 positives, 1 negatives. + ! Indices must be all positive or all negative. + i Got 1 positives, 1 negatives. # slice_*() checks that `n=` is explicitly named @@ -64,31 +64,36 @@ (expect_error(slice_head(df, 5))) Output - Error in `slice_head()`: `n` must be explicitly named. + Error in `slice_head()`: + ! `n` must be explicitly named. i Did you mean `slice_head(n = 5)`? Code (expect_error(slice_tail(df, 5))) Output - Error in `slice_tail()`: `n` must be explicitly named. + Error in `slice_tail()`: + ! `n` must be explicitly named. i Did you mean `slice_tail(n = 5)`? Code (expect_error(slice_min(df, x, 5))) Output - Error in `slice_min()`: `n` must be explicitly named. + Error in `slice_min()`: + ! `n` must be explicitly named. i Did you mean `slice_min(n = 5)`? Code (expect_error(slice_max(df, x, 5))) Output - Error in `slice_max()`: `n` must be explicitly named. + Error in `slice_max()`: + ! `n` must be explicitly named. i Did you mean `slice_max(n = 5)`? Code (expect_error(slice_sample(df, 5))) Output - Error in `slice_sample()`: `n` must be explicitly named. + Error in `slice_sample()`: + ! `n` must be explicitly named. i Did you mean `slice_sample(n = 5)`? # slice_*() checks that for empty `... @@ -97,52 +102,52 @@ (expect_error(slice_head(df, 5, 2))) Output - Error in `slice_head()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - * `..2` - i Did you misspecify an argument? + Error in `slice_head()`: + ! `...` must be empty. + x Problematic arguments: + * ..1 = 5 + * ..2 = 2 + i Did you forget to name an argument? Code (expect_error(slice_tail(df, 5, 2))) Output - Error in `slice_tail()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - * `..2` - i Did you misspecify an argument? + Error in `slice_tail()`: + ! `...` must be empty. + x Problematic arguments: + * ..1 = 5 + * ..2 = 2 + i Did you forget to name an argument? Code (expect_error(slice_min(df, x, 5, 2))) Output - Error in `slice_min()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - * `..2` - i Did you misspecify an argument? + Error in `slice_min()`: + ! `...` must be empty. + x Problematic arguments: + * ..1 = 5 + * ..2 = 2 + i Did you forget to name an argument? Code (expect_error(slice_max(df, x, 5, 2))) Output - Error in `slice_max()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - * `..2` - i Did you misspecify an argument? + Error in `slice_max()`: + ! `...` must be empty. + x Problematic arguments: + * ..1 = 5 + * ..2 = 2 + i Did you forget to name an argument? Code (expect_error(slice_sample(df, 5, 2))) Output - Error in `slice_sample()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - * `..2` - i Did you misspecify an argument? + Error in `slice_sample()`: + ! `...` must be empty. + x Problematic arguments: + * ..1 = 5 + * ..2 = 2 + i Did you forget to name an argument? --- @@ -150,47 +155,47 @@ (expect_error(slice_head(df, n = 5, 2))) Output - Error in `slice_head()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_head()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_tail(df, n = 5, 2))) Output - Error in `slice_tail()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_tail()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_min(df, x, n = 5, 2))) Output - Error in `slice_min()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_min()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_max(df, x, n = 5, 2))) Output - Error in `slice_max()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_max()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_sample(df, n = 5, 2))) Output - Error in `slice_sample()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_sample()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? --- @@ -198,47 +203,47 @@ (expect_error(slice_head(df, prop = 0.5, 2))) Output - Error in `slice_head()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_head()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_tail(df, prop = 0.5, 2))) Output - Error in `slice_tail()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_tail()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_min(df, x, prop = 0.5, 2))) Output - Error in `slice_min()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_min()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_max(df, x, prop = 0.5, 2))) Output - Error in `slice_max()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_max()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? Code (expect_error(slice_sample(df, prop = 0.5, 2))) Output - Error in `slice_sample()`: `...` is not empty. - i These dots only exist to allow future extensions and should be empty. - x We detected these problematic arguments: - * `..1` - i Did you misspecify an argument? + Error in `slice_sample()`: + ! `...` must be empty. + x Problematic argument: + * ..1 = 2 + i Did you forget to name an argument? # slice_*() checks for constant n= and prop= @@ -247,81 +252,81 @@ Output Error in `slice_head()`: - `n` must be a constant. + ! `n` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_head(df, prop = n()))) Output Error in `slice_head()`: - `prop` must be a constant. + ! `prop` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_tail(df, n = n()))) Output Error in `slice_tail()`: - `n` must be a constant. + ! `n` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_tail(df, prop = n()))) Output Error in `slice_tail()`: - `prop` must be a constant. + ! `prop` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_min(df, x, n = n()))) Output Error in `slice_min()`: - `n` must be a constant. + ! `n` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_min(df, x, prop = n()))) Output Error in `slice_min()`: - `prop` must be a constant. + ! `prop` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_max(df, x, n = n()))) Output Error in `slice_max()`: - `n` must be a constant. + ! `n` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_max(df, x, prop = n()))) Output Error in `slice_max()`: - `prop` must be a constant. + ! `prop` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_sample(df, n = n()))) Output Error in `slice_sample()`: - `n` must be a constant. + ! `n` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_sample(df, prop = n()))) Output Error in `slice_sample()`: - `prop` must be a constant. + ! `prop` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. # slice_min/max() check size of `order_by=` (#5922) @@ -330,17 +335,17 @@ Output Error in `slice_min()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - `order_by` must have size 10, not size 6. + ! `order_by` must have size 10, not size 6. Code (expect_error(slice_max(data.frame(x = 1:10), 1:6))) Output Error in `slice_max()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - `order_by` must have size 10, not size 6. + ! `order_by` must have size 10, not size 6. # slice_sample() check size of `weight_by=` (#5922) @@ -349,9 +354,9 @@ Output Error in `slice_sample()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - `weight_by` must have size 10, not size 6. + ! `weight_by` must have size 10, not size 6. # rename errors with invalid grouped data frame (#640) @@ -361,81 +366,83 @@ Output Error in `slice()`: - Problem while evaluating `..2 = 1 + ""`. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while evaluating `..2 = 1 + ""`. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code (expect_error(group_by(mtcars, cyl) %>% slice(1, 1 + ""))) Output Error in `slice()`: - Problem while evaluating `..2 = 1 + ""`. - i The error occurred in group 1: cyl = 4. - Caused by error in `+`: - non-numeric argument to binary operator + ! Problem while evaluating `..2 = 1 + ""`. + i The error occurred in group 1: cyl = 4. + Caused by error in `1 + ""`: + ! non-numeric argument to binary operator Code (expect_error(slice(df, TRUE))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Invalid result of type . - i Indices must be positive or negative integers. + ! Invalid result of type . + i Indices must be positive or negative integers. Code (expect_error(slice(df, FALSE))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Invalid result of type . - i Indices must be positive or negative integers. + ! Invalid result of type . + i Indices must be positive or negative integers. Code (expect_error(slice(mtcars, 1, 1, ""))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Can't combine `..1` and `..3` . + ! Can't combine `..1` and `..3` . Code (expect_error(group_by(mtcars, cyl) %>% slice(1, 1, ""))) Output Error in `slice()`: - Problem while computing indices. - i The error occurred in group 1: cyl = 4. + ! Problem while computing indices. + i The error occurred in group 1: cyl = 4. Caused by error: - Can't combine `..1` and `..3` . + ! Can't combine `..1` and `..3` . Code (expect_error(mtcars %>% slice(c(-1, 2)))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Indices must be all positive or all negative. - i Got 1 positives, 1 negatives. + ! Indices must be all positive or all negative. + i Got 1 positives, 1 negatives. Code (expect_error(mtcars %>% slice(c(2:3, -1)))) Output Error in `slice()`: - Problem while computing indices. + ! Problem while computing indices. Caused by error: - Indices must be all positive or all negative. - i Got 2 positives, 1 negatives. + ! Indices must be all positive or all negative. + i Got 2 positives, 1 negatives. Code (expect_error(slice_head(data.frame(), n = 1, prop = 1))) Output - Error in `slice_head()`: Must supply `n` or `prop`, but not both. + Error in `slice_head()`: + ! Must supply `n` or `prop`, but not both. Code (expect_error(slice_tail(data.frame(), n = "a"))) Output - Error in `slice_tail()`: `n` must be a single number. + Error in `slice_tail()`: + ! `n` must be a single number. Code (expect_error(slide_head(data.frame(), prop = "a"))) Output @@ -445,25 +452,27 @@ Output Error in `slice_head()`: - `n` must be a constant. + ! `n` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_head(data.frame(), prop = n()))) Output Error in `slice_head()`: - `prop` must be a constant. + ! `prop` must be a constant. Caused by error in `n()`: - Must be used inside dplyr verbs. + ! Must be used inside dplyr verbs. Code (expect_error(slice_head(data.frame(), n = NA))) Output - Error in `slice_head()`: `n` must be a single number. + Error in `slice_head()`: + ! `n` must be a single number. Code (expect_error(slice_head(data.frame(), prop = NA))) Output - Error in `slice_head()`: `prop` must be a single number. + Error in `slice_head()`: + ! `prop` must be a single number. diff --git a/tests/testthat/_snaps/summarise.md b/tests/testthat/_snaps/summarise.md index 8b3d4ab74b..4eac3eb42f 100644 --- a/tests/testthat/_snaps/summarise.md +++ b/tests/testthat/_snaps/summarise.md @@ -43,14 +43,16 @@ a = 1)))) Output - Error in `summarise()`: Problem while computing `a = rlang::env(a = 1)`. + Error in `summarise()`: + ! Problem while computing `a = rlang::env(a = 1)`. x `a` must be a vector, not an environment. Code (expect_error(tibble(x = 1, y = c(1, 2, 2), z = runif(3)) %>% group_by(x, y) %>% summarise(a = rlang::env(a = 1)))) Output - Error in `summarise()`: Problem while computing `a = rlang::env(a = 1)`. + Error in `summarise()`: + ! Problem while computing `a = rlang::env(a = 1)`. x `a` must be a vector, not an environment. i The error occurred in group 1: x = 1, y = 1. Code @@ -58,7 +60,8 @@ summarise(a = lm(y ~ x)))) Output - Error in `summarise()`: Problem while computing `a = lm(y ~ x)`. + Error in `summarise()`: + ! Problem while computing `a = lm(y ~ x)`. x `a` must be a vector, not a `lm` object. i Did you mean: `a = list(lm(y ~ x))` ? i The error occurred in row 1. @@ -68,32 +71,34 @@ Output Error in `summarise()`: - Problem while computing `a = a[[1]]`. + ! Problem while computing `a = a[[1]]`. Caused by error: - `a` must return compatible vectors across groups. - i Result type for group 1 (id = 1): . - i Result type for group 2 (id = 2): . + ! `a` must return compatible vectors across groups. + i Result type for group 1 (id = 1): . + i Result type for group 2 (id = 2): . Code (expect_error(tibble(id = 1:2, a = list(1, "2")) %>% rowwise() %>% summarise(a = a[[ 1]]))) Output Error in `summarise()`: - Problem while computing `a = a[[1]]`. + ! Problem while computing `a = a[[1]]`. Caused by error: - `a` must return compatible vectors across groups. + ! `a` must return compatible vectors across groups. Code (expect_error(tibble(z = 1) %>% summarise(x = 1:3, y = 1:2))) Output - Error in `summarise()`: Problem while recycling `y = 1:2`. + Error in `summarise()`: + ! Problem while recycling `y = 1:2`. x `y` must be size 3 or 1, not 2. i An earlier column had size 3. Code (expect_error(tibble(z = 1:2) %>% group_by(z) %>% summarise(x = 1:3, y = 1:2))) Output - Error in `summarise()`: Problem while recycling `y = 1:2`. + Error in `summarise()`: + ! Problem while recycling `y = 1:2`. x `y` must be size 3 or 1, not 2. i An earlier column had size 3. i The error occurred in group 1: z = 1. @@ -102,7 +107,8 @@ y = 1:2))) Output - Error in `summarise()`: Problem while recycling `y = 1:2`. + Error in `summarise()`: + ! Problem while recycling `y = 1:2`. x `y` must be size 3 or 1, not 2. i An earlier column had size 3. i The error occurred in group 2: z = 3. @@ -111,7 +117,8 @@ g == 1) 42))) Output - Error in `summarise()`: Problem while computing `x = if (g == 1) 42`. + Error in `summarise()`: + ! Problem while computing `x = if (g == 1) 42`. x `x` must return compatible vectors across groups. i Cannot combine NULL and non NULL results. Code @@ -119,56 +126,57 @@ Output Error in `summarise()`: - Problem while computing `a = mean(not_there)`. + ! Problem while computing `a = mean(not_there)`. Caused by error in `mean()`: - object 'not_there' not found + ! object 'not_there' not found Code (expect_error(summarise(group_by(mtcars, cyl), a = mean(not_there)))) Output Error in `summarise()`: - Problem while computing `a = mean(not_there)`. - i The error occurred in group 1: cyl = 4. + ! Problem while computing `a = mean(not_there)`. + i The error occurred in group 1: cyl = 4. Caused by error in `mean()`: - object 'not_there' not found + ! object 'not_there' not found Code (expect_error(summarise(tibble(a = 1), c = .data$b))) Output Error in `summarise()`: - Problem while computing `c = .data$b`. + ! Problem while computing `c = .data$b`. Caused by error in `.data$b`: - Column `b` not found in `.data`. + ! Column `b` not found in `.data`. Code (expect_error(summarise(group_by(tibble(a = 1:3), a), c = .data$b))) Output Error in `summarise()`: - Problem while computing `c = .data$b`. - i The error occurred in group 1: a = 1. + ! Problem while computing `c = .data$b`. + i The error occurred in group 1: a = 1. Caused by error in `.data$b`: - Column `b` not found in `.data`. + ! Column `b` not found in `.data`. Code (expect_error(tibble(x = 1, x = 1, .name_repair = "minimal") %>% summarise(x))) Output - Error in `summarise()`: Can't transform a data frame with duplicate names. + Error in `summarise()`: + ! Can't transform a data frame with duplicate names. Code (expect_error(tibble() %>% summarise(stop("{")))) Output Error in `summarise()`: - Problem while computing `..1 = stop("{")`. + ! Problem while computing `..1 = stop("{")`. Caused by error: - { + ! { Code (expect_error(tibble(a = 1, b = "{value:1, unit:a}") %>% group_by(b) %>% summarise(a = stop("!")))) Output Error in `summarise()`: - Problem while computing `a = stop("!")`. - i The error occurred in group 1: b = "{value:1, unit:a}". + ! Problem while computing `a = stop("!")`. + i The error occurred in group 1: b = "{value:1, unit:a}". Caused by error: - ! + ! ! diff --git a/tests/testthat/_snaps/transmute.md b/tests/testthat/_snaps/transmute.md index 304f34542d..bf286a2a3c 100644 --- a/tests/testthat/_snaps/transmute.md +++ b/tests/testthat/_snaps/transmute.md @@ -4,15 +4,18 @@ (expect_error(transmute(mtcars, cyl2 = cyl, .keep = "all"))) Output - Error in `transmute()`: The `.keep` argument is not supported. + Error in `transmute()`: + ! The `.keep` argument is not supported. Code (expect_error(transmute(mtcars, cyl2 = cyl, .before = disp))) Output - Error in `transmute()`: The `.before` argument is not supported. + Error in `transmute()`: + ! The `.before` argument is not supported. Code (expect_error(transmute(mtcars, cyl2 = cyl, .after = disp))) Output - Error in `transmute()`: The `.after` argument is not supported. + Error in `transmute()`: + ! The `.after` argument is not supported. diff --git a/tests/testthat/_snaps/utils.md b/tests/testthat/_snaps/utils.md index e296efa2ec..232c4e7102 100644 --- a/tests/testthat/_snaps/utils.md +++ b/tests/testthat/_snaps/utils.md @@ -4,12 +4,17 @@ (expect_error(dplyr:::check_pkg("`__foobarbaz__`", "foobar a baz"))) Output - Error in `dplyr:::check_pkg()`: The `__foobarbaz__` package is required to foobar a baz. - i Please install it with `install.packages("`__foobarbaz__`")`. + Error in `is_installed()`: + ! Must supply valid package names. + x Problematic names: + * "`__foobarbaz__`" Code (expect_error(dplyr:::check_pkg("`__foobarbaz__`", "foobar a baz", install = FALSE)) ) Output - Error in `dplyr:::check_pkg()`: The `__foobarbaz__` package is required to foobar a baz. + Error in `is_installed()`: + ! Must supply valid package names. + x Problematic names: + * "`__foobarbaz__`" diff --git a/tests/testthat/_snaps/window.md b/tests/testthat/_snaps/window.md index db38c662a9..8236cbeee4 100644 --- a/tests/testthat/_snaps/window.md +++ b/tests/testthat/_snaps/window.md @@ -4,5 +4,6 @@ (expect_error(order_by(NULL, 1L))) Output - Error in `order_by()`: `call` must be a function call, not an integer vector. + Error in `order_by()`: + ! `call` must be a function call, not an integer vector. From 48858afc2140a52902e770d08d24467c0512677a Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 17 Dec 2021 11:35:41 +0100 Subject: [PATCH 2/3] Supply valid package name to `is_installed()` --- tests/testthat/_snaps/utils.md | 17 +++++++---------- tests/testthat/test-utils.R | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/testthat/_snaps/utils.md b/tests/testthat/_snaps/utils.md index 232c4e7102..52f7f7388a 100644 --- a/tests/testthat/_snaps/utils.md +++ b/tests/testthat/_snaps/utils.md @@ -1,20 +1,17 @@ # check_pkg() give meaningful error messages Code - (expect_error(dplyr:::check_pkg("`__foobarbaz__`", "foobar a baz"))) + (expect_error(dplyr:::check_pkg("dplyrFooBarBaz", "foobar a baz"))) Output - Error in `is_installed()`: - ! Must supply valid package names. - x Problematic names: - * "`__foobarbaz__`" + Error in `dplyr:::check_pkg()`: + ! The dplyrFooBarBaz package is required to foobar a baz. + i Please install it with `install.packages("dplyrFooBarBaz")`. Code - (expect_error(dplyr:::check_pkg("`__foobarbaz__`", "foobar a baz", install = FALSE)) + (expect_error(dplyr:::check_pkg("dplyrFooBarBaz", "foobar a baz", install = FALSE)) ) Output - Error in `is_installed()`: - ! Must supply valid package names. - x Problematic names: - * "`__foobarbaz__`" + Error in `dplyr:::check_pkg()`: + ! The dplyrFooBarBaz package is required to foobar a baz. diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 8e0acd8078..4f7c2ed150 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -8,7 +8,7 @@ test_that("quo_is_variable_reference handles .data",{ test_that("check_pkg() give meaningful error messages", { expect_snapshot({ - (expect_error(dplyr:::check_pkg("`__foobarbaz__`", "foobar a baz"))) - (expect_error(dplyr:::check_pkg("`__foobarbaz__`", "foobar a baz", install = FALSE))) + (expect_error(dplyr:::check_pkg("dplyrFooBarBaz", "foobar a baz"))) + (expect_error(dplyr:::check_pkg("dplyrFooBarBaz", "foobar a baz", install = FALSE))) }) }) From 91e5582e33f0e40a2cc3ea481896e7e341074ba6 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Fri, 17 Dec 2021 11:44:26 +0100 Subject: [PATCH 3/3] Check condition header not full message --- tests/testthat/test-conditions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-conditions.R b/tests/testthat/test-conditions.R index b1f2656b51..e95794edcc 100644 --- a/tests/testthat/test-conditions.R +++ b/tests/testthat/test-conditions.R @@ -1,6 +1,6 @@ test_that("can hide expression in error messages", { err <- catch_cnd(mutate(mtcars, invisible(999 + "")), "error") - expect_false(grepl("999", conditionMessage(err))) + expect_false(grepl("999", cnd_header(err))) expect_snapshot(error = TRUE, { mutate(mtcars, invisible(999 + ""))