aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Kellner <ken@kenkellner.com>2023-12-07 11:54:36 -0500
committerKen Kellner <ken@kenkellner.com>2023-12-07 11:54:36 -0500
commit995ed8a911ddba0cec05c18489b1da6ec386b06a (patch)
tree374c02d5b725259c9d276d4e729233416f9efad5
parent3628ba7cadad4c09a8b306e37267bc6671f7636d (diff)
Add factory/module tests
-rw-r--r--inst/tinytest/test_run_rjags.R22
1 files changed, 22 insertions, 0 deletions
diff --git a/inst/tinytest/test_run_rjags.R b/inst/tinytest/test_run_rjags.R
new file mode 100644
index 0000000..65d05da
--- /dev/null
+++ b/inst/tinytest/test_run_rjags.R
@@ -0,0 +1,22 @@
+# load_modules loads and unloads correctly
+jagsUI:::set.modules(NULL, FALSE)
+expect_equal(rjags::list.modules(),c('basemod','bugs'))
+jagsUI:::set.modules('glm', FALSE)
+expect_equal(rjags::list.modules(),c('basemod','bugs','glm'))
+jagsUI:::set.modules(NULL, FALSE)
+expect_equal(rjags::list.modules(),c('basemod','bugs'))
+jagsUI:::set.modules(NULL, DIC=TRUE)
+expect_equal(rjags::list.modules(),c('basemod','bugs','dic'))
+
+
+# load_factories works correctly
+jagsUI:::set.factories(NULL)
+expect_equal(rjags::list.factories('sampler')[1:2,2], c(TRUE, TRUE))
+jagsUI:::set.factories(c('bugs::BinomSlice sampler FALSE',
+ 'bugs::RW1 sampler FALSE'))
+expect_equal(rjags::list.factories('sampler')[1:2,2], c(FALSE, FALSE))
+jagsUI:::set.factories(c('bugs::BinomSlice sampler TRUE',
+ 'bugs::RW1 sampler TRUE'))
+expect_equal(rjags::list.factories('sampler')[1:2,2], c(TRUE, TRUE))
+expect_error(jagsUI:::set.factories(c('bad bad')))
+expect_error(jagsUI:::set.factories(c('bugs::fake sampler FALSE')))