Skip to content

Commit daa3e64

Browse files
committed
Update expect_compare_ helper
1 parent 12f12f0 commit daa3e64

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

R/expect-comparison.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
#' @name comparison-expectations
2020
NULL
2121

22-
expect_compare <- function(operator = c("<", "<=", ">", ">="), act, exp) {
22+
expect_compare_ <- function(
23+
operator = c("<", "<=", ">", ">="),
24+
act,
25+
exp,
26+
trace_env = caller_env()
27+
) {
2328
operator <- match.arg(operator)
2429
op <- match.fun(operator)
2530

@@ -42,7 +47,7 @@ expect_compare <- function(operator = c("<", "<=", ">", ">="), act, exp) {
4247
exp$lab,
4348
act$val - exp$val
4449
)
45-
return(fail(msg, trace_env = caller_env()))
50+
return(fail(msg, trace_env = trace_env))
4651
}
4752
pass(act$val)
4853
}
@@ -52,7 +57,7 @@ expect_lt <- function(object, expected, label = NULL, expected.label = NULL) {
5257
act <- quasi_label(enquo(object), label, arg = "object")
5358
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
5459

55-
expect_compare("<", act, exp)
60+
expect_compare_("<", act, exp)
5661
}
5762

5863
#' @export
@@ -61,7 +66,7 @@ expect_lte <- function(object, expected, label = NULL, expected.label = NULL) {
6166
act <- quasi_label(enquo(object), label, arg = "object")
6267
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
6368

64-
expect_compare("<=", act, exp)
69+
expect_compare_("<=", act, exp)
6570
}
6671

6772
#' @export
@@ -70,7 +75,7 @@ expect_gt <- function(object, expected, label = NULL, expected.label = NULL) {
7075
act <- quasi_label(enquo(object), label, arg = "object")
7176
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
7277

73-
expect_compare(">", act, exp)
78+
expect_compare_(">", act, exp)
7479
}
7580

7681
#' @export
@@ -79,7 +84,7 @@ expect_gte <- function(object, expected, label = NULL, expected.label = NULL) {
7984
act <- quasi_label(enquo(object), label, arg = "object")
8085
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
8186

82-
expect_compare(">=", act, exp)
87+
expect_compare_(">=", act, exp)
8388
}
8489

8590

0 commit comments

Comments
 (0)