forked from r-lib/testthat
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kirill Müller
committed
Oct 3, 2015
1 parent
3ecdae7
commit 5c9eec7
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#' Expect that code succeeds. | ||
#' | ||
#' Use it when failure should not abort the current test. | ||
#' | ||
#' @param expr Expression to evaluate | ||
#' @export | ||
#' @examples | ||
#' expect_success(print("Hi!")) | ||
#' \dontrun{ | ||
#' expect_success(stop("What?")) | ||
#' } | ||
expect_success <- function(expr) { | ||
label <- find_expr("expr") | ||
out <- evaluate_promise(expr) | ||
|
||
res <- try(force(expr), silent = TRUE) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
success <- !inherits(res, "try-error") | ||
|
||
expect( | ||
success, | ||
paste(label, "raised an error:", as.character(res)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
% Generated by roxygen2 (4.1.1): do not edit by hand | ||
% Please edit documentation in R/expectations-success.R | ||
\name{expect_success} | ||
\alias{expect_success} | ||
\title{Expect that code succeeds.} | ||
\usage{ | ||
expect_success(expr) | ||
} | ||
\arguments{ | ||
\item{expr}{Expression to evaluate} | ||
} | ||
\description{ | ||
Use it when failure should not abort the current test. | ||
} | ||
\examples{ | ||
expect_success(print("Hi!")) | ||
\dontrun{ | ||
expect_success(stop("What?")) | ||
} | ||
} | ||
|
I missed r-lib#219, the new function seems largely unnecessary. I'd rather change it to a simple forwarder, or remove it altogether.