This file is indexed.

/usr/share/doc/r-cran-rlang/tests/testthat/test-arg.R is in r-cran-rlang 0.2.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
31
32
33
34
35
36
37
38
39
40
41
42
43
context("arg")

test_that("matches arg", {
  myarg <- c("foo", "baz")
  expect_identical(arg_match(myarg, c("bar", "foo")), "foo")
  expect_error(
    regex = "`myarg` should be one of: \"bar\" or \"baz\"",
    arg_match(myarg, c("bar", "baz"))
  )
})

test_that("informative error message on partial match", {
  myarg <- "f"
  expect_error(
    regex = "Did you mean \"foo\"?",
    arg_match(myarg, c("bar", "foo"))
  )
})

test_that("gets choices from function", {
  fn <- function(myarg = c("bar", "foo")) arg_match(myarg)
  expect_error(fn("f"), "Did you mean \"foo\"?")
  expect_identical(fn("foo"), "foo")
})

test_that("is_missing() works with symbols", {
  x <- missing_arg()
  expect_true(is_missing(x))
})

test_that("is_missing() works with non-symbols", {
  expect_true(is_missing(missing_arg()))

  l <- list(missing_arg())
  expect_true(is_missing(l[[1]]))
  expect_error(missing(l[[1]]), "invalid use")
})

test_that("maybe_missing() forwards missing value", {
  x <- missing_arg()
  expect_true(is_missing(maybe_missing(x)))
  expect_false(is_missing(maybe_missing(1L)))
})