Skip to content

Commit d34458e

Browse files
committed
add test for new behavior
1 parent c341a4b commit d34458e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/testthat/test-model-sample.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ test_that("seed works for multi chain sampling", {
307307
expect_false(all(chain_tdata_1 == chain_tdata_2))
308308
})
309309

310-
test_that("fixed_param is set when the model has no parameters", {
310+
test_that("Correct behavior if fixed_param not set when the model has no parameters", {
311311
code <- "
312312
model {}
313313
generated quantities {
@@ -316,10 +316,21 @@ test_that("fixed_param is set when the model has no parameters", {
316316
"
317317
stan_file <- write_stan_file(code)
318318
m <- cmdstan_model(stan_file)
319+
fake_cmdstan_version("2.35.0")
319320
expect_error(
320321
m$sample(),
321322
"Model contains no parameters. Please use 'fixed_param = TRUE'."
322323
)
324+
325+
reset_cmdstan_version()
326+
if (cmdstan_version() >= "2.36.0") {
327+
# as of 2.36.0 we don't need fixed_param if no parameters
328+
expect_no_error(
329+
utils::capture.output(
330+
fit <- m$sample(iter_warmup = 10, iter_sampling = 10, diagnostics = NULL)
331+
)
332+
)
333+
}
323334
})
324335

325336
test_that("sig_figs warning if version less than 2.25", {

0 commit comments

Comments
 (0)