R version 4.4.0 RC (2024-04-16 r86468 ucrt) -- "Puppy Cup" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## This file is part of SimInf, a framework for stochastic > ## disease spread simulations. > ## > ## Copyright (C) 2015 Pavol Bauer > ## Copyright (C) 2017 -- 2019 Robin Eriksson > ## Copyright (C) 2015 -- 2019 Stefan Engblom > ## Copyright (C) 2015 -- 2020 Stefan Widgren > ## > ## SimInf is free software: you can redistribute it and/or modify > ## it under the terms of the GNU General Public License as published by > ## the Free Software Foundation, either version 3 of the License, or > ## (at your option) any later version. > ## > ## SimInf is distributed in the hope that it will be useful, > ## but WITHOUT ANY WARRANTY; without even the implied warranty of > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > ## GNU General Public License for more details. > ## > ## You should have received a copy of the GNU General Public License > ## along with this program. If not, see . > > library(SimInf) > library(tools) > source("util/check.R") > > ## For debugging > sessionInfo() R version 4.4.0 RC (2024-04-16 r86468 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] SimInf_9.7.0 loaded via a namespace (and not attached): [1] MASS_7.3-60.2 compiler_4.4.0 Matrix_1.7-0 grid_4.4.0 digest_0.6.35 [6] lattice_0.22-6 > > ## Check missing and invalid model argument > res <- assertError(package_skeleton()) > check_error(res, "Missing 'model' argument.") > > res <- assertError(package_skeleton(5)) > check_error(res, "'model' argument is not a 'SimInf_model'.") > > ## Check missing 'ldata', 'gdata' and 'v0' parameters > m <- mparse(transitions = "@ -> 1 -> S", + compartments = "S", + u0 = data.frame(S = 0), + tspan = 1:10) > stopifnot(is.null(SimInf:::create_model_R_object_ldata(m))) > stopifnot(is.null(SimInf:::create_model_R_object_gdata(m))) > stopifnot(is.null(SimInf:::create_model_R_object_v0(m))) > > ## Check package_skeleton > m <- mparse(transitions = c("@ -> a -> S", + "S -> b*S*I/(S+I+R) -> I", + "I -> g*I -> R"), + compartments = c("S", "I", "R"), + ldata = data.frame(a = 1), + gdata = c(b = 0.16), + u0 = data.frame(S = 99, I = 1, R = 0), + v0 = data.frame(g = 0.077), + tspan = 1:10) > > ## Check that a malformed package name is detected > path <- tempdir() > res <- assertError(package_skeleton(m, name = "S_I_R", path = path)) > check_error(res, "Malformed package name.") > > ## Create a package > package_skeleton(m, name = "SIR", path = path) Creating directories ... Creating DESCRIPTION ... Creating NAMESPACE ... Creating C file ... Creating R file ... Creating help files ... > stopifnot(file.exists(file.path(path, "SIR", "DESCRIPTION"))) > stopifnot(file.exists(file.path(path, "SIR", "NAMESPACE"))) > stopifnot(file.exists(file.path(path, "SIR", "man", "SIR-class.Rd"))) > stopifnot(file.exists(file.path(path, "SIR", "man", "SIR.Rd"))) > stopifnot(file.exists(file.path(path, "SIR", "man", "run-methods.Rd"))) > stopifnot(file.exists(file.path(path, "SIR", "R", "model.R"))) > stopifnot(file.exists(file.path(path, "SIR", "src", "model.c"))) > > ## Check that it fails if path exists > res <- assertError(package_skeleton(m, name = "SIR", path = path)) > check_error(res, "already exists.", FALSE) > > ## Cleanup > unlink(path, recursive = TRUE) > > proc.time() user system elapsed 0.89 0.15 1.03