Skip to content

Commit 70568e4

Browse files
committed
skip on R < 4.1, add tests for infix_spaces_linter()
1 parent 3ba9cc9 commit 70568e4

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

tests/testthat/test-indentation_linter.R

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,6 @@ test_that("indentation linter flags unindented expressions", {
111111
linter
112112
)
113113

114-
# native pipe indents
115-
expect_lint(
116-
trim_some("
117-
a |>
118-
foo()
119-
"),
120-
NULL,
121-
linter
122-
)
123-
124-
expect_lint(
125-
trim_some("
126-
b <- a |>
127-
foo()
128-
"),
129-
NULL,
130-
linter
131-
)
132-
133114
expect_lint(
134115
trim_some("
135116
if (cond)
@@ -686,3 +667,26 @@ test_that("consecutive same-level lints are suppressed", {
686667
indentation_linter()
687668
)
688669
})
670+
671+
test_that("native pipe is supported", {
672+
skip_if_not_r_version("4.1")
673+
linter <- indentation_linter()
674+
675+
expect_lint(
676+
trim_some("
677+
a |>
678+
foo()
679+
"),
680+
NULL,
681+
linter
682+
)
683+
684+
expect_lint(
685+
trim_some("
686+
b <- a |>
687+
foo()
688+
"),
689+
NULL,
690+
linter
691+
)
692+
})

tests/testthat/test-infix_spaces_linter.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,11 @@ test_that("Rules around missing arguments are respected", {
177177
expect_lint("switch(a =, b = 2)", lint_msg, linter)
178178
expect_lint("alist(missing_arg =)", lint_msg, linter)
179179
})
180+
181+
test_that("native pipe is supported", {
182+
skip_if_not_r_version("4.1")
183+
linter <- infix_spaces_linter()
184+
185+
expect_lint("a |> foo()", NULL, linter)
186+
expect_lint("a|>foo()", rex::rex("Put spaces around all infix operators."), linter)
187+
})

0 commit comments

Comments
 (0)