@@ -440,10 +440,10 @@ compare_condition_3e <- function(cond_type, cond_class, cond, lab, expected) {
440440 if (expected ) {
441441 if (is.null(cond )) {
442442 if (is.null(cond_class )) {
443- sprintf(" %s did not throw the expected %s." , lab , cond_type )
443+ sprintf(" Expected %s to throw a %s." , lab , cond_type )
444444 } else {
445445 sprintf(
446- " %s did not throw a %s with class <%s>." ,
446+ " Expected %s to throw a %s with class <%s>." ,
447447 lab ,
448448 cond_type ,
449449 cond_class
@@ -454,12 +454,9 @@ compare_condition_3e <- function(cond_type, cond_class, cond, lab, expected) {
454454 }
455455 } else {
456456 if (! is.null(cond )) {
457- sprintf(
458- " %s threw an unexpected %s.\n Message: %s\n Class: %s" ,
459- lab ,
460- cond_type ,
461- cnd_message(cond ),
462- paste(class(cond ), collapse = " /" )
457+ c(
458+ sprintf(" Expected %s not to throw any %ss." , lab , cond_type ),
459+ actual_condition(cond )
463460 )
464461 } else {
465462 NULL
@@ -493,7 +490,7 @@ compare_condition_2e <- function(
493490
494491 # Otherwise we're definitely expecting a condition
495492 if (is.null(cond )) {
496- return (sprintf(" %s did not throw an %s." , lab , cond_type ))
493+ return (sprintf(" Expected %s to throw a %s." , lab , cond_type ))
497494 }
498495
499496 matches <- cnd_matches_2e(cond , class , regexp , inherit , ... )
@@ -562,15 +559,20 @@ compare_messages <- function(
562559 # Expecting no messages
563560 if (identical(regexp , NA )) {
564561 if (length(messages ) > 0 ) {
565- return (sprintf(" %s generated %s:\n %s" , lab , cond_type , bullets ))
562+ return (sprintf(
563+ " Expected %s not to generate %s.\n Actually generated:\n %s" ,
564+ lab ,
565+ cond_type ,
566+ bullets
567+ ))
566568 } else {
567569 return ()
568570 }
569571 }
570572
571573 # Otherwise we're definitely expecting messages
572574 if (length(messages ) == 0 ) {
573- return (sprintf(" %s did not produce any %s." , lab , cond_type ))
575+ return (sprintf(" Expected %s to produce %s." , lab , cond_type ))
574576 }
575577
576578 if (is.null(regexp )) {
@@ -625,3 +627,12 @@ check_condition_dots <- function(
625627 call = error_call
626628 )
627629}
630+
631+ actual_condition <- function (cond ) {
632+ paste0(
633+ " Actually got a <" ,
634+ class(cond )[[1 ]],
635+ " > with message:\n " ,
636+ indent_lines(cnd_message(cond ))
637+ )
638+ }
0 commit comments