Für Vorlesungen, bitte die Webseite verwenden. https://flavigny.de/lecture
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
664B

  1. clear_warnings <- function() last.warning <<- list()
  2. careless <- function(f) {
  3. function(...) {
  4. suppressWarnings(f(...))
  5. }
  6. }
  7. fail_with <- function(expr, value) tryCatch(expr, error = function(cond) value)
  8. does_error <- function(expr) {
  9. didFail <- F
  10. tryCatch(expr, error = function(cond) didFail <<- T)
  11. didFail
  12. }
  13. count_warnings <- function(expr) {
  14. N <- 0
  15. withCallingHandlers(expr, warning = function(cond) N <<- N + 1)
  16. N
  17. }
  18. record <- function(expr) {
  19. msgs <- c()
  20. rec <- function(cond) { msgs <<- c(msgs, cond$message); rlang::cnd_muffle(cond)}
  21. withCallingHandlers(expr, warning = rec, message = rec)
  22. msgs
  23. }