From a54eef2bfbb4cf14c4d1b2f602adaf9978ab58f5 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 19 Nov 2023 09:29:31 -0800 Subject: [PATCH] vectorization+metadata --- tests/testthat/test-rep_len_linter.R | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/testthat/test-rep_len_linter.R b/tests/testthat/test-rep_len_linter.R index 4819bd780..385f161a1 100644 --- a/tests/testthat/test-rep_len_linter.R +++ b/tests/testthat/test-rep_len_linter.R @@ -34,3 +34,21 @@ test_that("rep_len_linter blocks simple disallowed usages", { # implicit usage in third argument expect_lint("rep(1:10, 10:1, 50)", lint_msg, linter) }) + +test_that("vectorized lints work", { + lint_msg <- rex::rex("Use rep_len(x, n) instead of rep(x, length.out = n).") + + expect_lint( + trim_some("{ + rep(x, y) + rep(1:10, length.out = 50) + rep(x, each = 4, length.out = 50) + rep(x, length.out = 50) + }"), + list( + list(lint_msg, line_number = 3L), + list(lint_msg, line_number = 5L) + ), + rep_len_linter() + ) +}) \ No newline at end of file