Skip to content

Commit 14e37fb

Browse files
Merge branch 'main' into skip-r
2 parents 9ff94ac + d947142 commit 14e37fb

File tree

15 files changed

+39
-19
lines changed

15 files changed

+39
-19
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# testthat (development version)
22

3+
* `expect_s4_class()` now supports unquoting (@stibu81, #2064).
4+
* `it()` now finds the correct evaluation environment in more cases (@averissimo, #2085).
5+
* Fixed an issue preventing compilation from succeeding due to deprecation / removal of `std::uncaught_exception()` (@kevinushey, #2047).
6+
37
# testthat 3.2.3
48

59
* Fixed an issue where `expect_no_error(1)` was failing (#2037).

R/describe.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ it <- function(description, code = NULL) {
9494
check_string(description, allow_empty = FALSE)
9595

9696
code <- substitute(code)
97-
describe_it(description, code)
97+
describe_it(description, code, env = parent.frame())
9898
}

R/expect-inheritance.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ expect_s7_class <- function(object, class) {
125125
#' @rdname inheritance-expectations
126126
expect_s4_class <- function(object, class) {
127127
act <- quasi_label(enquo(object), arg = "object")
128-
act_val_lab <- format_class(methods::is(object))
128+
act$class <- format_class(methods::is(act$val))
129129
exp_lab <- format_class(class)
130130

131131
if (identical(class, NA)) {
@@ -139,7 +139,7 @@ expect_s4_class <- function(object, class) {
139139
} else {
140140
expect(
141141
methods::is(act$val, class),
142-
sprintf("%s inherits from %s not %s.", act$lab, act_val_lab, exp_lab)
142+
sprintf("%s inherits from %s not %s.", act$lab, act$class, exp_lab)
143143
)
144144
}
145145
} else {

R/expect-known.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,5 @@ expect_known_hash <- function(object, hash = NULL) {
215215
}
216216

217217
all_utf8 <- function(x) {
218-
! any(is.na(iconv(x, "UTF-8", "UTF-8")))
218+
!anyNA(iconv(x, "UTF-8", "UTF-8"))
219219
}

R/expect-self-test.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ new_capture("expectation_success")
1919
#' Tools for testing expectations
2020
#'
2121
#' @description
22-
#' * `expect_sucess()` and `expect_failure()` check that there's at least
22+
#' * `expect_success()` and `expect_failure()` check that there's at least
2323
#' one success or failure respectively.
2424
#' * `expect_snapshot_failure()` records the failure message so that you can
2525
#' manually check that it is informative.

R/mock2.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ local_mocked_bindings <- function(..., .package = NULL, .env = caller_env()) {
144144
local_bindings_rebind(!!!bindings, .env = test_env, .frame = .env)
145145
}
146146

147-
if (any(!bindings_found)) {
147+
if (!all(bindings_found)) {
148148
missing <- names(bindings)[!bindings_found]
149149
cli::cli_abort("Can't find binding for {.arg {missing}}")
150150
}

R/praise.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ praise <- function() {
2121
"\U0001f9ff Your tests look perfect \U0001f9ff",
2222
"\U0001f3af Your tests hit the mark \U0001f3af",
2323
"\U0001f41d Your tests are the bee's knees \U0001f41d",
24-
"\U0001f4a3 Your tests are da bomb \U0001f4a3",
25-
"\U0001f525 Your tests are lit \U0001f525"
24+
"\U0001f3b8 Your tests rock \U0001f3b8",
25+
"\U0001f44f Your tests get an ovation \U0001f44f"
2626
)
2727

2828
x <- if (cli::is_utf8_output()) c(plain, utf8) else plain

R/reporter-list.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ all_passed <- function(res) {
126126
}
127127

128128
df <- as.data.frame.testthat_results(res)
129-
sum(df$failed) == 0 && all(!df$error)
129+
sum(df$failed) == 0 && !any(df$error)
130130
}
131131

132132
any_warnings <- function(res) {

inst/include/testthat/vendor/catch.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,15 @@
379379

380380
namespace Catch {
381381

382+
inline bool HasUncaughtException()
383+
{
384+
#if __cplusplus >= 202002L
385+
return std::uncaught_exceptions() > 0;
386+
#else
387+
return std::uncaught_exception();
388+
#endif
389+
}
390+
382391
struct IConfig;
383392

384393
struct CaseSensitive { enum Choice {
@@ -8379,7 +8388,7 @@ namespace Catch {
83798388
{}
83808389

83818390
ScopedMessage::~ScopedMessage() {
8382-
if ( !std::uncaught_exception() ){
8391+
if ( !HasUncaughtException() ){
83838392
getResultCapture().popScopedMessage(m_info);
83848393
}
83858394
}
@@ -8702,7 +8711,7 @@ namespace Catch {
87028711
Section::~Section() {
87038712
if( m_sectionIncluded ) {
87048713
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
8705-
if( std::uncaught_exception() )
8714+
if( HasUncaughtException() )
87068715
getResultCapture().sectionEndedEarly( endInfo );
87078716
else
87088717
getResultCapture().sectionEnded( endInfo );

man/expect_success.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)