You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Might be implemented similar to depreciated flat roundtrip
#' Verify parse data modifications#'#' @description Check whether serializing the parse data results in the same#' number of lines as the initial data that should be styled.#' @param pd_flat A parse table.#' @param text A character vector with the initial text to compare against.#' @return If the verification is successful, `pd` is returned, with empty#' lines at the end of `text` stripped. \cr#' Otherwise, an error is thrown.#' @seealso [serialize_parse_data_flat()]verify_roundtrip<-function(pd_flat, text) {
roundtrip<- serialize_parse_data_flat(pd_flat)
if (length(roundtrip) < length(text)) {
stopifnot(text[-seq_along(roundtrip)] =="")
text<-text[seq_along(roundtrip)]
}
stopifnot(identical(text, roundtrip))
text
}
I wonder how that should be implemented. Because with reference to #85, I think it would make sense to not just test parsing and serialising (because that almost certainly works now), but also whether the code is still valid after tokens were inserted, compare #259. So a simple parse statement of the output could check that.
I think there are multiple layers of roundtrip testing:
At the text level: parse + nest + serialize should give exactly the same output (minus tabs to spaces conversion)
At the code level: styling with any scope below "token" should lead to identical results (language objects or call trees) after parsing
At the semantic level: styling with scope "token" should not change semantics of the code
The first two can be tested automatically, for the third we need tests with good coverage and rely on the user. We still could test that the resulting code is parseable, but this doesn't buy us much.
Activity
lorenzwalthert commentedon Sep 21, 2017
Reference: #85.
lorenzwalthert commentedon Sep 23, 2017
Related: #216.
lorenzwalthert commentedon Oct 29, 2017
I wonder how that should be implemented. Because with reference to #85, I think it would make sense to not just test parsing and serialising (because that almost certainly works now), but also whether the code is still valid after tokens were inserted, compare #259. So a simple parse statement of the output could check that.
krlmlr commentedon Oct 31, 2017
I think there are multiple layers of roundtrip testing:
The first two can be tested automatically, for the third we need tests with good coverage and rely on the user. We still could test that the resulting code is parseable, but this doesn't buy us much.
lorenzwalthert commentedon Nov 3, 2017
Can we label this with "Status: Postponed" and close it for now?
krlmlr commentedon Nov 4, 2017
Sure.
lorenzwalthert commentedon Nov 21, 2017
Reference: #280.
krlmlr commentedon Feb 28, 2018
Have we implemented roundtrip checking by now?
lorenzwalthert commentedon Feb 28, 2018
In #287, we implemented verifying whenever possible (
can_verify_roundtrip), which seems to be the case whenever we don't have any token manipulators.lorenzwalthert commentedon Mar 13, 2018
Reference: #368.