-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update remove_enclosing_curly_braces
#98
Conversation
R/utils.R
Outdated
#' | ||
#' @return The string without curly braces | ||
#' @return Character string without curly braces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#' @return Character string without curly braces | |
#' @return `character(1)` string without curly braces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it doesn't always return character(1) - but I have removed the upper case "C"
|
||
# converts vector of expressions to character | ||
format_expression <- function(code) { | ||
unlist(lapply(as.character(code), remove_enclosing_curly_braces)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not vapply with character(1)?:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I can't really change the output of remove_enclosing_curly_braces
without changing chunks which I would rather not do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...though I guess I could if we test to make sure chunks are still good
Code Coverage Summary
Diff against main
Results for commit: 51254db Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested with sample apps and with code
library(teal.code)
a <- new_qenv(
list2env(list(y = 2, x = 1)),
code = quote({
x <- 1
y <- 2
})
) |> eval_code(quote({
if (x == 1) {
print("x = 1")
}
}))
b <- new_qenv(
list2env(list(y = 2, x = 1)),
code = quote({
x <- 1
y <- 2
})
) |> eval_code(quote({
if (x == 1) {
print("x = 1")
}
}))
c <- a |> eval_code(quote({
c <- 4
}))
concat(a, b)|>
get_code() |> paste(collapse = "\n") |> cat()
join(a, c)|>
get_code() |> paste(collapse = "\n") |> cat()
a2 <- new_qenv(
list2env(list(y = 2, x = 1)),
code = quote({
{
x <- 1
y <- 2
}
})
) |> eval_code(quote({
if (x == 1) print("x = 1")
}))
a2 |> get_code() |> paste(collapse = "\n") |> cat()
a3 <- new_qenv(
list2env(list(y = 2, x = 1)),
code = quote({
x <- 1; y <- 2
})
) |> eval_code(quote({
if (x == 1) print("x = 1"); print("Hello")
}))
a3 |> get_code() |> paste(collapse = "\n") |> cat()
we tested some edge cases too.
Closes #4
Compare this branch to main for existing module qenv's and also with for example:
and