|
224 | 224 | <error/vctrs_error_subscript_type>
|
225 | 225 | Error:
|
226 | 226 | ! Can't extract element with `1:2`.
|
227 |
| - x Subscript `1:2` must be size 1, not 2. |
| 227 | + Caused by error: |
| 228 | + ! `1:2` must be size 1, not 2. |
228 | 229 | Code
|
229 | 230 | (expect_error(vec_as_location2(c("foo", "bar"), 2L, c("foo", "bar")), class = "vctrs_error_subscript_type")
|
230 | 231 | )
|
231 | 232 | Output
|
232 | 233 | <error/vctrs_error_subscript_type>
|
233 | 234 | Error:
|
234 | 235 | ! Can't extract element with `c("foo", "bar")`.
|
235 |
| - x Subscript `c("foo", "bar")` must be size 1, not 2. |
| 236 | + Caused by error: |
| 237 | + ! `c("foo", "bar")` must be size 1, not 2. |
236 | 238 | Code
|
237 | 239 | # Idem with custom `arg`
|
238 | 240 | (expect_error(vec_as_location2(1:2, 2L, arg = "foo", call = call("my_function")),
|
|
241 | 243 | <error/vctrs_error_subscript_type>
|
242 | 244 | Error in `my_function()`:
|
243 | 245 | ! Can't extract element with `foo`.
|
244 |
| - x Subscript `foo` must be size 1, not 2. |
| 246 | + Caused by error: |
| 247 | + ! `foo` must be size 1, not 2. |
245 | 248 | Code
|
246 | 249 | (expect_error(vec_as_location2(mtcars, 10L, arg = "foo", call = call(
|
247 | 250 | "my_function")), class = "vctrs_error_subscript_type"))
|
|
257 | 260 | <error/vctrs_error_subscript_type>
|
258 | 261 | Error in `my_function()`:
|
259 | 262 | ! Can't extract element with `foo`.
|
260 |
| - x Subscript `foo` must be size 1, not 2. |
| 263 | + Caused by error: |
| 264 | + ! `foo` must be size 1, not 2. |
261 | 265 |
|
262 | 266 | # vec_as_location2() requires positive integers
|
263 | 267 |
|
|
267 | 271 | <error/vctrs_error_subscript_type>
|
268 | 272 | Error:
|
269 | 273 | ! Can't extract element with `0`.
|
270 |
| - x Subscript `0` must be a positive location, not 0. |
| 274 | + Caused by error: |
| 275 | + ! `0` must be a positive location, not 0. |
271 | 276 | Code
|
272 | 277 | (expect_error(vec_as_location2(-1, 2L), class = "vctrs_error_subscript_type"))
|
273 | 278 | Output
|
274 | 279 | <error/vctrs_error_subscript_type>
|
275 | 280 | Error:
|
276 | 281 | ! Can't extract element with `-1`.
|
277 |
| - x Subscript `-1` must be a positive location, not -1. |
| 282 | + Caused by error: |
| 283 | + ! `-1` must be a positive location, not -1. |
278 | 284 | Code
|
279 | 285 | # Idem with custom `arg`
|
280 | 286 | (expect_error(vec_as_location2(0, 2L, arg = "foo", call = call("my_function")),
|
|
283 | 289 | <error/vctrs_error_subscript_type>
|
284 | 290 | Error in `my_function()`:
|
285 | 291 | ! Can't extract element with `foo`.
|
286 |
| - x Subscript `foo` must be a positive location, not 0. |
| 292 | + Caused by error: |
| 293 | + ! `foo` must be a positive location, not 0. |
287 | 294 |
|
288 | 295 | # vec_as_location2() fails with NA
|
289 | 296 |
|
|
294 | 301 | <error/vctrs_error_subscript_type>
|
295 | 302 | Error:
|
296 | 303 | ! Can't extract element with `na_int`.
|
297 |
| - x Subscript `na_int` must be a location, not an integer `NA`. |
| 304 | + Caused by error: |
| 305 | + ! `na_int` must be a location, not an integer `NA`. |
298 | 306 | Code
|
299 | 307 | (expect_error(vec_as_location2(na_chr, 1L, names = "foo"), class = "vctrs_error_subscript_type")
|
300 | 308 | )
|
301 | 309 | Output
|
302 | 310 | <error/vctrs_error_subscript_type>
|
303 | 311 | Error:
|
304 | 312 | ! Can't extract element with `na_chr`.
|
305 |
| - x Subscript `na_chr` must be a location, not a character `NA`. |
| 313 | + Caused by error: |
| 314 | + ! `na_chr` must be a location, not a character `NA`. |
306 | 315 | Code
|
307 | 316 | # Idem with custom `arg`
|
308 | 317 | (expect_error(vec_as_location2(na_int, 2L, arg = "foo", call = call(
|
|
311 | 320 | <error/vctrs_error_subscript_type>
|
312 | 321 | Error in `my_function()`:
|
313 | 322 | ! Can't extract element with `foo`.
|
314 |
| - x Subscript `foo` must be a location, not an integer `NA`. |
| 323 | + Caused by error: |
| 324 | + ! `foo` must be a location, not an integer `NA`. |
315 | 325 |
|
316 | 326 | # num_as_location() optionally forbids negative indices
|
317 | 327 |
|
|
744 | 754 | <error/vctrs_error_subscript_type>
|
745 | 755 | Error in `my_function()`:
|
746 | 756 | ! Can't extract element with `foo`.
|
747 |
| - x Subscript `foo` must be a positive location, not -1. |
| 757 | + Caused by error: |
| 758 | + ! `foo` must be a positive location, not -1. |
748 | 759 | Code
|
749 | 760 | (expect_error(vec_as_location2(0, 2, arg = "foo", call = call("my_function")),
|
750 | 761 | class = "vctrs_error_subscript_type"))
|
751 | 762 | Output
|
752 | 763 | <error/vctrs_error_subscript_type>
|
753 | 764 | Error in `my_function()`:
|
754 | 765 | ! Can't extract element with `foo`.
|
755 |
| - x Subscript `foo` must be a positive location, not 0. |
| 766 | + Caused by error: |
| 767 | + ! `foo` must be a positive location, not 0. |
756 | 768 | Code
|
757 | 769 | (expect_error(vec_as_location2(na_dbl, 2, arg = "foo", call = call(
|
758 | 770 | "my_function")), class = "vctrs_error_subscript_type"))
|
759 | 771 | Output
|
760 | 772 | <error/vctrs_error_subscript_type>
|
761 | 773 | Error in `my_function()`:
|
762 | 774 | ! Can't extract element with `foo`.
|
763 |
| - x Subscript `foo` must be a location, not an integer `NA`. |
| 775 | + Caused by error: |
| 776 | + ! `foo` must be a location, not an integer `NA`. |
764 | 777 | Code
|
765 | 778 | (expect_error(vec_as_location2(c(1, 2), 2, arg = "foo", call = call(
|
766 | 779 | "my_function")), class = "vctrs_error_subscript_type"))
|
767 | 780 | Output
|
768 | 781 | <error/vctrs_error_subscript_type>
|
769 | 782 | Error in `my_function()`:
|
770 | 783 | ! Can't extract element with `foo`.
|
771 |
| - x Subscript `foo` must be size 1, not 2. |
| 784 | + Caused by error: |
| 785 | + ! `foo` must be size 1, not 2. |
772 | 786 | Code
|
773 | 787 | (expect_error(vec_as_location(c(TRUE, FALSE), 3, arg = "foo", call = call(
|
774 | 788 | "my_function")), class = "vctrs_error_subscript_size"))
|
|
833 | 847 | <error/vctrs_error_subscript_type>
|
834 | 848 | Error:
|
835 | 849 | ! Can't rename column with `foo(bar)`.
|
836 |
| - x Subscript `foo(bar)` must be a positive location, not -1. |
| 850 | + Caused by error: |
| 851 | + ! `foo(bar)` must be a positive location, not -1. |
837 | 852 | Code
|
838 | 853 | (expect_error(with_tibble_cols(vec_as_location2(0, 2)), class = "vctrs_error_subscript_type")
|
839 | 854 | )
|
840 | 855 | Output
|
841 | 856 | <error/vctrs_error_subscript_type>
|
842 | 857 | Error:
|
843 | 858 | ! Can't rename column with `foo(bar)`.
|
844 |
| - x Subscript `foo(bar)` must be a positive location, not 0. |
| 859 | + Caused by error: |
| 860 | + ! `foo(bar)` must be a positive location, not 0. |
845 | 861 | Code
|
846 | 862 | (expect_error(with_tibble_cols(vec_as_location2(na_dbl, 2)), class = "vctrs_error_subscript_type")
|
847 | 863 | )
|
848 | 864 | Output
|
849 | 865 | <error/vctrs_error_subscript_type>
|
850 | 866 | Error:
|
851 | 867 | ! Can't rename column with `foo(bar)`.
|
852 |
| - x Subscript `foo(bar)` must be a location, not an integer `NA`. |
| 868 | + Caused by error: |
| 869 | + ! `foo(bar)` must be a location, not an integer `NA`. |
853 | 870 | Code
|
854 | 871 | (expect_error(with_tibble_cols(vec_as_location2(c(1, 2), 2)), class = "vctrs_error_subscript_type")
|
855 | 872 | )
|
856 | 873 | Output
|
857 | 874 | <error/vctrs_error_subscript_type>
|
858 | 875 | Error:
|
859 | 876 | ! Can't rename column with `foo(bar)`.
|
860 |
| - x Subscript `foo(bar)` must be size 1, not 2. |
| 877 | + Caused by error: |
| 878 | + ! `foo(bar)` must be size 1, not 2. |
861 | 879 | Code
|
862 | 880 | (expect_error(with_tibble_cols(vec_as_location(c(TRUE, FALSE), 3)), class = "vctrs_error_subscript_size")
|
863 | 881 | )
|
|
0 commit comments