Skip to content

Commit 0f61d06

Browse files
committed
scope = "tokens", strict = TRUE
1 parent 2567609 commit 0f61d06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+287
-217
lines changed

R/auto-test.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ auto_test <- function(code_path, test_path, reporter = default_reporter(),
6161
TRUE
6262
}
6363
watch(c(code_path, test_path), watcher, hash = hash)
64-
6564
}
6665

6766
#' Watches a package for changes, rerunning tests as appropriate.
@@ -75,8 +74,10 @@ auto_test <- function(code_path, test_path, reporter = default_reporter(),
7574
#' @seealso [auto_test()] for details on how method works
7675
auto_test_package <- function(pkg = ".", reporter = default_reporter(), hash = TRUE) {
7776
if (!requireNamespace("devtools", quietly = TRUE)) {
78-
stop("devtools required to run auto_test_package(). Please install.",
79-
call. = FALSE)
77+
stop(
78+
"devtools required to run auto_test_package(). Please install.",
79+
call. = FALSE
80+
)
8081
}
8182

8283
pkg <- devtools::as.package(pkg)
@@ -120,5 +121,4 @@ auto_test_package <- function(pkg = ".", reporter = default_reporter(), hash = T
120121
TRUE
121122
}
122123
watch(c(code_path, test_path), watcher, hash = hash)
123-
124124
}

R/compare-character.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
compare.character <- function(x, y, check.attributes = TRUE, ...,
2828
max_diffs = 5, max_lines = 5,
2929
width = console_width()) {
30-
3130
if (identical(x, y)) {
3231
return(no_difference())
3332
}
@@ -61,7 +60,6 @@ compare.character <- function(x, y, check.attributes = TRUE, ...,
6160
}
6261

6362
mismatch_character <- function(x, y, diff = !vector_equal(x, y)) {
64-
6563
structure(
6664
list(
6765
i = which(diff),

R/compare-numeric.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ compare.numeric <- function(x, y,
2020
tolerance = .Machine$double.eps ^ 0.5,
2121
check.attributes = TRUE,
2222
..., max_diffs = 9) {
23-
all_equal <- all.equal(x, y, tolerance = tolerance,
24-
check.attributes = check.attributes, ...)
23+
all_equal <- all.equal(
24+
x, y, tolerance = tolerance,
25+
check.attributes = check.attributes, ...
26+
)
2527
if (isTRUE(all_equal)) {
2628
return(no_difference())
2729
}
@@ -65,7 +67,6 @@ mismatch_numeric <- function(x, y, diff = !vector_equal(x, y)) {
6567

6668
#' @export
6769
format.mismatch_numeric <- function(x, ..., max_diffs = 9, digits = 3) {
68-
6970
summary <- paste0(x$n_diff, "/", x$n, " mismatches")
7071
if (x$n_diff > 1) {
7172
mu <- format(x$mu_diff, digits = digits, trim = TRUE)

R/compare.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ same_type <- function(x, y) identical(typeof(x), typeof(y))
6767
diff_type <- function(x, y) difference(fmt = "Types not compatible: %s is not %s", typeof(x), typeof(y))
6868

6969
same_class <- function(x, y) {
70-
if (!is.object(x) && !is.object(y))
70+
if (!is.object(x) && !is.object(y)) {
7171
return(TRUE)
72+
}
7273
identical(class(x), class(y))
7374
}
7475
diff_class <- function(x, y) {

R/describe.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#' })
5757

5858
describe <- function(description, code) {
59-
is_invalid_description <- function (description) {
59+
is_invalid_description <- function(description) {
6060
!is.character(description) || length(description) != 1 ||
6161
nchar(description) == 0
6262
}

R/evaluate-promise.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#' 4
1717
#' })
1818
evaluate_promise <- function(code, print = FALSE) {
19-
2019
warnings <- Stack$new()
2120
handle_warning <- function(condition) {
2221
warnings$push(condition)
@@ -32,7 +31,8 @@ evaluate_promise <- function(code, print = FALSE) {
3231
temp <- file()
3332
on.exit(close(temp))
3433

35-
result <- withr::with_output_sink(temp,
34+
result <- withr::with_output_sink(
35+
temp,
3636
withCallingHandlers(
3737
withVisible(code),
3838
warning = handle_warning,

R/expect-comparison.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ expect_compare <- function(operator = c("<", "<=", ">", ">="), act, exp) {
2828
stopifnot(is.numeric(exp$val), length(exp$val) == 1)
2929

3030
msg <- c(
31-
"<" = "not strictly less than",
31+
"<" = "not strictly less than",
3232
"<=" = "not less than",
33-
">" = "not strictly more than",
33+
">" = "not strictly more than",
3434
">=" = "not more than"
3535
)[[operator]]
3636

R/expect-equality.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ NULL
4848
#' @param ... other values passed to [all.equal()]
4949
expect_equal <- function(object, expected, ..., info = NULL, label = NULL,
5050
expected.label = NULL) {
51-
5251
act <- quasi_label(enquo(object), label)
5352
exp <- quasi_label(enquo(expected), expected.label)
5453

@@ -66,7 +65,6 @@ expect_equal <- function(object, expected, ..., info = NULL, label = NULL,
6665
#' @export
6766
#' @rdname equality-expectations
6867
expect_setequal <- function(object, expected) {
69-
7068
act <- quasi_label(enquo(object))
7169
exp <- quasi_label(enquo(expected))
7270

@@ -103,7 +101,6 @@ expect_equivalent <- function(object, expected, ..., info = NULL, label = NULL,
103101
#' @rdname equality-expectations
104102
expect_identical <- function(object, expected, info = NULL, label = NULL,
105103
expected.label = NULL) {
106-
107104
act <- quasi_label(enquo(object), label)
108105
exp <- quasi_label(enquo(expected), expected.label)
109106

@@ -131,7 +128,6 @@ expect_identical <- function(object, expected, info = NULL, label = NULL,
131128
#' @rdname equality-expectations
132129
expect_identical <- function(object, expected, info = NULL, label = NULL,
133130
expected.label = NULL) {
134-
135131
act <- quasi_label(enquo(object), label)
136132
exp <- quasi_label(enquo(expected), expected.label)
137133

@@ -159,7 +155,6 @@ expect_identical <- function(object, expected, info = NULL, label = NULL,
159155
#' @rdname equality-expectations
160156
expect_reference <- function(object, expected, info = NULL, label = NULL,
161157
expected.label = NULL) {
162-
163158
act <- quasi_label(enquo(object), label)
164159
exp <- quasi_label(enquo(expected), expected.label)
165160

R/expect-known.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ expect_known_output <- function(object, file,
4444
label = NULL,
4545
print = FALSE,
4646
width = 80) {
47-
4847
act <- list()
4948
act$quo <- enquo(object)
5049
act$lab <- label %||% quo_label(act$quo)
@@ -86,7 +85,6 @@ expect_known_value <- function(object, file,
8685
...,
8786
info = NULL,
8887
label = NULL) {
89-
9088
act <- quasi_label(enquo(object), label)
9189

9290
if (!file.exists(file)) {
@@ -126,7 +124,6 @@ expect_equal_to_reference <- function(..., update = FALSE) {
126124
#' @param hash Known hash value. Leave empty and you'll be informed what
127125
#' to use in the test output.
128126
expect_known_hash <- function(object, hash = NULL) {
129-
130127
act <- quasi_label(enquo(object))
131128
act_hash <- digest::digest(act$val)
132129
if (!is.null(hash)) {

R/expect-named.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
expect_named <- function(object, expected, ignore.order = FALSE,
2929
ignore.case = FALSE, info = NULL,
3030
label = NULL) {
31-
3231
act <- quasi_label(enquo(object), label = label)
3332
act$names <- names(act$val)
3433

@@ -43,7 +42,8 @@ expect_named <- function(object, expected, ignore.order = FALSE,
4342

4443
expect(
4544
identical(act$names, exp_names),
46-
sprintf("Names of %s (%s) don't match %s",
45+
sprintf(
46+
"Names of %s (%s) don't match %s",
4747
act$lab,
4848
paste0("'", act$names, "'", collapse = ", "),
4949
paste0("'", exp_names, "'", collapse = ", ")

R/expect-output.R

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ NULL
8787
#' @export
8888
#' @rdname output-expectations
8989
expect_output <- function(object, regexp = NULL, ..., info = NULL, label = NULL) {
90-
9190
act <- quasi_capture(enquo(object), capture_output, label = label)
9291

9392
if (identical(regexp, NA)) {
@@ -118,7 +117,6 @@ expect_error <- function(object,
118117
...,
119118
info = NULL,
120119
label = NULL) {
121-
122120
act <- quasi_capture(enquo(object), capture_error, label = label)
123121
msg <- compare_condition(act$cap, act$lab, regexp = regexp, class = class, ...)
124122
expect(is.null(msg), msg, info = info)
@@ -134,10 +132,11 @@ expect_condition <- function(object,
134132
...,
135133
info = NULL,
136134
label = NULL) {
137-
138135
act <- quasi_capture(enquo(object), capture_condition, label = label)
139-
msg <- compare_condition(act$cap, act$lab, regexp = regexp, class = class, ...,
140-
cond_type = "condition")
136+
msg <- compare_condition(
137+
act$cap, act$lab, regexp = regexp, class = class, ...,
138+
cond_type = "condition"
139+
)
141140
expect(is.null(msg), msg, info = info)
142141

143142
invisible(act$val %||% act$err)
@@ -148,7 +147,6 @@ expect_condition <- function(object,
148147
#' @rdname output-expectations
149148
expect_message <- function(object, regexp = NULL, ..., all = FALSE,
150149
info = NULL, label = NULL) {
151-
152150
act <- quasi_capture(enquo(object), capture_messages, label = label)
153151
msg <- compare_messages(act$cap, act$lab, regexp = regexp, all = all, ...)
154152
expect(is.null(msg), msg, info = info)
@@ -160,10 +158,11 @@ expect_message <- function(object, regexp = NULL, ..., all = FALSE,
160158
#' @rdname output-expectations
161159
expect_warning <- function(object, regexp = NULL, ..., all = FALSE,
162160
info = NULL, label = NULL) {
163-
164161
act <- quasi_capture(enquo(object), capture_warnings, label = label)
165-
msg <- compare_messages(act$cap, act$lab, regexp = regexp, all = all, ...,
166-
cond_type = "warnings")
162+
msg <- compare_messages(
163+
act$cap, act$lab, regexp = regexp, all = all, ...,
164+
cond_type = "warnings"
165+
)
167166
expect(is.null(msg), msg, info = info)
168167

169168
invisible(act$val)
@@ -257,7 +256,6 @@ compare_messages <- function(messages,
257256
regexp = NA, ...,
258257
all = FALSE,
259258
cond_type = "messages") {
260-
261259
bullets <- paste0("* ", messages, collapse = "\n")
262260
# Expecting no messages
263261
if (identical(regexp, NA)) {

R/expect-self-test.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ show_failure <- function(expr) {
6767
#' @rdname expect_success
6868
#' @param path Path to save failure output
6969
expect_known_failure <- function(path, expr) {
70-
FailureReporter <- R6::R6Class("FailureReporter", inherit = CheckReporter,
70+
FailureReporter <- R6::R6Class(
71+
"FailureReporter", inherit = CheckReporter,
7172
public = list(end_reporter = function(...) {})
7273
)
7374

R/expectation.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ as.expectation <- function(x, ...) UseMethod("as.expectation", x)
160160

161161
#' @export
162162
as.expectation.default <- function(x, ..., srcref = NULL) {
163-
stop("Don't know how to convert '", paste(class(x), collapse = "', '"),
164-
"' to expectation.", call. = FALSE)
163+
stop(
164+
"Don't know how to convert '", paste(class(x), collapse = "', '"),
165+
"' to expectation.", call. = FALSE
166+
)
165167
}
166168

167169
#' @export
@@ -234,9 +236,9 @@ format.expectation <- function(x, ...) {
234236

235237
single_letter_summary <- function(x) {
236238
switch(expectation_type(x),
237-
skip = colourise("S", "skip"),
239+
skip = colourise("S", "skip"),
238240
success = colourise(".", "success"),
239-
error = colourise("E", "error"),
241+
error = colourise("E", "error"),
240242
failure = colourise("F", "failure"),
241243
warning = colourise("W", "warning"),
242244
"?"

R/expectations-matches.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#' }
2121
expect_match <- function(object, regexp, perl = FALSE, fixed = FALSE, ..., all = TRUE,
2222
info = NULL, label = NULL) {
23-
2423
if (fixed) escape <- identity
2524
else escape <- escape_regex
2625

@@ -38,8 +37,10 @@ expect_match <- function(object, regexp, perl = FALSE, fixed = FALSE, ..., all =
3837
if (length(act$val) == 1) {
3938
values <- paste0("Actual value: \"", escape(encodeString(act$val)), "\"")
4039
} else {
41-
values <- paste0("Actual values:\n",
42-
paste0("* ", escape(encodeString(act$val)), collapse = "\n"))
40+
values <- paste0(
41+
"Actual values:\n",
42+
paste0("* ", escape(encodeString(act$val)), collapse = "\n")
43+
)
4344
}
4445
expect(
4546
if (all) all(matches) else any(matches),

R/make-expectation.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
#' make_expectation(df)
1919
make_expectation <- function(x, expectation = "equals") {
2020
obj <- substitute(x)
21-
expectation <- match.arg(expectation,
22-
c("equals", "is_equivalent_to", "is_identical_to"))
21+
expectation <- match.arg(
22+
expectation,
23+
c("equals", "is_equivalent_to", "is_identical_to")
24+
)
2325

24-
dput(substitute(expect_equal(obj, values),
25-
list(obj = obj, expectation = as.name(expectation), values = x)))
26+
dput(substitute(
27+
expect_equal(obj, values),
28+
list(obj = obj, expectation = as.name(expectation), values = x)
29+
))
2630
}

R/mock.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ with_mock <- function(..., .env = topenv()) {
4242
mock_qual_names <- names(new_values)
4343

4444
if (all(mock_qual_names == "")) {
45-
warning("Not mocking anything. Please use named parameters to specify the functions you want to mock.",
46-
call. = FALSE)
45+
warning(
46+
"Not mocking anything. Please use named parameters to specify the functions you want to mock.",
47+
call. = FALSE
48+
)
4749
code_pos <- rep(TRUE, length(new_values))
4850
} else {
4951
code_pos <- (mock_qual_names == "")
@@ -82,8 +84,10 @@ extract_mocks <- function(new_values, .env, eval_env = parent.frame()) {
8284
pkg_name <- gsub(pkg_and_name_rx, "\\1", qual_name)
8385

8486
if (is_base_pkg(pkg_name)) {
85-
stop("Can't mock functions in base packages (", pkg_name, ")",
86-
call. = FALSE)
87+
stop(
88+
"Can't mock functions in base packages (", pkg_name, ")",
89+
call. = FALSE
90+
)
8791
}
8892

8993
name <- gsub(pkg_and_name_rx, "\\2", qual_name)

R/old-school.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ NULL
1414
#' @export
1515
#' @rdname oldskool
1616
is_null <- function() {
17-
warning("is_null is deprecated. Please use `expect_null` instead.",
18-
call. = FALSE)
17+
warning(
18+
"is_null is deprecated. Please use `expect_null` instead.",
19+
call. = FALSE
20+
)
1921
function(x) expect_null(x)
2022
}
2123

@@ -124,8 +126,10 @@ matches <- function(regexp, all = TRUE, ...) {
124126
#' @export
125127
#' @param amount maximum duration in seconds
126128
takes_less_than <- function(amount) {
127-
warning("takes_less_than() is deprecated because it is stochastic and unreliable",
128-
call. = FALSE)
129+
warning(
130+
"takes_less_than() is deprecated because it is stochastic and unreliable",
131+
call. = FALSE
132+
)
129133

130134
function(expr) {
131135
duration <- system.time(force(expr))["elapsed"]

0 commit comments

Comments
 (0)