Skip to content

Commit a3cb74d

Browse files
authored
Ensure that expect_no_error() and friends pass when appropriate (#2046)
Fixes #2037
1 parent 24ff6c0 commit a3cb74d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

R/expect-no-condition.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ expect_no_ <- function(base_class,
9696

9797
capture <- function(code) {
9898
try_fetch(
99-
code,
99+
{
100+
code
101+
NULL
102+
},
100103
!!base_class := function(cnd) {
101104
if (!matcher(cnd)) {
102105
return(zap())

tests/testthat/test-expect-no-condition.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ test_that("expect_no_* conditions behave as expected", {
1313
})
1414

1515
test_that("expect_no_* pass with pure code", {
16-
expect_no_error(1)
17-
expect_no_warning(1)
18-
expect_no_message(1)
19-
expect_no_condition(1)
16+
expect_success(out <- expect_no_error(1))
17+
expect_equal(out, 1)
18+
19+
expect_success(expect_no_warning(1))
20+
expect_success(expect_no_message(1))
21+
expect_success(expect_no_condition(1))
2022
})
2123

2224
test_that("expect_no_* don't emit success when they fail", {

0 commit comments

Comments
 (0)