hadley/test_that — Issue #25: simple bugs in gives_warning and shows_message
Author: berndbischl
Created: 2011-11-28 17:59:00+00:00
State: open

both functions dont work, when no warnings / messages are generated in the epxression.

minimal examples:

gives_warning("foo")(1)
Error: String must be an atomic vector
shows_message("foo")(1)
Error: String must be an atomic vector

cause:
warnings <- sapply(Filter(is.warning, res), "[[", "message")
Filter and sapply return an empty list, but matches later on requires a char vector.

possible fix:
vapply(Filter(is.warning, res), "[[", "message", fun.value = character(1))

also:
shows_message is copy-paste from gives_warning
at some places in the code and expecially the result-message: warning(s) --> message(s)

Bernd