tests/testthat/test_packages/r_non_template/R/foo.R

a <- function(x) {
  # make sure to skip the immediate. argument when reporting
	warning("I warned you!", immediate. = TRUE)
	x+1
}

b <- function(x) {
	stop("You failed ", length(x), " times.")
}

c <- function(x) {
	cat(sprintf(
		ngettext(length(x), "small fail\n", "big fail\n")
	))

  # example from #227
  stop("Can't find article called ", src_path(name), call. = FALSE)
}

# add some duplication of the messages to stress test logic
#   on handling duplicates; part of #49
d <- function(x) {
  stop("I warned you!")
}

e <- function(x) {
  # do recommend gettextf here: "Argument missing: %s" is better. #51
  warning(#also don't fail due to intervening comments, #59
    "Argument missing: ", # see #59; kept comment tight above to test numbering exactly
    x
  )
  # don't recommend gettextf here: single call
  warning(strrep("abcdefg", 10L), call. = FALSE)
  stop("You failed ", length(x), " times.")
}

Try the potools package in your browser

Any scripts or data that you put into this service are public.

potools documentation built on Nov. 2, 2023, 5:20 p.m.