This file is indexed.

/usr/share/doc/r-cran-pillar/tests/testthat/test-format_scientific.R is in r-cran-pillar 1.0.1-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
context("format_scientific")

format_scientific_bw <- function(x, ...) {
  old <- options(crayon.enabled = FALSE)
  on.exit(options(old))

  ret <- pillar_shaft(x, ...)
  # Hack: Pretend decimal format requires 100 characters
  ret$dec <- set_width(ret$dec, 100)
  ret <- set_width(ret, 100)
  ret <- set_min_width(ret, min(get_min_widths(ret)))
  format(ret, width = get_min_width(ret))
}

test_that("negative values displayed correct", {
  f <- format_scientific_bw(-0.123, superscript = FALSE)
  expect_equal(unname(format(f)), "-1.23e-1")
})

test_that("exponents correct in presence of NA", {
  f <- format_scientific_bw(c(NA, 1e-5), superscript = FALSE)
  expect_equal(unname(format(f)), c("NA      ", " 1.00e-5"))
})

test_that("output test", {
  expect_pillar_output(10 ^ c(-9, -6, 3, 9), width = 10, filename = "scientific.txt")
  expect_pillar_output((10 ^ c(3, 9, 15, 22)) * c(-1, 1), width = 10, filename = "scientific-short-neg.txt")
})