How do I pipe in a result to stopifnot()
and testit::assert()
?
library(magrittr)
0 %>%
testit::assert("gotta be small", . < 10)
# Error: . is not TRUE
0 %>%
testit::assert(. < 10)
# Error: . is not TRUE
0 %>%
stopifnot(. < 10)
# Error in function_list[[k]](value) : . is not TRUE
Works:
testit::assert(0 < 10)
stopifnot(0 < 10)
I'm assuming they're not acting like a conventional function like add()
because they're evaluating an expression. I'm guessing I should package the argument differently, so it's interpreted correctly by their match.call()
calls, but I'm not sure how to.