Skip to content

Commit

Permalink
tests: checks if code with non-native pipe operator is correctly dete…
Browse files Browse the repository at this point in the history
…cted
  • Loading branch information
averissimo committed Oct 16, 2024
1 parent 1d87d84 commit fcb9c4a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/testthat/test-get_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ testthat::describe("Backticked symbol", {
)
})

testthat::it("with non-native pipe is detected code dependency", {
testthat::it("with non-native pipe used as function is detected code dependency", {
td <- teal_data() |>
within({
`%add_column%` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)
Expand All @@ -766,4 +766,23 @@ testthat::describe("Backticked symbol", {
)
)
})

testthat::it("with non-native pipe is detected code dependency", {
td <- teal_data() |>
within({
`%add_column%` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)
iris_ds <- iris %add_column% dplyr::tibble(new_col = "new column")
})

# Note that the original code is changed to use the non-native pipe operator
# correctly.
testthat::expect_identical(
get_code(td, datanames = "iris_ds"),
paste(
sep = "\n",
"`%add_column%` <- function(lhs, rhs) dplyr::bind_cols(lhs, rhs)",
"iris_ds <- iris %add_column% dplyr::tibble(new_col = \"new column\")"
)
)
})
})

0 comments on commit fcb9c4a

Please sign in to comment.