# tests/testthat/test_accessors.R In CharlotteJana/pdmpsim: Simulate Piecewise Deterministic Markov Processes

```context("accessors")

data("simplePdmp")
obj <- simplePdmp

test_that("changing of important slots resets slot out", {

# slot init
obj <- sim(obj)
init(obj) <- c(f = 5, d = 1)
expect_null(out(obj))

# slot parms
obj <- sim(obj)
parms(obj) <- c(a = 3)
expect_null(out(obj))

# slot times
obj <- sim(obj)
times(obj) <- c(from = 0, to = 10, by = 0.1)
expect_null(out(obj))

# slot dynfunc
obj <- sim(obj)
dynfunc(obj) <- function(t, x, parms) c(-x["d"]*t, 0)
expect_null(out(obj))

# slot ratefunc
obj <- sim(obj)
ratefunc(obj) <- function(t, x, parms) 2
expect_null(out(obj))

# slot jumpfuc
obj <- sim(obj)
jumpfunc(obj) <- function(t, x, parms, jtype) c(0, (-1)*x["d"])
expect_null(out(obj))

# slot solver
obj <- sim(obj)
solver(obj) <- "lsodar"
expect_null(out(obj))

# # slot initfunc
# obj <- sim(obj, initialize = FALSE)
# initfunc(obj) <- NULL
# expect_null(out(obj))

# slot discStates
obj <- sim(obj, initialize = FALSE)
discStates(obj) <- list(d = c(1, 0, -1))
expect_null(out(obj))

})

test_that("changing of slots descr does not affect slot out", {

# slot descr
obj <- sim(obj)
descr(obj) <- "another description"
expect_false(is.null(out(obj)))

})
```
CharlotteJana/pdmpsim documentation built on July 2, 2019, 5:37 a.m.