Skip to content
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

small simplification for glue, add coverage test #1660

Merged
merged 10 commits into from
Oct 10, 2022
Merged

Conversation

MichaelChirico
Copy link
Collaborator

length(parsed_text) == 0 also covers the case like glue("{}") where an empty expression is parsed (parsed_text is expression()). I don't see how nrow(parse_data) == 0 is possible after that (even a comment generates parse data).

@@ -165,8 +165,7 @@ extract_glued_symbols <- function(expr) {
parse(text = xml2::xml_text(cl)),
error = function(...) NULL,
warning = function(...) NULL
)[[1L]]
if (is.null(parsed_cl)) next
Copy link
Collaborator Author

@MichaelChirico MichaelChirico Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of how we could end up with a parsing error here... if there's a flaw in our thinking that might lead to that happening, we should let it cause an error & users can report it so we can tighten the logic elsewhere.

@@ -160,13 +160,16 @@ extract_glued_symbols <- function(expr) {
}
glued_symbols <- new.env(parent = emptyenv())

unexpected_error <- function(cond) {
stop("Unexpected failure to parse glue call, please report: ", conditionMessage(cond))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to make sure that we get this expected error message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no -- I don't know how to trigger the error. it should be nocov but covr doesn't separate out tryCatch branches

@MichaelChirico MichaelChirico merged commit a9cc2bc into main Oct 10, 2022
@MichaelChirico MichaelChirico deleted the covr-glue branch October 10, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants