# handles parsing failures gracefully Code test_evaluate("1 + ", highlight = TRUE) Output 1 + #> Error: <text>:2:0: unexpected end of input #> 1: 1 + #> ^ # highlights when requested Code test_evaluate("1 + \n 2 + 3", highlight = TRUE) Output 1 + 2 + 3 #> [1] 6 # handles basic cases Code test_evaluate("# comment") Output # comment Code test_evaluate("message('x')") Output message('x') #> x Code test_evaluate("warning('x')") Output warning('x') #> Warning: x Code test_evaluate("stop('x', call. = FALSE)") Output stop('x', call. = FALSE) #> Error: x
        Code
          test_evaluate("f <- function() stop('x'); f()")
        Output
f <- function() stop('x'); f() #> Error in f(): x # each line of input gets span Code test_evaluate("1 +\n 2 +\n 3 +\n 4 +\n 5") Output 1 + 2 + 3 + 4 + 5 #> [1] 15 # output always gets trailing nl Code test_evaluate("cat(\"a\")\ncat(\"a\\n\")") Output cat("a") #> a cat("a\n") #> a
    # combines plots as needed

        Code
          f1 <- (function() plot(1))
          f2 <- (function() lines(0:2, 0:2))
          test_evaluate("f1()\nf2()\n")
        Output
f1() f2()
    ---

        Code
          f3 <- (function() {
            plot(1)
            plot(2)
          })
          test_evaluate("f3()")
        Output
f3() # handles other plots f3() f4()
    # ansi escapes are translated to html

        Code
          blue <- (function(x) paste0("\033[34m", x, "\033[39m"))
          f <- (function(x) {
            cat("Output: ", blue("blue"), "\n", sep = "")
            message(paste0("Message: ", blue("blue")))
            warning(blue("blue"), call. = FALSE)
            stop(blue("blue"), call. = FALSE)
          })
          test_evaluate("f()\n")
        Output
f() #> Output: blue #> Message: blue #> Warning: blue #> Error: blue