Skip to content

Instantly share code, notes, and snippets.

@MichaelChirico
Created May 10, 2026 20:53
Show Gist options
  • Select an option

  • Save MichaelChirico/e74dadfeeedbec9ca9dd28f3b0ec1f85 to your computer and use it in GitHub Desktop.

Select an option

Save MichaelChirico/e74dadfeeedbec9ca9dd28f3b0ec1f85 to your computer and use it in GitHub Desktop.
Validate check of digits.rank
# This script creates two dummy packages to prove that the binary search evaluation
# correctly identifies packages that fail when digits.rank is set too low.
# -- Create dummy3 --
# This package expects wilcox.test(c(1.11, 2.22), c(1.14, 2.25))$statistic to be exactly 1.
# This assertion fails at digits.rank=1 and 2, but passes at digits.rank >= 3.
dir.create("dummy3/R", recursive = TRUE, showWarnings = FALSE)
dir.create("dummy3/tests/testthat", recursive = TRUE, showWarnings = FALSE)
writeLines(c(
"Package: dummy3",
"Version: 1.0",
"Title: Dummy3",
"Description: Dummy3",
"Author: Me",
"Maintainer: Me <me@me.com>",
"License: GPL-3",
"Suggests: testthat"
), "dummy3/DESCRIPTION")
writeLines("exportPattern(\"^[[:alpha:]]+\")", "dummy3/NAMESPACE")
writeLines("f <- function() { 1 }", "dummy3/R/dummy3.R")
writeLines(c(
"library(testthat)",
"library(dummy3)",
"test_check(\"dummy3\")"
), "dummy3/tests/testthat.R")
writeLines(c(
"test_that(\"dummy3 works\", {",
" x <- c(1.11, 2.22)",
" y <- c(1.14, 2.25)",
" res <- wilcox.test(x, y)",
" expect_equal(res$statistic[[\"W\"]], 1)",
"})"
), "dummy3/tests/testthat/test-wilcox.R")
# -- Create dummy6 --
# This package expects wilcox.test(c(1.11111, 2.22222), c(1.11114, 2.22225))$statistic to be exactly 1.
# This assertion fails at digits.rank=1 through 5, but passes at digits.rank >= 6.
dir.create("dummy6/R", recursive = TRUE, showWarnings = FALSE)
dir.create("dummy6/tests/testthat", recursive = TRUE, showWarnings = FALSE)
writeLines(c(
"Package: dummy6",
"Version: 1.0",
"Title: Dummy6",
"Description: Dummy6",
"Author: Me",
"Maintainer: Me <me@me.com>",
"License: GPL-3",
"Suggests: testthat"
), "dummy6/DESCRIPTION")
writeLines("exportPattern(\"^[[:alpha:]]+\")", "dummy6/NAMESPACE")
writeLines("f <- function() { 1 }", "dummy6/R/dummy6.R")
writeLines(c(
"library(testthat)",
"library(dummy6)",
"test_check(\"dummy6\")"
), "dummy6/tests/testthat.R")
writeLines(c(
"test_that(\"dummy6 works\", {",
" x <- c(1.11111, 2.22222)",
" y <- c(1.11114, 2.22225)",
" res <- wilcox.test(x, y)",
" expect_equal(res$statistic[[\"W\"]], 1)",
"})"
), "dummy6/tests/testthat/test-wilcox.R")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment