Skip to content

Commit

Permalink
de-lint test-undesirable_operator_linter.R
Browse files Browse the repository at this point in the history
  • Loading branch information
AshesITR committed Dec 6, 2020
1 parent 92f6608 commit 92a9fe0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/testthat/test-undesirable_operator_linter.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
context("undesirable_operator_linter")

test_that("linter returns correct linting", {
linter <- undesirable_operator_linter(op=c("$"="use the `[[` accessor", "<<-"=NA))
msgA <- rex::escape("Operator `<<-` is undesirable.")
msgD <- rex::escape("Operator `$` is undesirable. As an alternative, use the `[[` accessor.")
linter <- undesirable_operator_linter(op = c("$" = "use the `[[` accessor", "<<-" = NA))
msg_assign <- rex::escape("Operator `<<-` is undesirable.")
msg_dollar <- rex::escape("Operator `$` is undesirable. As an alternative, use the `[[` accessor.")

expect_lint("x <- foo:::getObj()", NULL, linter)
expect_lint("cat(\"10$\")", NULL, linter)
expect_lint("a <<- log(10)", list(message=msgA, line_number=1L, column_number=3L), linter)
expect_lint("data$parsed == c(1, 2)", list(message=msgD, line_number=1L, column_number=5L), linter)
expect_lint("a <<- log(10)", list(message = msg_assign, line_number = 1L, column_number = 3L), linter)
expect_lint("data$parsed == c(1, 2)", list(message = msg_dollar, line_number = 1L, column_number = 5L), linter)
})

0 comments on commit 92a9fe0

Please sign in to comment.