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
new file: tests/testit/test-clean.R #405
Conversation
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.
It is not a good idea to copy the source code from R/
to tests/
. When the source code under R/
is updated, you'd have to copy again. Are you able to come up with a way to avoid copying? Thanks!
I thought this was not the way to go but couldn't figure so far how to actually call the functions that do the string operations because as far as I understand all are anonymous functions. Maybe another approach would be to modify clean.R but yeah not sure if this is what is needed. For example: # replace three or more \n with two, i.e. two or more empty lines with one
replace_inline = function(x) {
x = paste(gsub('\\s+$', '', x), collapse = '\n')
trim_ws(gsub('\n{3,}', '\n\n', x))
} remove_extra_empty_lines = function(f) process_file(f, remove_inline) |
So, now the functions in |
It took me some time to figure this out -- I don't know if it my setup or something else but I had to add It seems to me that otherwise |
modified: tests/test-all.R modified: tests/testit/test-clean.R
…sible to return the processed character vector, so that we can test these functions without reading/writing to files
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.
I added a third argument x
to process_file()
so we can test the functions without reading or writing to files. Thank you!
BTW, if you use the dev version of testit (remotes::install_github('yihui/testit')
), you will be able to Ctrl + Shift + L and then run test-all.R
.
Hi Yihui. Thanks for looking into this. I was thinking that I am not doing this right because there was no feedback for a while. I will try to work on the rest of the R files now for tests. |
No, it was just that I had been busy with many other things. Sorry about the delay. |
Tests for clean.R