Skip to content
Snippets Groups Projects
Commit 75ee8385 authored by Gael  MILLOT's avatar Gael MILLOT
Browse files

test

parent 9aa21032
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,10 @@ Source the cute_little_functions.R into R/RStudio to have the functions availabl
WHAT'S NEW IN
v1.8:
1) Updated for saferDev
v1.7:
1) Debugged
......
################################################################
## ##
## R DEBUGGING TOOLS v1.7 ##
## R DEBUGGING TOOLS ##
## ##
## Gael A. Millot ##
## ##
## Compatible with R v4.0.2 ##
## Bioinformatics and Biostatistics Hub ##
## Institut Pasteur Paris ##
## ##
################################################################
......@@ -109,24 +109,21 @@ cat(paste0("\n================\n\n"))
str_arg_check_with_fun_check_dev <- '
# AIM:
# string that check:
# which arguments have been checked using fun_check()
# which arguments have been checked using saferDev::arg_check()
# STRING
function.name.local <- as.list(match.call(expand.dots=FALSE))[[1]]
default.arg.list <- formals(fun = sys.function(sys.parent(n = 2))) # list of all the arguments of the function with their default values (not the values of the user !). Use n = 2 when he string has to be evaluated by eval() inside a function. Use n=1 (default) if not evaluation. It seems that ls() as first line of the function provide the names of the arguments (empty, called, etc., or not)
if( ! any(ls() %in% "checked.arg.names")){
cat(paste0("\n\n================\n\nERROR: MISSING checked.arg.names OBJECT\nARGUMENTS MAY HAVE NOT BEEN CHECKED USING fun_check()\nSEE THE fun_export_data() FUNCTION FOR THIS KIND OF CHECKING\n\n================\n\n"))
}
if( ! find("fun_check") == ".GlobalEnv"){
cat(paste0("\n\n================\n\nERROR: MISSING fun_check() FUNCTION IN THE GLOBAL ENVIRONMENT\nARGUMENTS MAY HAVE NOT BEEN CHECKED USING fun_check()\nSEE THE fun_export_data() FUNCTION FOR THIS KIND OF CHECKING\n\n================\n\n"))
cat(paste0("\n\n================\n\nERROR: MISSING checked.arg.names OBJECT\nARGUMENTS MAY HAVE NOT BEEN CHECKED USING saferDev::arg_check()\n\n================\n\n"))
}
cat(paste0("\n\n================================\n\n", function.name.local," FUNCTION ARGUMENT CHECKING USING fun_check()\n\n================================\n"))
cat(paste0("\n\n================================\n\n", function.name.local," FUNCTION ARGUMENT CHECKING USING saferDev::arg_check()\n\n================================\n"))
if(any(duplicated(checked.arg.names))){ # for function debbuging
cat(paste0("\n================\nTHESE ARGUMENTS ARE DUPLICATED IN CHECK USING fun_check():\n", paste(checked.arg.names[duplicated(checked.arg.names)], collapse = "\n")))
cat(paste0("\n================\nTHESE ARGUMENTS ARE DUPLICATED IN CHECK USING saferDev::arg_check():\n", paste(checked.arg.names[duplicated(checked.arg.names)], collapse = "\n")))
}
if( any(! names(default.arg.list) %in% checked.arg.names)){ # check the correct number of args # for function debbuging # names(default.arg.list) can be replaced by formalArgs("name of the created function")
cat(paste0("\n================\nTHESE ARGUMENTS HAVE NOT BEEN CHECKED WITH fun_check():\n", paste(names(default.arg.list)[ ! names(default.arg.list) %in% checked.arg.names], collapse = "\n")))
cat(paste0("\n================\nTHESE ARGUMENTS HAVE NOT BEEN CHECKED WITH saferDev::arg_check():\n", paste(names(default.arg.list)[ ! names(default.arg.list) %in% checked.arg.names], collapse = "\n")))
}else{
cat(paste0("\n================\nALL THE ARGUMENTS HAVE BEEN CHECKED USING fun_check()"))
cat(paste0("\n================\nALL THE ARGUMENTS HAVE BEEN CHECKED USING saferDev::arg_check()"))
}
cat(paste0("\n================\n\n"))
# END STRING
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment