File: test-routine_registration_linter.R

package info (click to toggle)
r-cran-lintr 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,396 kB
  • sloc: sh: 13; xml: 10; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
patrick::with_parameters_test_that(
  "lints correctly",
  {
    linter <- routine_registration_linter()
    expect_lint(sprintf("%s(ROUTINE, 1)", caller), NULL, linter)
    expect_lint(
      sprintf("%s('ROUTINE', PACKAGE = 'foo')", caller),
      "Register your native code routines with useDynLib",
      linter
    )
  },
  .test_name = c(".C", ".Call", ".External", ".Fortran"),
  caller = c(".C", ".Call", ".External", ".Fortran")
)

test_that("lints vectorize", {
  lint_msg <- "Register your native code routines with useDynLib"

  expect_lint(
    trim_some("{
      .C('ROUTINE', PACKAGE = 'foo')
      .External('POUTINE', PACKAGE = 'bar')
    }"),
    list(
      list(lint_msg, line_number = 2L),
      list(lint_msg, line_number = 3L)
    ),
    routine_registration_linter()
  )
})