|
5 | 5 | # gives an error with more than one arg
|
6 | 6 |
|
7 | 7 | Code
|
8 |
| - (expect_error(arg_match0_wrapper(c("bar", "fun"), c("bar", "baz")))) |
9 |
| - Output |
10 |
| - <error/rlang_error> |
| 8 | + arg_match0_wrapper(c("bar", "fun"), c("bar", "baz")) |
| 9 | + Condition <rlang_error> |
11 | 10 | Error in `arg_match0_wrapper()`:
|
12 | 11 | ! `arg` must be length 1 or a permutation of `c("bar", "baz")`.
|
13 | 12 |
|
14 | 13 | # gives error with different than rearranged arg vs value
|
15 | 14 |
|
16 |
| - `myarg` must be one of "fun" or "bar", not "foo". |
17 |
| - |
18 |
| ---- |
19 |
| - |
20 |
| - `arg` must be length 1 or a permutation of `c("foo", "bar")`. |
| 15 | + Code |
| 16 | + f() |
| 17 | + Condition |
| 18 | + Error in `f()`: |
| 19 | + ! `myarg` must be one of "fun" or "bar", not "foo". |
| 20 | + Code |
| 21 | + arg_match0_wrapper(c("foo", "foo"), c("foo", "bar"), arg_nm = "x") |
| 22 | + Condition |
| 23 | + Error in `arg_match0_wrapper()`: |
| 24 | + ! `arg` must be length 1 or a permutation of `c("foo", "bar")`. |
21 | 25 |
|
22 | 26 | # `arg_match()` has informative error messages
|
23 | 27 |
|
24 | 28 | Code
|
25 |
| - (expect_error(arg_match_wrapper("continuuos", c("discrete", "continuous"), |
26 |
| - "my_arg"))) |
27 |
| - Output |
28 |
| - <error/rlang_error> |
| 29 | + arg_match_wrapper("continuuos", c("discrete", "continuous"), "my_arg") |
| 30 | + Condition <rlang_error> |
29 | 31 | Error in `arg_match0_wrapper()`:
|
30 | 32 | ! `my_arg` must be one of "discrete" or "continuous", not "continuuos".
|
31 | 33 | i Did you mean "continuous"?
|
32 | 34 | Code
|
33 |
| - (expect_error(arg_match_wrapper("fou", c("bar", "foo"), "my_arg"))) |
34 |
| - Output |
35 |
| - <error/rlang_error> |
| 35 | + arg_match_wrapper("fou", c("bar", "foo"), "my_arg") |
| 36 | + Condition <rlang_error> |
36 | 37 | Error in `arg_match0_wrapper()`:
|
37 | 38 | ! `my_arg` must be one of "bar" or "foo", not "fou".
|
38 | 39 | i Did you mean "foo"?
|
39 | 40 | Code
|
40 |
| - (expect_error(arg_match_wrapper("fu", c("ba", "fo"), "my_arg"))) |
41 |
| - Output |
42 |
| - <error/rlang_error> |
| 41 | + arg_match_wrapper("fu", c("ba", "fo"), "my_arg") |
| 42 | + Condition <rlang_error> |
43 | 43 | Error in `arg_match0_wrapper()`:
|
44 | 44 | ! `my_arg` must be one of "ba" or "fo", not "fu".
|
45 | 45 | i Did you mean "fo"?
|
46 | 46 | Code
|
47 |
| - (expect_error(arg_match_wrapper("baq", c("foo", "baz", "bas"), "my_arg"))) |
48 |
| - Output |
49 |
| - <error/rlang_error> |
| 47 | + arg_match_wrapper("baq", c("foo", "baz", "bas"), "my_arg") |
| 48 | + Condition <rlang_error> |
50 | 49 | Error in `arg_match0_wrapper()`:
|
51 | 50 | ! `my_arg` must be one of "foo", "baz", or "bas", not "baq".
|
52 | 51 | i Did you mean "baz"?
|
53 | 52 | Code
|
54 |
| - (expect_error(arg_match_wrapper("", character(), "my_arg"))) |
55 |
| - Output |
56 |
| - <error/rlang_error> |
| 53 | + arg_match_wrapper("", character(), "my_arg") |
| 54 | + Condition <rlang_error> |
57 | 55 | Error in `arg_match0()`:
|
58 | 56 | ! `values` must have at least one element.
|
59 | 57 | Code
|
60 |
| - (expect_error(arg_match_wrapper("fo", "foo", quote(f())))) |
61 |
| - Output |
62 |
| - <error/rlang_error> |
| 58 | + arg_match_wrapper("fo", "foo", quote(f())) |
| 59 | + Condition <rlang_error> |
63 | 60 | Error in `arg_match0()`:
|
64 | 61 | ! `arg_nm` must be a string or symbol.
|
65 | 62 |
|
66 | 63 | # `arg_match()` provides no suggestion when the edit distance is too large
|
67 | 64 |
|
68 | 65 | Code
|
69 |
| - (expect_error(arg_match0_wrapper("foobaz", c("fooquxs", "discrete"), "my_arg"))) |
70 |
| - Output |
71 |
| - <error/rlang_error> |
| 66 | + arg_match0_wrapper("foobaz", c("fooquxs", "discrete"), "my_arg") |
| 67 | + Condition <rlang_error> |
72 | 68 | Error in `arg_match0_wrapper()`:
|
73 | 69 | ! `my_arg` must be one of "fooquxs" or "discrete", not "foobaz".
|
74 | 70 | Code
|
75 |
| - (expect_error(arg_match0_wrapper("a", c("b", "c"), "my_arg"))) |
76 |
| - Output |
77 |
| - <error/rlang_error> |
| 71 | + arg_match0_wrapper("a", c("b", "c"), "my_arg") |
| 72 | + Condition <rlang_error> |
78 | 73 | Error in `arg_match0_wrapper()`:
|
79 | 74 | ! `my_arg` must be one of "b" or "c", not "a".
|
80 | 75 |
|
81 | 76 | # `arg_match()` makes case-insensitive match
|
82 | 77 |
|
83 | 78 | Code
|
84 |
| - (expect_error(arg_match0_wrapper("a", c("A", "B"), "my_arg"), |
85 |
| - "Did you mean \"A\"?")) |
86 |
| - Output |
87 |
| - <error/rlang_error> |
| 79 | + arg_match0_wrapper("a", c("A", "B"), "my_arg") |
| 80 | + Condition <rlang_error> |
88 | 81 | Error in `arg_match0_wrapper()`:
|
89 | 82 | ! `my_arg` must be one of "A" or "B", not "a".
|
90 | 83 | i Did you mean "A"?
|
91 | 84 | Code
|
92 |
| - (expect_error(arg_match0_wrapper("aa", c("AA", "aA"), "my_arg"), |
93 |
| - "Did you mean \"aA\"?")) |
94 |
| - Output |
95 |
| - <error/rlang_error> |
| 85 | + arg_match0_wrapper("aa", c("AA", "aA"), "my_arg") |
| 86 | + Condition <rlang_error> |
96 | 87 | Error in `arg_match0_wrapper()`:
|
97 | 88 | ! `my_arg` must be one of "AA" or "aA", not "aa".
|
98 | 89 | i Did you mean "aA"?
|
99 | 90 |
|
100 | 91 | # check_required() checks argument is supplied (#1118)
|
101 | 92 |
|
102 | 93 | Code
|
103 |
| - (expect_error(f())) |
104 |
| - Output |
105 |
| - <error/rlang_error> |
| 94 | + f() |
| 95 | + Condition <rlang_error> |
106 | 96 | Error in `f()`:
|
107 | 97 | ! `x` is absent but must be supplied.
|
108 | 98 | Code
|
109 |
| - (expect_error(g())) |
110 |
| - Output |
111 |
| - <error/rlang_error> |
| 99 | + g() |
| 100 | + Condition <rlang_error> |
112 | 101 | Error in `f()`:
|
113 | 102 | ! `x` is absent but must be supplied.
|
114 | 103 |
|
115 | 104 | # arg_match() supports symbols and scalar strings
|
116 | 105 |
|
117 | 106 | Code
|
118 |
| - (expect_error(arg_match0_wrapper(chr_get("fo", 0L), c("bar", "foo"), "my_arg"))) |
119 |
| - Output |
120 |
| - <error/rlang_error> |
| 107 | + arg_match0_wrapper(chr_get("fo", 0L), c("bar", "foo"), "my_arg") |
| 108 | + Condition <rlang_error> |
121 | 109 | Error in `arg_match0_wrapper()`:
|
122 | 110 | ! `my_arg` must be one of "bar" or "foo", not "fo".
|
123 | 111 | i Did you mean "foo"?
|
124 | 112 |
|
125 | 113 | # arg_match() requires an argument symbol
|
126 | 114 |
|
127 | 115 | Code
|
128 |
| - (expect_error(wrapper())) |
129 |
| - Output |
130 |
| - <error/rlang_error> |
| 116 | + wrapper() |
| 117 | + Condition <rlang_error> |
131 | 118 | Error in `arg_match()`:
|
132 | 119 | ! `arg` must be a symbol, not the string "foo".
|
133 | 120 |
|
134 | 121 | # can match multiple arguments
|
135 | 122 |
|
136 | 123 | Code
|
137 |
| - (expect_error(my_wrapper("ba"))) |
138 |
| - Output |
139 |
| - <error/rlang_error> |
| 124 | + my_wrapper("ba") |
| 125 | + Condition <rlang_error> |
140 | 126 | Error in `my_wrapper()`:
|
141 | 127 | ! `my_arg` must be one of "foo", "bar", or "baz", not "ba".
|
142 | 128 | i Did you mean "bar"?
|
143 | 129 | Code
|
144 |
| - (expect_error(my_wrapper(c("foo", "ba")))) |
145 |
| - Output |
146 |
| - <error/rlang_error> |
| 130 | + my_wrapper(c("foo", "ba")) |
| 131 | + Condition <rlang_error> |
147 | 132 | Error in `my_wrapper()`:
|
148 | 133 | ! `my_arg` must be one of "foo", "bar", or "baz", not "ba".
|
149 | 134 | i Did you mean "bar"?
|
150 | 135 |
|
151 | 136 | # arg_match0() defuses argument
|
152 | 137 |
|
153 | 138 | Code
|
154 |
| - (expect_error(fn("foo"))) |
155 |
| - Output |
156 |
| - <error/rlang_error> |
| 139 | + fn("foo") |
| 140 | + Condition <rlang_error> |
157 | 141 | Error in `fn()`:
|
158 | 142 | ! `arg` must be one of "bar" or "baz", not "foo".
|
159 | 143 | Code
|
160 |
| - (expect_error(arg_match0("foo", c("bar", "baz")))) |
161 |
| - Output |
162 |
| - <error/rlang_error> |
| 144 | + arg_match0("foo", c("bar", "baz")) |
| 145 | + Condition <rlang_error> |
163 | 146 | Error:
|
164 | 147 | ! `"foo"` must be one of "bar" or "baz", not "foo".
|
165 | 148 |
|
166 | 149 | # check_exclusive works
|
167 | 150 |
|
168 | 151 | Code
|
169 |
| - (expect_error(f())) |
170 |
| - Output |
171 |
| - <error/rlang_error> |
| 152 | + f() |
| 153 | + Condition <rlang_error> |
172 | 154 | Error in `check_exclusive()`:
|
173 | 155 | ! Must supply at least two arguments.
|
174 | 156 | Code
|
175 |
| - (expect_error(g())) |
176 |
| - Output |
177 |
| - <error/rlang_error> |
| 157 | + g() |
| 158 | + Condition <rlang_error> |
178 | 159 | Error in `check_exclusive()`:
|
179 | 160 | ! Must supply at least two arguments.
|
180 | 161 | Code
|
181 |
| - (expect_error(h())) |
182 |
| - Output |
183 |
| - <error/rlang_error> |
| 162 | + h() |
| 163 | + Condition <rlang_error> |
184 | 164 | Error in `check_exclusive()`:
|
185 | 165 | ! Must supply at least two arguments.
|
186 | 166 |
|
187 | 167 | ---
|
188 | 168 |
|
189 | 169 | Code
|
190 |
| - (expect_error(f())) |
191 |
| - Output |
192 |
| - <error/rlang_error> |
| 170 | + f() |
| 171 | + Condition <rlang_error> |
193 | 172 | Error in `f()`:
|
194 | 173 | ! One of `foo` or `bar` must be supplied.
|
195 | 174 |
|
196 | 175 | ---
|
197 | 176 |
|
198 | 177 | Code
|
199 | 178 | # All arguments supplied
|
200 |
| - (expect_error(g(foo, bar, baz))) |
201 |
| - Output |
202 |
| - <error/rlang_error> |
| 179 | + g(foo, bar, baz) |
| 180 | + Condition <rlang_error> |
203 | 181 | Error in `g()`:
|
204 | 182 | ! Exactly one of `foo`, `bar`, or `baz` must be supplied.
|
205 | 183 | Code
|
206 | 184 | # Some arguments supplied
|
207 |
| - (expect_error(g(foo, bar))) |
208 |
| - Output |
209 |
| - <error/rlang_error> |
| 185 | + g(foo, bar) |
| 186 | + Condition <rlang_error> |
210 | 187 | Error in `g()`:
|
211 | 188 | ! Exactly one of `foo`, `bar`, or `baz` must be supplied.
|
212 | 189 | x `foo` and `bar` were supplied together.
|
213 | 190 |
|
214 | 191 | # arg_match() mentions correct call if wrong type is supplied (#1388)
|
215 | 192 |
|
216 | 193 | Code
|
217 |
| - (expect_error(f(1))) |
218 |
| - Output |
219 |
| - <error/rlang_error> |
| 194 | + f(1) |
| 195 | + Condition <rlang_error> |
220 | 196 | Error in `f()`:
|
221 | 197 | ! `my_arg` must be a string or character vector.
|
222 | 198 | Code
|
223 |
| - (expect_error(g(1))) |
224 |
| - Output |
225 |
| - <error/rlang_error> |
| 199 | + g(1) |
| 200 | + Condition <rlang_error> |
226 | 201 | Error in `g()`:
|
227 | 202 | ! `my_arg` must be a character vector, not the number 1.
|
228 | 203 |
|
|
253 | 228 | # arg_match() supports `NA` (#1519)
|
254 | 229 |
|
255 | 230 | Code
|
256 |
| - (expect_error(f(NA))) |
257 |
| - Output |
258 |
| - <error/rlang_error> |
| 231 | + f(NA) |
| 232 | + Condition <rlang_error> |
259 | 233 | Error in `f()`:
|
260 | 234 | ! `x` must be a character vector, not `NA`.
|
261 | 235 | Code
|
262 |
| - (expect_error(f(na_chr))) |
263 |
| - Output |
264 |
| - <error/rlang_error> |
| 236 | + f(na_chr) |
| 237 | + Condition <rlang_error> |
265 | 238 | Error in `f()`:
|
266 | 239 | ! `x` must be a single string, not a character `NA`.
|
267 | 240 | Code
|
268 |
| - (expect_error(f(chr()))) |
269 |
| - Output |
270 |
| - <error/rlang_error> |
| 241 | + f(chr()) |
| 242 | + Condition <rlang_error> |
271 | 243 | Error in `f()`:
|
272 | 244 | ! `x` must be length 1, not length 0
|
273 | 245 |
|
0 commit comments