Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition to testthat 3e #479

Merged
merged 15 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Suggests:
nycflights13,
rmarkdown,
stringr,
testthat,
testthat (>= 3.0.0),
vdiffr (>= 1.0.0),
parsnip
VignetteBuilder:
Expand All @@ -108,3 +108,4 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
Config/testthat/edition: 3
1 change: 1 addition & 0 deletions R/generate.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ process_variables <- function(variables, should_prompt) {
if (length(out) == 1) {
out <- as.character(out)
} else {
out <- as.list(out)
out <- purrr::map(out, as.character)
}

Expand Down
2 changes: 1 addition & 1 deletion R/shade_confidence_interval.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ shade_confidence_interval_term <- function(plot, endpoints,
inherit.aes = FALSE
),
dots,
list(size = 2)
list(linewidth = 2)
)
segment_layer <- do.call(ggplot2::geom_segment, segment_args)

Expand Down
4 changes: 2 additions & 2 deletions R/shade_p_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ shade_p_value_term <- function(plot, obs_stat, direction,

# Add vertical line at `obs_stat`
# Making extra step of precomputing arguments in order to have default value
# of `size = 2` overwritable in `...`
# of `linewidth = 2` overwritable in `...`
segment_args <- c_dedupl(
# Not overwritable arguments
list(
Expand All @@ -187,7 +187,7 @@ shade_p_value_term <- function(plot, obs_stat, direction,
# Extra arguments
dots,
# Default arguments that might be replaced in `...`
list(size = 2)
list(linewidth = 2)
)
segment_layer <- do.call(ggplot2::geom_segment, segment_args)

Expand Down
2 changes: 1 addition & 1 deletion R/visualize.R
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ simulation_layer <- function(data, dots = list(NULL)) {
res <- list(
do.call(
ggplot2::stat_bin,
c(list(mapping = aes(x = stat, y = ..density..),
c(list(mapping = aes(x = stat, y = ggplot2::after_stat(density)),
bins = bins,
color = "white",
breaks = bin_breaks),
Expand Down
10 changes: 8 additions & 2 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files

library(testthat)
library(infer)

test_check("infer")


4 changes: 2 additions & 2 deletions tests/testthat/helper-data.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set.seed(4242)

expect_doppelganger <- function(title, fig, path = NULL, ...) {
expect_doppelganger <- function(title, fig, ...) {
testthat::skip_if_not_installed("vdiffr")
vdiffr::expect_doppelganger(title, fig, path = path, ...)
vdiffr::expect_doppelganger(title, fig, ...)
}

eps <- if (capabilities("long.double")) {sqrt(.Machine$double.eps)} else {0.01}
Expand Down
13 changes: 6 additions & 7 deletions tests/testthat/test-aliases.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("aliases")

test_that("aliases work", {
expect_equal(
gss_calc %>%
Expand All @@ -8,17 +6,18 @@ test_that("aliases work", {
expected = 1,
tolerance = eps
)

expect_silent(gss_permute %>% get_ci())
})

test_that("old aliases produce warning", {
expect_warning(
gss_calc %>%
res <- gss_calc %>%
p_value(obs_stat = -0.2, direction = "right") %>%
dplyr::pull(),
expected = 1
dplyr::pull()
)


expect_equal(res, 1)

expect_warning(gss_permute %>% conf_int())
})
Loading