Skip to content

Commit

Permalink
add some missing test skips for posterior and vdiffr
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed May 16, 2024
1 parent 6c7b578 commit 5bc3d60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/testthat/test.curve_interval.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ test_that("curve_interval works with lineribbon", {
# basic cases: 95%, 0%, 100%, > 100% ---------------------------------------------

test_that("basic cases on single interval work", {
skip_if_not_installed("posterior")

df = data.frame(value = ppoints(1000))

ref = data.frame(
Expand Down Expand Up @@ -116,6 +118,8 @@ test_that("basic cases on single interval work", {
})

test_that("basic cases on single curve work", {
skip_if_not_installed("posterior")

df = data.frame(x = 1:3, y = rep(ppoints(1000), each = 3) + 1:3)

ref = data.frame(
Expand All @@ -134,7 +138,6 @@ test_that("basic cases on single curve work", {
expect_equal(curve_interval(df, .along = x, .width = c(.95, 0, 1)), ref)
expect_equal(curve_interval(group_by(df, x), .width = c(.95, 0, 1)), ref)

skip_if_not_installed("posterior")
# data frame of rvars
y_rvar = rep(posterior::rvar(ppoints(1000)), 3) + 1:3
df = data.frame(x = 1:3, y = y_rvar)
Expand All @@ -149,6 +152,8 @@ test_that("basic cases on single curve work", {
})

test_that("basic cases on multiple variables", {
skip_if_not_installed("posterior")

df = data.frame(
x = 1:3,
y1 = rep(ppoints(1000), each = 3) + 1:3,
Expand Down Expand Up @@ -181,17 +186,23 @@ test_that("basic cases on multiple variables", {
# errors ------------------------------------------------------------------

test_that("error is thrown when no columns found to summarize", {
skip_if_not_installed("posterior")

df = data.frame(value = ppoints(10))
expect_error(curve_interval(df, .exclude = "value"), "No columns found to calculate point and interval summaries for")
expect_error(curve_interval(df, .along = x))
})

test_that("error is thrown when along does not match a column", {
skip_if_not_installed("posterior")

df = data.frame(value = ppoints(10))
expect_error(curve_interval(df, .along = x), class = "ggdist_invalid_column_selection")
})

test_that("error is thrown with groups of different sizes", {
skip_if_not_installed("posterior")

df = data.frame(
value = ppoints(9),
group = c("a", "a", "b"),
Expand All @@ -201,6 +212,8 @@ test_that("error is thrown with groups of different sizes", {
})

test_that("curve_interval(<rvar>) and curve_interval(<matrix>) do not support along", {
skip_if_not_installed("posterior")

expect_error(
curve_interval(matrix(1:4, nrow = 2), .along = "x"),
'does\\s+not\\s+support\\s+the\\s+[^a-zA-Z]*\\.along[^a-zA-Z]*\\s+argument'
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test.subguide.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ test_that("subguide_axis(numeric()) works but is not zeroGrob()", {
# subguide_integer --------------------------------------------------------

test_that("integer subguide corner cases work", {
skip_if_no_vdiffr()

df = data.frame(x = c(1, 2), t = c(0, 0.5))

sg = subguide_integer(theme = theme_test())
Expand Down

0 comments on commit 5bc3d60

Please sign in to comment.