55# ' the operation in this protocol. It will be parsed with
66# ' \code{\link[glue]{glue}} and used in the bitfield legend, so can include
77# ' the test arguments as enbraced expressions.
8- # ' @param test [`function(...)`][function ]\cr the function used to compute the bit
9- # ' flag.
8+ # ' @param test [`function(...)`][character ]\cr the function used to compute the bit
9+ # ' flag (expressed as character string) .
1010# ' @param example [`list(.)`][list]\cr named list that contains all arguments in
1111# ' \code{test} as name with values of the correct type.
1212# ' @param type [`character(1)`][character]\cr the encoding type according to
3232# ' @examples
3333# ' newFlag <- bf_protocol(name = "na",
3434# ' description = "{x} contains NA-values{result}.",
35- # ' test = function(x) is.na(x = x),
35+ # ' test = " function(x) is.na(x = x)" ,
3636# ' example = list(x = bf_tbl$commodity),
3737# ' type = "bool")
38- # ' @importFrom checkmate assertCharacter assertFunction assertChoice
39- # ' assertIntegerish
38+ # ' @importFrom checkmate assertCharacter assertFunction assertList assertChoice
39+ # ' assertIntegerish assertClass
4040# ' @importFrom rlang exec
4141# ' @importFrom dplyr case_match case_when
4242# ' @importFrom utils bibentry
@@ -48,7 +48,7 @@ bf_protocol <- function(name, description, test, example, type, bits = NULL,
4848
4949 assertCharacter(x = name , len = 1 , any.missing = FALSE )
5050 assertCharacter(x = description , len = 1 , any.missing = FALSE )
51- assertFunction (x = test )
51+ assertCharacter (x = test , len = 1 , any.missing = FALSE )
5252 assertList(x = example )
5353 assertChoice(x = type , choices = c(" bool" , " enum" , " int" , " float" ))
5454 assertIntegerish(x = bits , len = 1 , null.ok = TRUE )
@@ -58,6 +58,8 @@ bf_protocol <- function(name, description, test, example, type, bits = NULL,
5858 version <- " 1.0.0"
5959 }
6060
61+ test <- eval(parse(text = test ))
62+
6163 # determine number of bits, if not given ----
6264 if (is.null(bits )) {
6365
@@ -94,7 +96,7 @@ bf_protocol <- function(name, description, test, example, type, bits = NULL,
9496 encoding_type = type ,
9597 bits = bits , # when the test is general and could result in any number of bits, use NA here
9698 requires = requiredPkgs ,
97- test = paste0(deparse( test ), collapse = " " ) ,
99+ test = test ,
98100 data = example ,
99101 reference = reference )
100102
0 commit comments