R Under development (unstable) (2024-10-16 r87241 ucrt) -- "Unsuffered Consequences" 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. > if(!require("GNE"))stop("this test requires package GNE.") Loading required package: GNE Loading required package: alabama Loading required package: numDeriv Loading required package: nleqslv Loading required package: BB Loading required package: SQUAREM > > f <- function(x) x > f2 <- function(x, y) x+y > f3 <- function(x, y, z) f2(x,y)+z > f4 <- function(x, y, z, a) f3(x,y,z)+a > f5 <- function(x, y, z, a, b) f4(x,y,z,a)+b > > g <- function(x, y, z) GNE:::evalwitharglist(f3, x, list(y, z)) > g2 <- function(x, y, z) GNE:::evalwitharglist(f3, x, c(list(y), z)) > > h <- function(x, z, y) x+z+y$a+y$b > > > args(GNE:::testfunc) function (f, x = NULL, arg = NULL, echo = TRUE, errmess = "", tobelisted = TRUE) NULL > GNE:::testfunc(f, echo=2, errmess="1") $x [1] TRUE function (x) x [[1]] [1] 1 [1] 1 > GNE:::testfunc(f, 1, echo=2, errmess="2") $x [1] TRUE function (x) x [[1]] [1] 1 [1] 1 > try( GNE:::testfunc(f, 1, 1:10, echo=2, errmess="3") ) $x Error in GNE:::testfunc(f, 1, 1:10, echo = 2, errmess = "3") : wrong number of arguments. > GNE:::testfunc(f2, 1, 1:10, echo=2, errmess="4") $x $y [1] TRUE function (x, y) x + y [[1]] [1] 1 [[2]] [1] 1 2 3 4 5 6 7 8 9 10 [1] 2 3 4 5 6 7 8 9 10 11 > GNE:::testfunc(f3, 1, 1:10, echo=2, errmess="5") $x $y $z [1] TRUE function (x, y, z) f2(x, y) + z [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 2 3 4 5 6 7 8 9 10 [1] 3 4 5 6 7 8 9 10 11 12 > GNE:::testfunc(f3, 1, NULL, echo=2, errmess="6") $x $y $z [1] TRUE function (x, y, z) f2(x, y) + z [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [1] 3 > GNE:::testfunc(f4, 1, echo=2, errmess="7") $x $y $z $a [1] TRUE function (x, y, z, a) f3(x, y, z) + a [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [[4]] [1] 1 [1] 4 > GNE:::testfunc(f5, 1, echo=2, errmess="8") $x $y $z $a $b [1] TRUE function (x, y, z, a, b) f4(x, y, z, a) + b [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 [[4]] [1] 1 [[5]] [1] 1 [1] 5 > > GNE:::testfunc(g, 1, 1:10, echo=2, errmess="9") $x $y $z [1] TRUE function (x, y, z) GNE:::evalwitharglist(f3, x, list(y, z)) [[1]] [1] 1 [[2]] [1] 1 [[3]] [1] 1 2 3 4 5 6 7 8 9 10 [1] 3 4 5 6 7 8 9 10 11 12 > GNE:::testfunc(g2, 1, list(1:10), echo=2, errmess="10") $x $y $z [1] TRUE function (x, y, z) GNE:::evalwitharglist(f3, x, c(list(y), z)) [[1]] [1] 1 [[2]] [1] 1 [[3]] [[3]][[1]] [1] 1 2 3 4 5 6 7 8 9 10 [1] 3 4 5 6 7 8 9 10 11 12 > > GNE:::testfunc(h, 1, list(a=1, b=pi), echo=2, errmess="11") $x $z $y [1] TRUE function (x, z, y) x + z + y$a + y$b [[1]] [1] 1 [[2]] [1] 1 [[3]] [[3]]$a [1] 1 [[3]]$b [1] 3.141593 [1] 6.141593 > GNE:::testfunc(h, arg=list(a=1, b=pi), echo=2, errmess="12") $x $z $y [1] TRUE function (x, z, y) x + z + y$a + y$b [[1]] [1] 1 [[2]] [1] 1 [[3]] [[3]]$a [1] 1 [[3]]$b [1] 3.141593 [1] 6.141593 > > > proc.time() user system elapsed 0.21 0.15 0.37