Skip to content

Commit 902892c

Browse files
test interaction with roxygen and base indention
1 parent a5e0e45 commit 902892c

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
test_that("base_indention is respected in caching", {
2+
on.exit(clear_testthat_cache())
3+
text <- c("1 + 1")
4+
fresh_testthat_cache()
5+
without_indention <- style_text(text)
6+
fresh_testthat_cache()
7+
style_text(text, base_indention = 5)
8+
expect_equal(
9+
style_text(text),
10+
without_indention
11+
)
12+
})
13+
14+
test_that("include_roxygen_exmples is respected in caching", {
15+
on.exit(clear_testthat_cache())
16+
text <- c("#' Roxygen", "#'", "#' @examples", "#' 1+1", "1 + 1")
17+
fresh_testthat_cache()
18+
with_examples <- style_text(text)
19+
fresh_testthat_cache()
20+
style_text(text, include_roxygen_examples = FALSE)
21+
expect_equal(
22+
style_text(text, include_roxygen_examples = TRUE),
23+
with_examples
24+
)
25+
})
26+
27+
28+
test_that("cache is deactivated at end of caching related testthat file", {
29+
expect_false(cache_is_activated())
30+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test_that("base_indention is respected in caching", {
2+
on.exit(clear_testthat_cache())
3+
text <- c("1 + 1")
4+
fresh_testthat_cache()
5+
without_indention <- style_text(text)
6+
fresh_testthat_cache()
7+
style_text(text, base_indention = 5)
8+
expect_equal(
9+
style_text(text),
10+
without_indention
11+
)
12+
})
13+
14+
test_that("cache is deactivated at end of caching related testthat file", {
15+
expect_false(cache_is_activated())
16+
})

tests/testthat/test-cache-interaction-roxygen-code-examples.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ test_that("roxzgen code examples are written to cache as whole expressions bring
5656
expect_gt(first["elapsed"], 6 * second["elapsed"])
5757
})
5858

59+
test_that("cache is deactivated at end of caching related testthat file", {
60+
expect_false(cache_is_activated())
61+
})
5962

6063
# consider dropping transformer text from cache key to speed up.

0 commit comments

Comments
 (0)