Skip to content

Commit

Permalink
create a new test collection instead of modifying existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Dec 3, 2024
1 parent a59d4bb commit e843fd5
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 56 deletions.
9 changes: 0 additions & 9 deletions tests/testthat/line_breaks_and_other/curly-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,3 @@ while (TRUE){

while (TRUE){#
}


for (i in 1:10) {}





while (TRUE) {}
6 changes: 0 additions & 6 deletions tests/testthat/line_breaks_and_other/curly-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,3 @@ while (TRUE) {

while (TRUE) { #
}


for (i in 1:10) {}


while (TRUE) {}
20 changes: 0 additions & 20 deletions tests/testthat/line_breaks_and_other/pipe_and_comment-in.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
1:10 %>% # sum
sum()


f %>% g()





h %>% i()





# some comment




j %>% k()
12 changes: 0 additions & 12 deletions tests/testthat/line_breaks_and_other/pipe_and_comment-out.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
1:10 %>% # sum
sum()


f %>% g()


h %>% i()


# some comment


j %>% k()
4 changes: 0 additions & 4 deletions tests/testthat/line_breaks_fun_call/blank-non-strict-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ call(
1
)





call(
x = 2,
1,
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/line_breaks_fun_call/blank-non-strict-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ call(
1
)





call(
x = 2,
1,
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/braces-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
1 + 1
}





### some comment




{
NULL
}
11 changes: 11 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/braces-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
1 + 1
}


### some comment


{
NULL
}
20 changes: 20 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/conditionals-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
for (i in 1:10) {}






# some comment





while (TRUE) {}




# some comment
if (TRUE) NULL
11 changes: 11 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/conditionals-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
for (i in 1:10) {}


# some comment


while (TRUE) {}


# some comment
if (TRUE) NULL
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
f <- function() NULL








g <- function() NULL




f()

# comment





g()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
f <- function() NULL


g <- function() NULL


f()

# comment


g()
23 changes: 23 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/non_strict-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
f <- function() NULL








g <- function() NULL




f()

# comment





g()
12 changes: 12 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/non_strict-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
f <- function() NULL


g <- function() NULL


f()

# comment


g()
21 changes: 21 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/piped_chains-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


f %>% g()






h %>% i()





# some comment




j %>% k()
10 changes: 10 additions & 0 deletions tests/testthat/line_breaks_top_level_exprs/piped_chains-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
f %>% g()


h %>% i()


# some comment


j %>% k()
30 changes: 30 additions & 0 deletions tests/testthat/test-line_breaks_top_level_exprs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
test_that("extra line breaks between conditional statements are removed", {
expect_no_warning(
test_collection("line_breaks_top_level_exprs", "conditionals", transformer = style_text)
)
})

test_that("extra line breaks between function and definitions and calls are removed", {
expect_no_warning(
test_collection("line_breaks_top_level_exprs", "function_defs_and_calls", transformer = style_text)
)
})

test_that("extra line breaks between piped chains are removed", {
expect_no_warning(
test_collection("line_breaks_top_level_exprs", "piped_chains", transformer = style_text)
)
})

test_that("extra line breaks between braced expressions are removed", {
expect_no_warning(
test_collection("line_breaks_top_level_exprs", "braces", transformer = style_text)
)
})

test_that("extra line breaks are not removed in non-strict mode", {
expect_no_warning(
test_collection("line_breaks_top_level_exprs", "non_strict", transformer = style_text)
)
})

2 changes: 1 addition & 1 deletion tests/testthat/test-transformers-drop.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test_that("tidyverse transformers are correctly dropped", {

names_line_break <- c(
"remove_empty_lines_after_opening_and_before_closing_braces",
"set_line_breaks_between_top_level_exprs ",
"set_line_breaks_between_top_level_exprs",
"set_line_break_around_comma_and_or",
"set_line_break_after_assignment",
"set_line_break_after_opening_if_call_is_multi_line",
Expand Down

0 comments on commit e843fd5

Please # to comment.