Skip to content

Commit 0d80a7b

Browse files
one more test. From #594
1 parent a12f1c4 commit 0d80a7b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tests/testthat/test-cache-high-level-api.R

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ text <- c(
2424
rep(10)
2525

2626
capture.output(test_that("activated cache brings speedup on style_text() API on character vector", {
27-
2827
activate_testthat_cache()
2928
on.exit(clear_testthat_cache())
3029
clear_testthat_cache()
@@ -36,7 +35,6 @@ capture.output(test_that("activated cache brings speedup on style_text() API on
3635
}))
3736

3837
capture.output(test_that("activated cache brings speedup on style_text() API on character scalar", {
39-
4038
activate_testthat_cache()
4139
on.exit(clear_testthat_cache())
4240
clear_testthat_cache()
@@ -75,7 +73,8 @@ test_that("trailing line breaks are ignored for caching in one scalar", {
7573
second <- system.time(
7674
styler::style_text(
7775
paste0(paste0(text, collapse = "\n"), "\n", "\n", "\n", "\n", collapse = "")
78-
))
76+
)
77+
)
7978
expect_true(first["elapsed"] / 2 > second["elapsed"])
8079
# check we only have three different expressions. Top-level, example and fun.
8180
cache_info <- cache_info()
@@ -86,7 +85,6 @@ test_that("trailing line breaks are ignored for caching in one scalar", {
8685
})
8786

8887
capture.output(test_that("no speedup when tranformer changes", {
89-
9088
activate_testthat_cache()
9189
on.exit(clear_testthat_cache())
9290
clear_testthat_cache()
@@ -112,11 +110,11 @@ capture.output(
112110
first <- system.time(styler::style_text(text))
113111
second <- system.time(styler::style_text(paste0(text, collapse = "\n")))
114112
expect_true(first["elapsed"] / 2 > second["elapsed"])
115-
}))
113+
})
114+
)
116115

117116

118117
capture.output(test_that("unactivated cache does not bring speedup", {
119-
120118
on.exit(clear_testthat_cache())
121119
clear_testthat_cache()
122120
cache_deactivate()
@@ -127,7 +125,6 @@ capture.output(test_that("unactivated cache does not bring speedup", {
127125

128126

129127
capture.output(test_that("avoid deleting comments #584 (see commit messages)", {
130-
131128
on.exit(clear_testthat_cache())
132129
clear_testthat_cache()
133130
activate_testthat_cache()
@@ -136,7 +133,7 @@ capture.output(test_that("avoid deleting comments #584 (see commit messages)", {
136133
"# Comment",
137134
"# another",
138135
"NULL"
139-
)
136+
)
140137
style_text(text)
141138
text2 <- c(
142139
"1 + 1",
@@ -152,7 +149,6 @@ capture.output(test_that("avoid deleting comments #584 (see commit messages)", {
152149

153150

154151
capture.output(test_that("avoid removing roxygen mask (see commit messages in #584)", {
155-
156152
on.exit(clear_testthat_cache())
157153
clear_testthat_cache()
158154
activate_testthat_cache()
@@ -182,7 +178,6 @@ capture.output(test_that("avoid removing roxygen mask (see commit messages in #5
182178

183179

184180
capture.output(test_that("partial caching of multiple expressions on one line works", {
185-
186181
on.exit(clear_testthat_cache())
187182
clear_testthat_cache()
188183
activate_testthat_cache()
@@ -194,4 +189,14 @@ capture.output(test_that("partial caching of multiple expressions on one line wo
194189
as.character(styled),
195190
text2
196191
)
192+
193+
style_text("mtcars")
194+
style_text("mtcars %>%
195+
f()")
196+
final_text <- "mtcars %>%
197+
f() #"
198+
expect_equal(
199+
as.character(style_text(final_text)),
200+
final_text,
201+
)
197202
}))

0 commit comments

Comments
 (0)