diff --git a/tests/testthat/test-ui-piping.R b/tests/testthat/test-ui-piping.R index 7fc54c6e6..8337f4b16 100644 --- a/tests/testthat/test-ui-piping.R +++ b/tests/testthat/test-ui-piping.R @@ -1984,3 +1984,61 @@ test_that("off-diagonal piping issue #518", { expect_error(modNew$omega, NA) }) + +test_that("piping append", { + + mod <- function() { + ini({ + tka <- 0.45 + label("Ka") + tcl <- 1 + label("Cl") + tv <- 3.45 + label("V") + add.sd <- c(0, 0.7) + eta.cl ~ 0.3 + eta.v ~ 0.1 + }) + model({ + ka <- exp(tka) + cl <- exp(tcl + eta.cl) + v <- exp(tv + eta.v) + d/dt(depot) = -ka * depot + d/dt(center) = ka * depot - cl/v * center + cp = center/v + cp ~ add(add.sd) + }) + } + + mod5 <- mod |> + model({ + PD <- 1-emax*cp/(ec50+cp) + ## + effect(0) <- e0 + kin <- e0*kout + d/dt(effect) <- kin*PD -kout*effect + }, append=d/dt(center)) + + expect_equal(mod5$theta, c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7)) + + mod6 <- mod5 |> + model({ + emax <- exp(temax) + e0 <- exp(te0 + eta.e0) + ec50 <- exp(tec50) + kin <- exp(tkin) + kout <- exp(tkout) + }, append=NA) + + expect_equal(mod6$theta, + c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7, temax = 1, te0 = 1, tec50 = 1, tkin = 1, tkout = 1)) + + expect_equal( + mod6$omega, + lotri({ + eta.cl ~ 0.3 + eta.v ~ 0.1 + eta.e0 ~ 1 + })) + +})