diff --git a/tests/testthat/test-dev.R b/tests/testthat/test-dev.R index 8ba1cae1..d358e7c1 100644 --- a/tests/testthat/test-dev.R +++ b/tests/testthat/test-dev.R @@ -767,6 +767,7 @@ test_that("student deviance", { }) test_that("skewnorm missing values", { + skip_if_not_installed("sn") expect_identical(dev_skewnorm(logical(0), integer(0), numeric(0), numeric(0)), numeric(0)) expect_identical(dev_skewnorm(NA, 1, 1, 1), NA_real_) expect_identical(dev_skewnorm(1, NA, 1, 1), NA_real_) @@ -775,6 +776,7 @@ test_that("skewnorm missing values", { }) test_that("skewnorm known values", { + skip_if_not_installed("sn") expect_identical(dev_skewnorm(1, 1), 0) expect_identical(dev_skewnorm(1, 1, 1), 0) expect_equal(dev_skewnorm(1, 1, 1, 1), 0.398456311678723) @@ -800,6 +802,7 @@ test_that("skewnorm known values", { }) test_that("skewnorm vectorized", { + skip_if_not_installed("sn") expect_equal(dev_skewnorm(0:3, 2, 0.1, 0), c(400, 100, 0, 100)) expect_equal(dev_skewnorm(c(0, 1, 3, 0), 3, 0.5, 0.5), c(47.9668417319782, 22.3177579563216, 0.137683650077409, 47.9668417319782)) expect_equal(dev_skewnorm(0:3, 0:3, rep(1, 4), 0), rep(0, 4)) @@ -807,6 +810,7 @@ test_that("skewnorm vectorized", { }) test_that("skewnorm vectorized missing values", { + skip_if_not_installed("sn") expect_equal(dev_skewnorm(c(NA, 1), 0:1, 0:1, 0:1), c(NA, 0.398456311678723)) expect_equal(dev_skewnorm(c(0, NA), 0:1, 1:2, 0:1), c(0, NA)) expect_equal(dev_skewnorm(c(0:1), c(NA, 1), 1:2, 0:1), c(NA, 0.398456311678724)) @@ -818,11 +822,13 @@ test_that("skewnorm vectorized missing values", { }) test_that("skewnorm res", { + skip_if_not_installed("sn") expect_equal(dev_skewnorm(10, 0.5, 0.5), dev_skewnorm(10, 0.5, 0.5, res = TRUE)^2) expect_equal(dev_skewnorm(0:1, c(0.3, 0.6), 0.5), dev_skewnorm(0:1, c(0.3, 0.6), 0.5, res = TRUE)^2) }) test_that("skewnorm log_lik", { + skip_if_not_installed("sn") expect_equal( dev_skewnorm(0:1, 1:2, 2:3, shape = 0), 2 * (log_lik_skewnorm(0:1, 0:1, 2:3, shape = 0) - log_lik_skewnorm(0:1, 1:2, 2:3, shape = 0)) @@ -830,6 +836,7 @@ test_that("skewnorm log_lik", { }) test_that("skewnorm ran", { + skip_if_not_installed("sn") set.seed(101) samples <- ran_skewnorm(100000, 3, 0.5, 0.5) expect_equal(mean(samples), 3.17851201086154) @@ -840,6 +847,7 @@ test_that("skewnorm ran", { }) test_that("skewnorm deviance", { + skip_if_not_installed("sn") samples <- ran_skewnorm(1000, 3, 0.5, 0) mod <- glm(samples ~ 1, family = gaussian) deviance <- sum(dev_skewnorm(samples, coef(mod)[1])) diff --git a/tests/testthat/test-log-lik.R b/tests/testthat/test-log-lik.R index ed4303b5..5419a119 100644 --- a/tests/testthat/test-log-lik.R +++ b/tests/testthat/test-log-lik.R @@ -193,6 +193,7 @@ test_that("beta_binom log_lik", { }) test_that("skewnorm missing values", { + skip_if_not_installed("sn") expect_identical(log_lik_skewnorm(numeric(0), numeric(0), numeric(0), numeric(0)), numeric(0)) expect_identical(log_lik_skewnorm(1, numeric(0)), numeric(0)) expect_identical(log_lik_skewnorm(1, 1, sd = numeric(0)), numeric(0)) @@ -204,6 +205,7 @@ test_that("skewnorm missing values", { }) test_that("skewnorm known values", { + skip_if_not_installed("sn") expect_equal(log_lik_skewnorm(0.5, 3), -4.04393853320467) expect_equal(log_lik_skewnorm(0.5, 3, 0), -Inf) expect_equal(log_lik_skewnorm(0.5, 3, 1, -4), -3.35079135264473) @@ -220,6 +222,7 @@ test_that("skewnorm known values", { }) test_that("skewnorm vectorized", { + skip_if_not_installed("sn") expect_equal( log_lik_skewnorm(0:3, 2, 0.5, 0), c(-8.22579135264473, -2.22579135264473, -0.225791352644727, -2.22579135264473) diff --git a/tests/testthat/test-ran.R b/tests/testthat/test-ran.R index a7046a1b..0c375d75 100644 --- a/tests/testthat/test-ran.R +++ b/tests/testthat/test-ran.R @@ -242,6 +242,7 @@ test_that("ran_beta_binom", { }) test_that("ran_skewnorm", { + skip_if_not_installed("sn") expect_error(ran_skewnorm(NA_integer_)) expect_error(ran_skewnorm(NULL)) expect_error(ran_skewnorm(integer(0))) diff --git a/tests/testthat/test-res.R b/tests/testthat/test-res.R index 44552452..1bb8da5f 100644 --- a/tests/testthat/test-res.R +++ b/tests/testthat/test-res.R @@ -575,6 +575,7 @@ test_that("res_beta_binom", { }) test_that("res_skewnorm", { + skip_if_not_installed("sn") expect_identical(res_skewnorm(integer(0), integer(0), integer(0)), numeric(0)) expect_identical(res_skewnorm(NA, 1, 1, 1), NA_real_) expect_identical(res_skewnorm(1, NA, 1, 1), NA_real_)