Skip to content

Commit

Permalink
Use expr_deparse() in expr_text()
Browse files Browse the repository at this point in the history
Closes r-lib#357
  • Loading branch information
lionel- committed Jan 21, 2018
1 parent 6a2b6bb commit 1055a7d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ expr_name <- function(expr) {
#' @param width Width of each line.
#' @param nlines Maximum number of lines to extract.
expr_text <- function(expr, width = 60L, nlines = Inf) {
str <- deparse(expr, width.cutoff = width)
str <- expr_deparse(expr, width = width)

if (length(str) > nlines) {
str <- c(str[seq_len(nlines - 1)], "...")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test_that("name symbols, calls, and scalars", {
expect_identical(expr_name(quote(foo(bar))), "foo(bar)")
expect_identical(expr_name(1L), "1")
expect_identical(expr_name("foo"), "foo")
expect_identical(expr_name(function() NULL), "function () ...")
expect_identical(expr_name(function() NULL), "<function() NULL>")
expect_error(expr_name(1:2), "must quote a symbol, scalar, or call")
expect_identical(expr_name(expr(function() { a; b })), "function() ...")
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-quo.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test_that("quosures are spliced", {
expect_identical(quo_text(q), "foo(bar, baz(baz, 3))")

q <- expr_interp(~foo::bar(!! function(x) ...))
expect_identical(f_text(q), "foo::bar(function (x) \n...)")
expect_identical(f_text(q), "foo::bar(<function(x) ...>)")

q <- quo(!! quo(!! quo(foo(!! quo(!! quo(bar(!! quo(!! quo(!! quo(baz))))))))))
expect_identical(quo_text(q), "foo(bar(baz))")
Expand Down

0 comments on commit 1055a7d

Please sign in to comment.