Skip to content

Commit

Permalink
tests around multiple blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebaron committed Sep 23, 2024
1 parent c933a69 commit 2828112
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/testthat/test-modspec.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,62 @@ for(what in c("THETA", "PARAM", "CMT",
})
}

test_that("multiple blocks allowed or not allowed", {
code <- "$SET end = 5\n$SET delta = 1\n$PARAM x = 3"
expect_error(
mcode("test-multiple-set", code, compile = FALSE),
"Multiple blocks found"
)

code <- "$GLOBAL end = 5\n$GLOBAL delta = 1\n$PARAM x = 3"
expect_error(
mcode("test-multiple-global", code, compile = FALSE),
"Multiple blocks found"
)

code <- "$PKMODEL end = 5\n$PKMODEL delta = 1\n$PARAM x = 3"
expect_error(
mcode("test-multiple-pkmodel", code, compile = FALSE),
"Multiple blocks found"
)

code <- "$MAIN end = 5\n$MAIN delta = 1\n$PARAM x = 3"
expect_error(
mcode("test-multiple-main", code, compile = FALSE),
"Multiple blocks found"
)

code <- "$PREAMBLE end = 5\n$PREAMBLE delta = 1\n$PARAM x = 3"
expect_error(
mcode("test-multiple-preamble", code, compile = FALSE),
"Multiple blocks found"
)

code <- "$PRED end = 5\n$PRED delta = 1\n$PARAM x = 3"
expect_error(
mcode("test-multiple-pred", code, compile = FALSE),
"Multiple blocks found"
)

code <- "$PLUGIN Rcpp\n$PLUGIN BH evtools\n$PARAM x = 3"
expect_silent(
mod <- mcode("test-multiple-plugin", code, compile = FALSE)
)
expect_is(mod, "mrgmod")

code <- "$ODE a = 3\n$ODE b = 55\n$PARAM x = 3"
expect_silent(
mod <- mcode("test-multiple-ode", code, compile = FALSE)
)
expect_is(mod, "mrgmod")

code <- "$TABLE x\n$TABLE y = 55\n$PARAM x = 3\n y = 10"
expect_silent(
mod <- mcode("test-multiple-table", code, compile = FALSE)
)
expect_is(mod, "mrgmod")
})

test_that("Commented model", {
code <- '
// A comment
Expand Down

0 comments on commit 2828112

Please sign in to comment.