Skip to content

Commit

Permalink
Merge pull request #1063 from tidyverse/f-rlang-1
Browse files Browse the repository at this point in the history
- Require rlang 1.0.1 and pillar 1.7.0 (#1063).
  • Loading branch information
krlmlr committed Feb 22, 2022
2 parents fb17115 + f09cee8 commit 23b26bc
Show file tree
Hide file tree
Showing 17 changed files with 2,317 additions and 309 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Imports:
lifecycle (>= 1.0.0),
magrittr,
methods,
pillar (>= 1.6.2),
pillar (>= 1.7.0),
pkgconfig,
rlang (>= 0.4.3),
rlang (>= 1.0.1),
utils,
vctrs (>= 0.3.8)
Suggests:
Expand Down
87 changes: 87 additions & 0 deletions tests/testthat/_snaps/add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# output test

Code
add_row(tibble(), a = 1)
Condition
Error:
! New rows can't add columns.
x Can't find column `a` in `.data`.
Code
add_row(tibble(), a = 1, b = 2)
Condition
Error:
! New rows can't add columns.
x Can't find columns `a` and `b` in `.data`.
Code
add_row(tibble(), a = "a", b = "b", c = "c", d = "d", e = "e", f = "f", g = "g",
h = "h", i = "i", j = "j", k = "k", l = "l", m = "m", n = "n", o = "o", p = "p",
q = "q", r = "r", s = "s", t = "t", u = "u", v = "v", w = "w", x = "x", y = "y",
z = "z")
Condition
Error:
! New rows can't add columns.
x Can't find columns `a`, `b`, `c`, `d`, `e`, and 21 more in `.data`.
Code
add_row(dplyr::group_by(tibble(a = 1), a))
Condition
Error:
! Can't add rows to grouped data frames.
Code
add_row(tibble(a = 1), a = 2, .before = 1, .after = 1)
Condition
Error:
! Can't specify both `.before` and `.after`.
Code
add_column(tibble(a = 1), a = 1)
Condition
Error:
! Column name `a` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 2.
Code
add_column(tibble(a = 1, b = 2), a = 1, b = 2)
Condition
Error:
! Column names `a` and `b` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 3.
* "b" at locations 2 and 4.
Code
add_column(tibble(a = "a", b = "b", c = "c", d = "d", e = "e", f = "f", g = "g",
h = "h", i = "i", j = "j", k = "k", l = "l", m = "m", n = "n", o = "o", p = "p",
q = "q", r = "r", s = "s", t = "t", u = "u", v = "v", w = "w", x = "x", y = "y",
z = "z"), a = "a", b = "b", c = "c", d = "d", e = "e", f = "f", g = "g", h = "h",
i = "i", j = "j", k = "k", l = "l", m = "m", n = "n", o = "o", p = "p", q = "q",
r = "r", s = "s", t = "t", u = "u", v = "v", w = "w", x = "x", y = "y", z = "z")
Condition
Error:
! Column names `a`, `b`, `c`, `d`, `e`, and 21 more must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 27.
* "b" at locations 2 and 28.
* "c" at locations 3 and 29.
* "d" at locations 4 and 30.
* "e" at locations 5 and 31.
* ...
Code
add_column(tibble(a = 2:3), b = 4:6)
Condition
Error:
! New columns must be compatible with `.data`.
x New column has 3 rows.
i `.data` has 2 rows.
Code
add_column(tibble(a = 1), b = 1, .before = 1, .after = 1)
Condition
Error:
! Can't specify both `.before` and `.after`.

249 changes: 146 additions & 103 deletions tests/testthat/_snaps/as_tibble.md
Original file line number Diff line number Diff line change
@@ -1,128 +1,171 @@
# as_tibble() implements unique names
# output test

Code
invalid_df <- as_tibble(list(3, 4, 5), .name_repair = "unique")
Message <rlib_message_name_repair>
New names:
* `` -> `...1`
* `` -> `...2`
* `` -> `...3`

# as_tibble() implements universal names

as_tibble(list(1))
Condition
Error:
! Column 1 must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty name found at location 1.
Code
invalid_df <- as_tibble(list(3, 4, 5), .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `` -> `...1`
* `` -> `...2`
* `` -> `...3`

# as_tibble.matrix() supports .name_repair

as_tibble(list(1, 2))
Condition
Error:
! Columns 1 and 2 must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty names found at locations 1 and 2.
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `` -> `...1`
* `` -> `...2`

---

as_tibble(list(a = 1, 2))
Condition
Error:
! Column 2 must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty name found at location 2.
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `if` -> `.if`

# as_tibble.poly() supports .name_repair

as_tibble(as.list(1:26))
Condition
Error:
! Columns 1, 2, 3, 4, 5, and 21 more must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty names found at locations 1, 2, 3, 4, 5, etc.
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `1` -> `...1`
* `2` -> `...2`
* `3` -> `...3`

# as_tibble.table() supports .name_repair

as_tibble(set_names(list(1), "..1"))
Condition
Error:
! Column 1 must not have names of the form ... or ..j.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be of the form `...` or `..j`.
x These names are invalid:
* "..1" at location 1.
Code
as_tibble(set_names(list(1:26), paste0("..", 1:26)))
Condition
Error in `set_names()`:
! The size of `nm` (26) must be compatible with the size of `x` (1).
Code
as_tibble(list(a = 1, a = 1))
Condition
Error:
! Column name `a` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 2.
Code
as_tibble(table(a = c(1, 1, 1, 2, 2, 2), a = c(3, 4, 5, 3, 4, 5)))
Error <tibble_error_column_names_must_be_unique>
Column name `a` must not be duplicated.
as_tibble(list(a = 1, a = 1, b = 1, b = 1))
Condition
Error:
! Column names `a` and `b` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 2.
* "b" at locations 3 and 4.
Code
as_tibble(table(c(1, 1, 1, 2, 2, 2), c(3, 4, 5, 3, 4, 5)))
Error <tibble_error_column_names_cannot_be_empty>
Columns 1 and 2 must be named.
as_tibble(list(a = new_environment()))
Condition
Error:
! All columns in a tibble must be vectors.
x Column `a` is an environment.
Code
as_tibble_row(list(1))
Condition
Error:
! Column 1 must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty name found at location 1.
Code
as_tibble_row(list(1, 2))
Condition
Error:
! Columns 1 and 2 must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty names found at locations 1 and 2.

---

Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `a` -> `a...1`
* `a` -> `a...2`

---

as_tibble_row(list(a = 1, 2))
Condition
Error:
! Column 2 must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty name found at location 2.
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `if` -> `.if`

---

as_tibble_row(as.list(1:26))
Condition
Error:
! Columns 1, 2, 3, 4, 5, and 21 more must be named.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be empty.
x Empty names found at locations 1, 2, 3, 4, 5, etc.
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `n` -> `n...2`
* `n` -> `n...3`

# as_tibble.ts() supports .name_repair, minimal by default (#537)

as_tibble_row(set_names(list(1), "..1"))
Condition
Error:
! Column 1 must not have names of the form ... or ..j.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names can't be of the form `...` or `..j`.
x These names are invalid:
* "..1" at location 1.
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `` -> `...1`
* `` -> `...2`

---

as_tibble_row(set_names(list(1:26), paste0("..", 1:26)))
Condition
Error in `set_names()`:
! The size of `nm` (26) must be compatible with the size of `x` (1).
Code
universal <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `if` -> `.if`

# creates col names with name repair

as_tibble_row(list(a = 1, a = 1))
Condition
Error:
! Column name `a` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 2.
Code
out <- as_tibble(x, .name_repair = "unique")
Message <rlib_message_name_repair>
New names:
* `` -> `...1`
* `` -> `...2`

---

as_tibble_row(list(a = 1, a = 1, b = 1, b = 1))
Condition
Error:
! Column names `a` and `b` must not be duplicated.
Use .name_repair to specify repair.
Caused by error in `stop_vctrs()`:
! Names must be unique.
x These names are duplicated:
* "a" at locations 1 and 2.
* "b" at locations 3 and 4.
Code
as_tibble_row(list(a = new_environment()))
Condition
Error in `stop_vctrs()`:
! Input must be a vector, not an environment.
Code
as_tibble_row(list(a = 1:3))
Condition
Error:
! All elements must be size one, use `list()` to wrap.
x Element `a` is of size 3.
Code
out <- as_tibble(x, .name_repair = "universal")
Message <rlib_message_name_repair>
New names:
* `` -> `...1`
* `` -> `...2`
as_tibble_row(list(a = 1:3, b = 1:3))
Condition
Error:
! All elements must be size one, use `list()` to wrap.
x Element `a` is of size 3.
x Element `b` is of size 3.

0 comments on commit 23b26bc

Please sign in to comment.