Skip to content

Commit

Permalink
Adding regression test for #2326
Browse files Browse the repository at this point in the history
closes #2326
  • Loading branch information
romainfrancois committed Nov 25, 2019
1 parent 07c353e commit ac61736
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# dplyr 0.9.0 (in development)

* `mutate()` and `summarise()` automatically unpack unnamed tibble results (#2326).

* `group_keys.rowwise_df()` gives a 0 column data frame with n() rows.

* `group_by()` uses hashing from the `vctrs` package.
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-mutate.r
Original file line number Diff line number Diff line change
Expand Up @@ -898,3 +898,14 @@ test_that("mutate() evaluates expression for empty groups", {
expect_equal(count, 6L)
expect_is(res$x, "numeric")
})

test_that("mutate() unpacks unnamed tibble results (#2326)", {
expect_equal(
iris %>% group_by(Species) %>% mutate(
tibble(Sepal = Sepal.Length * Petal.Length, Petal = Petal.Length * Petal.Width)
),
iris %>% group_by(Species) %>% mutate(Sepal = Sepal.Length * Petal.Length, Petal = Petal.Length * Petal.Width)
)
})


9 changes: 9 additions & 0 deletions tests/testthat/test-summarise.r
Original file line number Diff line number Diff line change
Expand Up @@ -1121,3 +1121,12 @@ test_that("summarise() correctly handle summarised list columns (#4349)", {
expect_identical(res$z, res$y)
expect_equal(res$z, list(1))
})

test_that("summarise() unpacks unnamed tibble results (#2326)", {
expect_equal(
iris %>% group_by(Species) %>% summarise(
tibble(Sepal = mean(Sepal.Length * Petal.Length), Petal = mean(Petal.Length * Petal.Width))
),
iris %>% group_by(Species) %>% summarise(Sepal = mean(Sepal.Length * Petal.Length), Petal = mean(Petal.Length * Petal.Width))
)
})

0 comments on commit ac61736

Please sign in to comment.