-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
242 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# needed to handle try-error | ||
setOldClass("quosure.error") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' Show the `Quosure` object | ||
#' | ||
#' Prints the `Quosure` object | ||
#' @param object (`Quosure`) | ||
#' @return nothing | ||
#' @importFrom methods show | ||
#' @examples | ||
#' q1 <- new_quosure(code = "print('a')", env = new.env()) | ||
#' q1 | ||
#' @export | ||
setMethod("show", "Quosure", function(object) { | ||
obs <- names(as.list(object@env)) | ||
if (length(obs) > 0) { | ||
cat(paste("A quosure object containing:", paste(obs, collapse = ", "))) | ||
} else { | ||
cat("A quosure object containing no objects") | ||
} | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
testthat::test_that("get_code returns code of Quosure object", { | ||
q <- new_quosure(list2env(list(x = 1)), code = "x <- 1") | ||
q <- eval_code(q, "y <- x", name = "next_code") | ||
testthat::expect_equal(get_code(q), c("initial code" = "x <- 1", "next_code" = "y <- x")) | ||
}) | ||
|
||
testthat::test_that("get_code called with quosure.error returns error with trace in error message", { | ||
q <- new_quosure(list2env(list(x = 1)), code = "x <- 1") | ||
q <- eval_code(q, "y <- x") | ||
q <- eval_code(q, "w <- v") | ||
|
||
code <- tryCatch( | ||
get_code(q), | ||
error = function(e) e | ||
) | ||
testthat::expect_equal(class(code), c("validation", "try-error", "simpleError", "error", "condition")) | ||
testthat::expect_equal( | ||
code$message, | ||
"object 'v' not found \n when evaluating Quosure code:\n w <- v\n\ntrace: \n x <- 1\n y <- x\n w <- v\n" | ||
) | ||
}) |
Oops, something went wrong.