P: Manually Create a Test Descriptor Prototype#

Description#

Allows for formulating expectations like ‘the desired outcome is c(1, 2, 3), with a warning’ or ‘an error should occur’.

Usage#

P(
  value = NULL,
  error = NULL,
  warning = NULL,
  message = NULL,
  stdout = NULL,
  stderr = NULL,
  value_comparer = NULL,
  sides_comparer = NULL
)

Arguments#

value

object (may of course be equipped with attributes)

error, warning, message

conditions expected to occur, see stop, warning, and message

stdout, stderr

character data expected on stdout and stderr, respectively

value_comparer, sides_comparer

optional two-argument functions which may be used to override the default comparers used by E

Details#

If error, warning, message, stdout, or stderr are NULL, then no side effects of particular kinds are included in the output.

The semantics is solely defined by the sides_comparer. E by default uses sides_similar (see its description therein), although you are free to override it manually or via a global option.

Value#

A list of class realtest_descriptor with named components:

  • value,

  • sides (optional) – a list with named elements error, warnings, messages, stdout, and stderr; those which are missing are assumed to be equal to NULL,

  • value_comparer (optional) – a function object,

  • sides_comparer (optional) – a function object.

Other functions are free to add more named components, and do with them whatever they please.

Author(s)#

Marek Gagolewski

See Also#

The official online manual of realtest at https://realtest.gagolewski.com/

Related functions: E, R

Examples#

# the desired outcome is c(1L, 2L, 3L):
P(1:3)
## $value
## [1] 1 2 3
## 
## attr(,"class")
## [1] "realtest_descriptor" "realtest"
# expecting c(1L, 2L, 3L), with a warning:
P(1:3, warning=TRUE)
## $value
## [1] 1 2 3
## 
## $sides
## $sides$warning
## [1] TRUE
## 
## 
## attr(,"class")
## [1] "realtest_descriptor" "realtest"
# note, however, that it is the sides_comparer that defines the semantics