Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed May 10, 2024
1 parent f178a44 commit bde2ed5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions tests/testthat/answers/model-print-output.stan
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
data {
int<lower=0> N;
array[N] int<lower=0, upper=1> y;
}
parameters {
real<lower=0, upper=1> theta;
}
model {
theta ~ beta(1, 1); // uniform prior on interval 0,1
y ~ bernoulli(theta);
}
1: data {
2: int<lower=0> N;
3: array[N] int<lower=0, upper=1> y;
4: }
5: parameters {
6: real<lower=0, upper=1> theta;
7: }
8: model {
9: theta ~ beta(1, 1); // uniform prior on interval 0,1
10: y ~ bernoulli(theta);
11: }
4 changes: 2 additions & 2 deletions tests/testthat/test-model-code-print.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ test_that("code() doesn't change when file changes (unless model is recreated)",

mod <- cmdstan_model(stan_file_1, compile = FALSE)
expect_identical(mod$code(), code_1_answer)
expect_identical(utils::capture.output(mod$print()), code_1_answer)
code_1_print <- utils::capture.output(mod$print())

# overwrite with new code, but mod$code() shouldn't change
file.copy(stan_file_2, stan_file_1, overwrite = TRUE)
expect_identical(mod$code(), code_1_answer)
expect_identical(utils::capture.output(mod$print()), code_1_print)

# recreate CmdStanModel object, now mod$code() should change
mod <- cmdstan_model(stan_file_1, compile = FALSE)
expect_identical(mod$code(), code_2_answer)
expect_identical(utils::capture.output(mod$print()), code_2_answer)
})

test_that("code() warns and print() errors if only exe and no Stan file", {
Expand Down

0 comments on commit bde2ed5

Please sign in to comment.