Skip to content

Commit

Permalink
Split coercion tests (#6846)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed May 17, 2023
1 parent 813dc33 commit c48230c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/testthat/test-join.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 43,18 @@ test_that("filtering joins preserve row and column order of x (#2964)", {
})

test_that("keys are coerced to symmetric type", {
foo <- tibble(id = 1:2, var1 = "foo")
bar <- tibble(id = as.numeric(1:2), var2 = "bar")
expect_type(inner_join(foo, bar, by = "id")$id, "double")
expect_type(inner_join(bar, foo, by = "id")$id, "double")

foo <- tibble(id = factor(c("a", "b")), var1 = "foo")
bar <- tibble(id = c("a", "b"), var2 = "bar")
expect_type(inner_join(foo, bar, by = "id")$id, "character")
expect_type(inner_join(bar, foo, by = "id")$id, "character")
})

test_that("factor keys are coerced to the union factor type", {
df1 <- tibble(x = 1, y = factor("a"))
df2 <- tibble(x = 2, y = factor("b"))
out <- full_join(df1, df2, by = c("x", "y"))
Expand Down

0 comments on commit c48230c

Please sign in to comment.