Skip to content

Commit

Permalink
Make tests conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
koheiw committed Dec 13, 2024
1 parent f4eeddd commit b2aa24e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/testthat/test-textmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,25 @@ test_that("textmodel_lss works with non-existent seeds", {
"No seed word is found in the dfm")
})

test_that("RSpectra and irlba work", {

expect_silent(textmodel_lss(dfmt_test, seedwords("pos-neg"), k = 10, engine = "RSpectra"))
expect_silent(textmodel_lss(dfmt_test, seedwords("pos-neg"), k = 10, engine = "irlba"))
test_that("rsvd and irlba work", {

if (requireNamespace("irlba")) {
expect_silent(textmodel_lss(dfmt_test, seedwords("pos-neg"), k = 10, engine = "irlba"))
} else {
expect_error(
expect_silent(textmodel_lss(dfmt_test, seedwords("pos-neg"), k = 10, engine = "irlba")),
"irlba package must be installed"
)
}

if (requireNamespace("rsvd")) {
expect_silent(textmodel_lss(dfmt_test, seedwords("pos-neg"), k = 10, engine = "rsvd"))
} else {
expect_error(
expect_silent(textmodel_lss(dfmt_test, seedwords("pos-neg"), k = 10, engine = "rsvd")),
"rsvd package must be installed"
)
}

})

Expand Down

0 comments on commit b2aa24e

Please sign in to comment.