Skip to content

Commit

Permalink
added stanmodule merge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gowerc committed Feb 1, 2024
1 parent d3cb92b commit ae90091
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/testthat/test-StanModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,44 @@ x ~ normal(mu, sigma);
expect_equal(x@parameters, c(" real mu; ", " real sigma;"))
expect_equal(x@model, "x ~ normal(mu, sigma);")
})


testthat("StanModule.merge works as expected",{

Check warning on line 159 in tests/testthat/test-StanModule.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=tests/testthat/test-StanModule.R,line=159,col=47,[commas_linter] Commas should always have a space after.
x <- merge(
StanModule(),
StanModule()
)
expect_equal(x@data, "")
expect_equal(x@transformed_data, "")
expect_equal(x@parameters, "")
expect_equal(x@transformed_parameters, "")
expect_equal(x@model, "")
expect_equal(x@generated_quantities, "")
expect_equal(x@functions, "")


x <- merge(
StanModule("model {\n int x;\n}"),
StanModule("data {\n int x;\n}")
)
expect_equal(x@data, " int x;")
expect_equal(x@transformed_data, "")
expect_equal(x@parameters, "")
expect_equal(x@transformed_parameters, "")
expect_equal(x@model, " int x;")
expect_equal(x@generated_quantities, "")
expect_equal(x@functions, "")


x <- merge(
StanModule("parameters {\n int x;\n}\n generated quantities {\n int w;\n}"),
StanModule("generated quantities {\n int z;\n}\n parameters {\n int y;\n}")
)
expect_equal(x@data, "")
expect_equal(x@transformed_data, "")
expect_equal(x@parameters, c(" int x;", " int y;"))
expect_equal(x@transformed_parameters, "")
expect_equal(x@model, "")
expect_equal(x@generated_quantities, c(" int w;", " int z;"))
expect_equal(x@functions, "")
})

0 comments on commit ae90091

Please sign in to comment.