Skip to content

Commit 6584fc9

Browse files
setting up basic testing
1 parent e2388b7 commit 6584fc9

5 files changed

+77
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#' Prettify R source code
2+
#'
3+
#' Performs various substitutions in all `.R` files in a package
4+
#' (code and tests).
5+
#' Carefully examine the results after running this function!
6+
#' @example style_pkg(style = tidyverse_style, strict = TRUE)
7+
a <- 2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#' Prettify R source code
2+
#'
3+
#' Performs various substitutions in all `.R` files in a package
4+
#' (code and tests).
5+
#' Carefully examine the results after running this function!
6+
#' @examples
7+
#' style_pkg(style = tidyverse_style, strict = TRUE)
8+
#' style_pkg(
9+
#' scope = "line_breaks",
10+
#' math_token_spacing = specify_math_token_spacing(zero = "'+'")
11+
#' )
12+
a <- call
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#' Prettify R source code
2+
#'
3+
#' Performs various substitutions in all `.R` files in a package...
4+
#' Carefully examine the results after running this function!
5+
#' @example style_pkg(style = tidyverse_style, strict = TRUE)
6+
#' @name k
7+
a <- 2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#' The tidyverse style
2+
#'
3+
#' Style code according to the tidyverse style guide.
4+
#' @family style_guides
5+
#' @examples
6+
#' style_text("call( 1)", style = tidyverse_style, scope = "spaces")
7+
#' style_text("call( 1)", transformers = tidyverse_style(strict = TRUE))
8+
#' style_text(c("ab <- 3", "a <-3"), strict = FALSE) # keeps alignment of "<-"
9+
#' style_text(c("ab <- 3", "a <-3"), strict = TRUE) # drops alignment of "<-"
10+
#' @importFrom purrr partial
11+
#' @export
12+
a <- call
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
context("test-identify-roxygen-examples.R")
2+
3+
#' Things to consider:
4+
#' * one function declaration or many
5+
#' * example(s) is last tag or not?
6+
#' * malformatted examples
7+
#' * \dontrun examples
8+
9+
test_that("one function, last tag, properly formatted, no dontrun", {
10+
expect_equal(
11+
identify_start_stop_ofroyxgen_examples_from_paths(testthat_file(
12+
"identify-roxygen-examples/1-one-function-example-last-proper-run.R"
13+
)),
14+
list(c(6, 6))
15+
)
16+
17+
expect_equal(
18+
identify_start_stop_ofroyxgen_examples_from_paths(testthat_file(
19+
"identify-roxygen-examples/2-one-function-examples-last-proper-run.R"
20+
)),
21+
list(c(6, 11))
22+
)
23+
})
24+
25+
test_that("one function, not last, tag, properly formatted, no dontrun", {
26+
expect_equal(
27+
identify_start_stop_ofroyxgen_examples_from_paths(testthat_file(
28+
"identify-roxygen-examples/3-one-function-example-not-last-proper-run.R"
29+
)),
30+
list(c(5, 9))
31+
)
32+
33+
expect_equal(
34+
identify_start_stop_ofroyxgen_examples_from_paths(testthat_file(
35+
"identify-roxygen-examples/4-one-function-examples-not-last-proper-run.R"
36+
)),
37+
list(c(5, 5))
38+
)
39+
})

0 commit comments

Comments
 (0)