Skip to content

Commit e643adf

Browse files
committed
Reformat with tight () hugging
1 parent a162fe6 commit e643adf

17 files changed

+416
-630
lines changed

tests/testthat/test-across.R

Lines changed: 52 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -234,50 +234,36 @@ test_that("across() throws meaningful error with failure during expansion (#6534
234234
test_that("across() gives meaningful messages", {
235235
expect_snapshot({
236236
# expanding
237-
(
238-
expect_error(
239-
tibble(x = 1) %>%
240-
summarise(across(where(is.numeric), 42))
241-
)
242-
)
243-
(
244-
expect_error(
245-
tibble(x = 1) %>%
246-
summarise(across(y, mean))
247-
)
248-
)
237+
(expect_error(
238+
tibble(x = 1) %>%
239+
summarise(across(where(is.numeric), 42))
240+
))
241+
(expect_error(
242+
tibble(x = 1) %>%
243+
summarise(across(y, mean))
244+
))
249245

250246
# computing
251-
(
252-
expect_error(
253-
tibble(x = 1) %>%
254-
summarise(res = across(where(is.numeric), 42))
255-
)
256-
)
257-
(
258-
expect_error(
259-
tibble(x = 1) %>%
260-
summarise(z = across(y, mean))
261-
)
262-
)
263-
(
264-
expect_error(
265-
tibble(x = 1) %>%
266-
summarise(res = sum(if_any(where(is.numeric), 42)))
267-
)
268-
)
269-
(
270-
expect_error(
271-
tibble(x = 1) %>%
272-
summarise(res = sum(if_all(~ mean(.x))))
273-
)
274-
)
275-
(
276-
expect_error(
277-
tibble(x = 1) %>%
278-
summarise(res = sum(if_any(~ mean(.x))))
279-
)
280-
)
247+
(expect_error(
248+
tibble(x = 1) %>%
249+
summarise(res = across(where(is.numeric), 42))
250+
))
251+
(expect_error(
252+
tibble(x = 1) %>%
253+
summarise(z = across(y, mean))
254+
))
255+
(expect_error(
256+
tibble(x = 1) %>%
257+
summarise(res = sum(if_any(where(is.numeric), 42)))
258+
))
259+
(expect_error(
260+
tibble(x = 1) %>%
261+
summarise(res = sum(if_all(~ mean(.x))))
262+
))
263+
(expect_error(
264+
tibble(x = 1) %>%
265+
summarise(res = sum(if_any(~ mean(.x))))
266+
))
281267

282268
(expect_error(across()))
283269
(expect_error(c_across()))
@@ -290,43 +276,33 @@ test_that("across() gives meaningful messages", {
290276
42
291277
}
292278
}
293-
(
294-
expect_error(
295-
# expanding
296-
tibble(x = 1:10, y = 11:20) %>%
297-
summarise(across(everything(), error_fn))
298-
)
299-
)
300-
(
301-
expect_error(
302-
# expanding
303-
tibble(x = 1:10, y = 11:20) %>%
304-
mutate(across(everything(), error_fn))
305-
)
306-
)
279+
(expect_error(
280+
# expanding
281+
tibble(x = 1:10, y = 11:20) %>%
282+
summarise(across(everything(), error_fn))
283+
))
284+
(expect_error(
285+
# expanding
286+
tibble(x = 1:10, y = 11:20) %>%
287+
mutate(across(everything(), error_fn))
288+
))
307289

308-
(
309-
expect_error(
310-
# evaluating
311-
tibble(x = 1:10, y = 11:20) %>%
312-
summarise(force(across(everything(), error_fn)))
313-
)
314-
)
315-
(
316-
expect_error(
317-
# evaluating
318-
tibble(x = 1:10, y = 11:20) %>%
319-
mutate(force(across(everything(), error_fn)))
320-
)
321-
)
290+
(expect_error(
291+
# evaluating
292+
tibble(x = 1:10, y = 11:20) %>%
293+
summarise(force(across(everything(), error_fn)))
294+
))
295+
(expect_error(
296+
# evaluating
297+
tibble(x = 1:10, y = 11:20) %>%
298+
mutate(force(across(everything(), error_fn)))
299+
))
322300

323301
# name issue
324-
(
325-
expect_error(
326-
tibble(x = 1) %>%
327-
summarise(across(everything(), list(f = mean, f = mean)))
328-
)
329-
)
302+
(expect_error(
303+
tibble(x = 1) %>%
304+
summarise(across(everything(), list(f = mean, f = mean)))
305+
))
330306
})
331307
})
332308

tests/testthat/test-arrange.R

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,17 @@ test_that("local arrange sorts missing values to end", {
2727
test_that("arrange() gives meaningful errors", {
2828
expect_snapshot({
2929
# duplicated column name
30-
(
31-
expect_error(
32-
tibble(x = 1, x = 1, .name_repair = "minimal") %>% arrange(x)
33-
)
34-
)
30+
(expect_error(
31+
tibble(x = 1, x = 1, .name_repair = "minimal") %>% arrange(x)
32+
))
3533

3634
# error in mutate() step
37-
(
38-
expect_error(
39-
tibble(x = 1) %>% arrange(y)
40-
)
41-
)
42-
(
43-
expect_error(
44-
tibble(x = 1) %>% arrange(rep(x, 2))
45-
)
46-
)
35+
(expect_error(
36+
tibble(x = 1) %>% arrange(y)
37+
))
38+
(expect_error(
39+
tibble(x = 1) %>% arrange(rep(x, 2))
40+
))
4741
})
4842
})
4943

tests/testthat/test-case-when.R

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -271,54 +271,38 @@ test_that("throws chained errors when formula evaluation fails", {
271271

272272
test_that("case_when() give meaningful errors", {
273273
expect_snapshot({
274-
(
275-
expect_error(
276-
case_when(
277-
c(TRUE, FALSE) ~ 1:3,
278-
c(FALSE, TRUE) ~ 1:2
279-
)
274+
(expect_error(
275+
case_when(
276+
c(TRUE, FALSE) ~ 1:3,
277+
c(FALSE, TRUE) ~ 1:2
280278
)
281-
)
282-
283-
(
284-
expect_error(
285-
case_when(
286-
c(TRUE, FALSE) ~ 1,
287-
c(FALSE, TRUE, FALSE) ~ 2,
288-
c(FALSE, TRUE, FALSE, NA) ~ 3
289-
)
290-
)
291-
)
279+
))
292280

293-
(
294-
expect_error(
295-
case_when(50 ~ 1:3)
296-
)
297-
)
298-
(
299-
expect_error(
300-
case_when(paste(50))
301-
)
302-
)
303-
(
304-
expect_error(
305-
case_when(y ~ x, paste(50))
281+
(expect_error(
282+
case_when(
283+
c(TRUE, FALSE) ~ 1,
284+
c(FALSE, TRUE, FALSE) ~ 2,
285+
c(FALSE, TRUE, FALSE, NA) ~ 3
306286
)
307-
)
308-
(
309-
expect_error(
310-
case_when()
311-
)
312-
)
313-
(
314-
expect_error(
315-
case_when(NULL)
316-
)
317-
)
318-
(
319-
expect_error(
320-
case_when(~ 1:2)
321-
)
322-
)
287+
))
288+
289+
(expect_error(
290+
case_when(50 ~ 1:3)
291+
))
292+
(expect_error(
293+
case_when(paste(50))
294+
))
295+
(expect_error(
296+
case_when(y ~ x, paste(50))
297+
))
298+
(expect_error(
299+
case_when()
300+
))
301+
(expect_error(
302+
case_when(NULL)
303+
))
304+
(expect_error(
305+
case_when(~ 1:2)
306+
))
323307
})
324308
})

tests/testthat/test-colwise-mutate.R

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -408,31 +408,23 @@ test_that("_if isn't tripped up by columns named 'i' (#5330)", {
408408
test_that("colwise mutate gives meaningful error messages", {
409409
expect_snapshot({
410410
# column not found
411-
(
412-
expect_error(
413-
mutate_at(tibble(), "test", ~1)
414-
)
415-
)
411+
(expect_error(
412+
mutate_at(tibble(), "test", ~1)
413+
))
416414

417415
# not summarising grouping variables
418416
tbl <- tibble(gr1 = rep(1:2, 4), gr2 = rep(1:2, each = 4), x = 1:8)
419417
tbl <- group_by(tbl, gr1)
420-
(
421-
expect_error(
422-
summarise_at(tbl, vars(gr1), mean)
423-
)
424-
)
418+
(expect_error(
419+
summarise_at(tbl, vars(gr1), mean)
420+
))
425421

426422
# improper additional arguments
427-
(
428-
expect_error(
429-
mutate_all(mtcars, length, 0, 0)
430-
)
431-
)
432-
(
433-
expect_error(
434-
mutate_all(mtcars, mean, na.rm = TRUE, na.rm = TRUE)
435-
)
436-
)
423+
(expect_error(
424+
mutate_all(mtcars, length, 0, 0)
425+
))
426+
(expect_error(
427+
mutate_all(mtcars, mean, na.rm = TRUE, na.rm = TRUE)
428+
))
437429
})
438430
})

tests/testthat/test-colwise-select.R

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -195,48 +195,32 @@ test_that("colwise select() / rename() give meaningful errors", {
195195
df <- tibble(x = 0L, y = 0.5, z = 1)
196196

197197
# colwise rename()
198-
(
199-
expect_error(
200-
df %>% rename_all()
201-
)
202-
)
203-
(
204-
expect_error(
205-
df %>% rename_if(is_integerish)
206-
)
207-
)
208-
(
209-
expect_error(
210-
df %>% rename_at(vars(x:y))
211-
)
212-
)
213-
(
214-
expect_error(
215-
df %>% rename_all(list(tolower, toupper))
216-
)
217-
)
198+
(expect_error(
199+
df %>% rename_all()
200+
))
201+
(expect_error(
202+
df %>% rename_if(is_integerish)
203+
))
204+
(expect_error(
205+
df %>% rename_at(vars(x:y))
206+
))
207+
(expect_error(
208+
df %>% rename_all(list(tolower, toupper))
209+
))
218210

219211
# colwise select()
220-
(
221-
expect_error(
222-
df %>% select_all(list(tolower, toupper))
223-
)
224-
)
225-
(
226-
expect_error(
227-
df %>% select_if(function(.x) 1)
228-
)
229-
)
230-
(
231-
expect_error(
232-
df %>% select_if(function(.x) c(TRUE, TRUE))
233-
)
234-
)
235-
236-
(
237-
expect_error(
238-
data.frame() %>% select_all(.funs = 42)
239-
)
240-
)
212+
(expect_error(
213+
df %>% select_all(list(tolower, toupper))
214+
))
215+
(expect_error(
216+
df %>% select_if(function(.x) 1)
217+
))
218+
(expect_error(
219+
df %>% select_if(function(.x) c(TRUE, TRUE))
220+
))
221+
222+
(expect_error(
223+
data.frame() %>% select_all(.funs = 42)
224+
))
241225
})
242226
})

0 commit comments

Comments
 (0)