Skip to content

Commit

Permalink
Test that arrange() breaks ties correctly when used with across() (
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan authored Oct 4, 2022
1 parent e2770ef commit 1a7061f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/testthat/test-arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ test_that("arrange() supports across() (#4679)", {
)
})

test_that("arrange() works with across() cols that return multiple columns (#6490)", {
df <- tibble(
a = c(1, 1, 1),
b = c(2, 2, 2),
c = c(4, 4, 3),
d = c(5, 2, 7)
)

expect_identical(
arrange(df, across(c(a, b)), across(c(c, d))),
df[c(3, 2, 1),]
)
})

test_that("arrange() with empty dots still calls dplyr_row_slice()", {
tbl <- new_tibble(list(x = 1), nrow = 1L)
foo <- structure(tbl, class = c("foo_df", class(tbl)))
Expand Down Expand Up @@ -411,6 +425,22 @@ test_that("legacy - arrange() supports across() (#4679)", {
)
})

test_that("legacy - arrange() works with across() cols that return multiple columns (#6490)", {
local_options(dplyr.legacy_locale = TRUE)

df <- tibble(
a = c(1, 1, 1),
b = c(2, 2, 2),
c = c(4, 4, 3),
d = c(5, 2, 7)
)

expect_identical(
arrange(df, across(c(a, b)), across(c(c, d))),
df[c(3, 2, 1),]
)
})

test_that("legacy - arrange sorts missings in df-cols correctly", {
local_options(dplyr.legacy_locale = TRUE)

Expand Down

0 comments on commit 1a7061f

Please sign in to comment.