tests/testthat/test-ir.R

context("ir")

test_that("deserialise", {
  code <- c("initial(x) <- 1", "deriv(x) <- 1")
  ir <- odin_parse_(code, type = "text")
  expect_error(odin_ir_deserialise(as.character(ir)),
               "Expected a json string")

  res <- odin_ir_deserialise(ir)
  expect_identical(res$ir, ir)
})


test_that("Stage information included in IR", {
  ir <- odin_parse_("examples/array_odin.R",
                    options = odin_options(rewrite_constants = FALSE))
  dat <- odin_ir_deserialise(ir)
  expect_equal(dat$data$elements$N_age$stage, "constant")
  expect_equal(dat$data$elements$I_tot$stage, "time")
})

Try the odin package in your browser

Any scripts or data that you put into this service are public.

odin documentation built on April 28, 2022, 9:05 a.m.