shorthands: Shorthands for 'testthat' expectations

Description Usage Arguments Details

Description

These operators are powered by the package *doubt* and make testing very compact. * '?~' is 'testthat::expect_true()' * '?e~' is 'testthat::expect_equal()' * '?i~' is 'testthat::expect_identical' These operators have various intteresting properties * They support the unary notation, which allows us to write '?~ is.numeric(2)' * They support infix notation AND left hand side n-ary notation so that you choose between 'tan(pi/4) ?e~ 1', or, '?e~ tan(pi/4) ? 1' * They have the lowest precedence, which means for instance that '2 ?i~ 1 + 1' doesn't need brackets.

This is an infix version of 'testthat::test_that()', compact and handy to highlight the description and spare brackets.

Usage

1
2
3
4
5
6
7
8
9
desc %?% code

"?~"(object, info = NULL, label = NULL)

"?e~"(object, expected, ..., info = NULL, label = NULL,
  expected.label = NULL)

"?i~"(object, expected, info = NULL, label = NULL,
  expected.label = NULL, ...)

Arguments

object

Computation and value to compare it to.

Both arguments supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details.

info

Extra information to be included in the message. This argument is soft-deprecated and should not be used in new code. Instead see alternatives in quasi_label.

label

Used to customise failure messages. For expert use only.

expected

Computation and value to compare it to.

Both arguments supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details.

...

For expect_equal() and expect_equivalent(), passed on compare(), for expect_identical() passed on to identical(). Used to control the details of the comparison.

expected.label

Used to customise failure messages. For expert use only.

Details

rather than 'TRUE ?e~ is.numeric(2)'.


moodymudskipper/dubioustests documentation built on Nov. 4, 2019, 7:29 p.m.