Skip to content

Commit 16c23f1

Browse files
committed
Remove more by hand
1 parent 8ad4f1c commit 16c23f1

File tree

9 files changed

+35
-42
lines changed

9 files changed

+35
-42
lines changed

R/expect-inheritance.R

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,21 @@ expect_s7_class <- function(object, class) {
116116

117117
if (!S7::S7_inherits(object)) {
118118
fail(sprintf("%s is not an S7 object", act$lab))
119-
} else {
120-
if (!S7::S7_inherits(object, class)) {
121-
obj_class <- setdiff(base::class(object), "S7_object")
122-
class_desc <- paste0("<", obj_class, ">", collapse = "/")
123-
msg <- sprintf(
124-
"%s inherits from %s not <%s>.",
125-
act$lab,
126-
class_desc,
127-
attr(class, "name", TRUE)
128-
)
129-
fail(msg)
130-
}
131-
succeed()
132119
}
133120

134-
invisible(act$val)
121+
if (!S7::S7_inherits(object, class)) {
122+
obj_class <- setdiff(base::class(object), "S7_object")
123+
class_desc <- paste0("<", obj_class, ">", collapse = "/")
124+
msg <- sprintf(
125+
"%s inherits from %s not <%s>.",
126+
act$lab,
127+
class_desc,
128+
attr(class, "name", TRUE)
129+
)
130+
fail(msg)
131+
}
132+
133+
pass(act$val)
135134
}
136135

137136
#' @export
@@ -146,7 +145,6 @@ expect_s4_class <- function(object, class) {
146145
msg <- sprintf("%s is an S4 object", act$lab)
147146
fail(msg)
148147
}
149-
succeed()
150148
} else if (is.character(class)) {
151149
if (!isS4(act$val)) {
152150
fail(sprintf("%s is not an S4 object", act$lab))
@@ -160,13 +158,12 @@ expect_s4_class <- function(object, class) {
160158
)
161159
fail(msg)
162160
}
163-
succeed()
164161
}
165162
} else {
166163
abort("`class` must be a NA or a character vector")
167164
}
168165

169-
invisible(act$val)
166+
pass(act$val)
170167
}
171168

172169
isS3 <- function(x) is.object(x) && !isS4(x)

R/expect-known.R

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ compare_file <- function(path, lines, ..., update = TRUE, info = NULL) {
7777
if (!file.exists(path)) {
7878
warning("Creating reference output", call. = FALSE)
7979
brio::write_lines(lines, path)
80-
succeed()
81-
return()
80+
return(pass(NULL))
8281
}
8382

8483
old_lines <- brio::read_lines(path)
@@ -107,7 +106,7 @@ compare_file <- function(path, lines, ..., update = TRUE, info = NULL) {
107106
)
108107
fail(msg, info = info, trace_env = caller_env())
109108
}
110-
succeed()
109+
pass(NULL)
111110
}
112111

113112
#' Expectations: is the output or the value equal to a known good value?
@@ -170,7 +169,6 @@ expect_known_value <- function(
170169
if (!file.exists(file)) {
171170
warning("Creating reference value", call. = FALSE)
172171
saveRDS(object, file, version = version)
173-
succeed()
174172
} else {
175173
ref_val <- readRDS(file)
176174
comp <- compare(act$val, ref_val, ...)
@@ -187,10 +185,9 @@ expect_known_value <- function(
187185
)
188186
fail(msg, info = info)
189187
}
190-
succeed()
191188
}
192189

193-
invisible(act$value)
190+
pass(act$value)
194191
}
195192

196193
#' @export
@@ -225,16 +222,14 @@ expect_known_hash <- function(object, hash = NULL) {
225222

226223
if (is.null(hash)) {
227224
warning(paste0("No recorded hash: use ", substr(act_hash, 1, 10)))
228-
succeed()
229225
} else {
230226
if (hash != act_hash) {
231227
msg <- sprintf("Value hashes to %s, not %s", act_hash, hash)
232228
fail(msg)
233229
}
234-
succeed()
235230
}
236231

237-
invisible(act$value)
232+
pass(act$value)
238233
}
239234

240235
all_utf8 <- function(x) {

R/expect-output.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,20 @@ expect_output <- function(
3737
msg <- sprintf("%s produced output.\n%s", act$lab, encodeString(act$cap))
3838
fail(msg, info = info)
3939
}
40-
succeed()
4140
} else if (is.null(regexp) || identical(act$cap, "")) {
4241
if (identical(act$cap, "")) {
4342
msg <- sprintf("%s produced no output", act$lab)
4443
fail(msg, info = info)
4544
}
46-
succeed()
4745
} else {
48-
expect_match(act$cap, enc2native(regexp), ..., info = info, label = act$lab)
46+
return(expect_match(
47+
act$cap,
48+
enc2native(regexp),
49+
...,
50+
info = info,
51+
label = act$lab
52+
))
4953
}
5054

51-
invisible(act$val)
55+
pass(act$val)
5256
}

R/expect-setequal.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,9 @@ expect_contains <- function(object, expected) {
144144
paste0("* Missing from `actual`: ", values(exp$val[exp_miss]), "\n"),
145145
paste0("* Present in `actual`: ", values(act$val), "\n")
146146
))
147-
} else {
148-
succeed()
149147
}
150148

151-
invisible(act$val)
149+
pass(act$val)
152150
}
153151

154152
#' @export
@@ -172,9 +170,7 @@ expect_in <- function(object, expected) {
172170
paste0("* Missing from `expected`: ", values(act$val[act_miss]), "\n"),
173171
paste0("* Present in `expected`: ", values(exp$val), "\n")
174172
))
175-
} else {
176-
succeed()
177173
}
178174

179-
invisible(act$val)
175+
pass(act$val)
180176
}

R/expect-vector.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ expect_vector <- function(object, ptype = NULL, size = NULL) {
2929
if (!is.null(message)) {
3030
fail(message)
3131
}
32-
succeed()
32+
pass(act$val)
3333
}

R/old-school.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ takes_less_than <- function(amount) {
113113
msg <- paste0("took ", duration, " seconds, which is more than ", amount)
114114
fail(msg)
115115
}
116-
succeed()
116+
pass(expr)
117117
}
118118
}
119119

@@ -135,7 +135,7 @@ not <- function(f) {
135135
msg <- paste0("NOT(", expt$message, ")")
136136
fail(msg, srcref = expt$srcref)
137137
}
138-
succeed()
138+
pass(NULL)
139139
}
140140

141141
function(...) {

R/snapshot-file.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ expect_snapshot_file <- function(
146146
)
147147
fail(msg)
148148
}
149-
succeed()
149+
pass(NULL)
150150
}
151151

152152
#' @rdname expect_snapshot_file

R/snapshot.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ expect_snapshot_helper <- function(
335335
)
336336
fail(msg, trace_env = trace_env)
337337
}
338-
succeed()
338+
339+
pass(NULL)
339340
}
340341

341342
snapshot_accept_hint <- function(variant, file, reset_output = TRUE) {

R/test-compiled-code.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ expect_cpp_tests_pass <- function(package) {
2626
msg <- paste("C++ unit tests:", info, sep = "\n")
2727
fail(msg)
2828
}
29-
succeed()
29+
pass(NULL)
3030
}
3131

3232
#' Do C++ tests past?

0 commit comments

Comments
 (0)