Skip to content

Commit

Permalink
Test for top level pick()
Browse files Browse the repository at this point in the history
  • Loading branch information
markfairbanks committed Nov 14, 2022
1 parent fe9cc96 commit da7029c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/testthat/test-tidyeval-across.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test_that("across() output can be used as a data frame", {
expect_named(res, c("x", "y", "z", "across_df"))
expect_equal(res$across_df, c(4, 6, 8))

expr <- dt_squash(expr(across(c(x, y), ~ .x + 1)), df$env, df, is_top_across = FALSE)
expr <- dt_squash(expr(across(c(x, y), ~ .x + 1)), df$env, df, is_top = FALSE)
expect_equal(expr, expr(data.table(x = x + 1, y = y + 1)))
})

Expand All @@ -180,8 +180,11 @@ test_that("pick() works", {
expect_named(res, c("x", "y", "z", "row_sum"))
expect_equal(res$row_sum, c(2, 4, 6))

expr <- dt_squash(expr(pick(x, y)), df$env, df, is_top_across = FALSE)
expr <- dt_squash(expr(pick(x, y)), df$env, df, is_top = FALSE)
expect_equal(expr, expr(data.table(x = x, y = y)))

# Top level pick works
expect_equal(group_by(df, pick(x, y))$groups, c("x", "y"))
})

# if_all ------------------------------------------------------------------
Expand Down

0 comments on commit da7029c

Please sign in to comment.