Skip to content

Commit b930131

Browse files
committed
Some basic docs
1 parent b1fdcd6 commit b930131

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export(equals_reference)
7979
export(evaluate_promise)
8080
export(exp_signal)
8181
export(expect)
82+
export(expect_all_equal)
83+
export(expect_all_false)
84+
export(expect_all_true)
8285
export(expect_condition)
8386
export(expect_contains)
8487
export(expect_cpp_tests_pass)

R/expect-all.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#' Expect that all values in a vector are the same
2+
#'
3+
#' These expectations are similar to `expect_true(all(x == "x"))`,
4+
#' `expect_true(all(x))` and `expect_true(all(!x))` but give more informative
5+
#' failure messages if the expectations are not met.
6+
#'
7+
#' @inheritParams expect_equal
8+
#' @export
9+
#' @examples
10+
#' x1 <- c(1, 1, 1, 1, 1, 1)
11+
#' expect_all_equal(x1, 1)
12+
#'
13+
#' x2 <- c(1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2)
14+
#' show_failure(expect_all_equal(x2, 1))
15+
#'
16+
#' # expect_all_true() and expect_all_false() are helpers for common cases
17+
#' show_failure(expect_all_true(rpois(100, 10) < 20))
18+
#' show_failure(expect_all_false(rpois(100, 10) > 20))
119
expect_all_equal <- function(object, expected) {
220
act <- quasi_label(enquo(object))
321
exp <- quasi_label(enquo(expected))
@@ -6,6 +24,8 @@ expect_all_equal <- function(object, expected) {
624
invisible(act$val)
725
}
826

27+
#' @export
28+
#' @rdname expect_all_equal
929
expect_all_true <- function(object) {
1030
act <- quasi_label(enquo(object))
1131
exp <- labelled_value(TRUE, "TRUE")
@@ -14,6 +34,8 @@ expect_all_true <- function(object) {
1434
invisible(act$val)
1535
}
1636

37+
#' @export
38+
#' @rdname expect_all_equal
1739
expect_all_false <- function(object) {
1840
act <- quasi_label(enquo(object))
1941
exp <- labelled_value(FALSE, "FALSE")

man/expect_all_equal.Rd

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)