Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Jul 27, 2023
1 parent af7ee66 commit 5766e88
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# teal.code 0.3.0.9008

* `eval_code` doesn't render plots in a graphical device.
* `chunks` have been removed. The new `qenv` object should be used instead. See the new `qenv` vignette in the package for further details.

# teal.code 0.3.0
Expand Down
5 changes: 5 additions & 0 deletions R/qenv-eval_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ setGeneric("eval_code", function(object, code) standardGeneric("eval_code"))
#' @rdname eval_code
#' @export
setMethod("eval_code", signature = c("qenv", "expression"), function(object, code) {
if (interactive()) {
grDevices::pdf(file = NULL)
on.exit(dev.off())
}

id <- sample.int(.Machine$integer.max, size = length(code))

object@id <- c(object@id, id)
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-qenv_eval_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ testthat::test_that("an error when calling eval_code returns a qenv.error object
})

testthat::test_that("a warning when calling eval_code returns a qenv object which has warnings", {
pdf(nullfile())
on.exit(dev.off())
q <- eval_code(new_qenv(), quote("iris_data <- iris"))
q <- eval_code(q, quote("p <- hist(iris_data[, 'Sepal.Length'], ff = '')"))
testthat::expect_s4_class(q, "qenv")
Expand Down

0 comments on commit 5766e88

Please sign in to comment.