all.equal.condition: Compare Conditions

View source: R/conditions.R

all.equal.conditionR Documentation

Compare Conditions

Description

Tests that issue warnings or 'stop' produce condition objects. The functions documented here are specialized versions of all.equal designed specifically to compare conditions and condition lists produced during unitizer test evaluations. conditionList objects are lists of conditions that come about when test expressions emit multiple conditions (e.g. more than one warning).

Usage

## S4 method for signature 'conditionList,ANY'
all.equal(target, current, ...)

## S3 method for class 'equal.conditionList'
all(target, current, ...)

## S3 method for class 'equal.condition'
all(target, current, ...)

Arguments

target

the list of conditions that we are matching against

current

the list of conditions we are checking

...

provided for compatibility with generic

Details

condition objects produced by tests have one additional attributed “printed” which disambiguates whether a condition was the result of the test expression, or the print / show method used to display it to screen.

For conditionList objects, these methods only return TRUE if all conditions are pairwise all.equal.

Value

TRUE if the (lists of) conditions are equivalent, a character vector explaining why they are not otherwise

Examples

cond.1 <- simpleWarning('hello world')
cond.2 <- simpleError('hello world')
cond.3 <- simpleError('goodbye world')
all.equal(cond.1, cond.1)
all.equal(cond.1, cond.2)
all.equal(cond.2, cond.3)
## Normally you would never actually create a `conditionList` yourself; these
## are automatically generated by `unitizer` for review at the `unitizer`
## prompt
all.equal(
  conditionList(.items=list(cond.1, cond.2)),
  conditionList(.items=list(cond.1, cond.3))
)

unitizer documentation built on Oct. 8, 2023, 5:06 p.m.