tinytest (version 1.1.0)

expect_equal: Express expectations

Description

Express expectations

Usage

expect_equal(current, target, tol = sqrt(.Machine$double.eps),
  info = NA_character_, ...)

expect_identical(current, target, info = NA_character_)

expect_equivalent(current, target, tol = sqrt(.Machine$double.eps), info = NA_character_, ...)

expect_true(current, info = NA_character_)

expect_false(current, info = NA_character_)

expect_silent(current, quiet = TRUE, info = NA_character_)

expect_null(current, info = NA_character_)

expect_error(current, pattern = ".*", info = NA_character_)

expect_warning(current, pattern = ".*", info = NA_character_)

expect_message(current, pattern = ".*", info = NA_character_)

Arguments

current

[R object or expression] Outcome or expression under scrutiny.

target

[R object or expression] Expected outcome

tol

[numeric] Test equality to machine rounding. Passed to all.equal (tolerance)

info

[character] scalar. Optional user-defined message. Must be a single character string. Multiline comments may be separated by "\n".

...

Passed to all.equal

quiet

[logical] suppress output printed by the current expression (see examples)

pattern

[character] A regular expression to match the message.

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

More information and examples

  • An overview of tinytest can be found in vignette("using_tinytest").

  • Examples of how tinytest is used in practice can be found in vignette("tinytest_examples")

Details

expect_equivalent calls expect_equal with the extra arguments check.attributes=FALSE and use.names=FALSE

expect_silent fails when an error or warning is thrown.

See Also

Other test-functions: ignore

Examples

Run this code
# NOT RUN {
expect_equal(1 + 1, 2)       # TRUE
expect_equal(1 - 1, 2)       # FALSE
expect_equivalent(2, c(x=2)) # TRUE
expect_equal(2, c(x=2))      # FALSE


expect_silent(1+1)           # TRUE
expect_silent(1+"a")         # FALSE
expect_silent(print("hihi")) # TRUE, nothing goes to screen
expect_silent(print("hihi", quiet=FALSE)) # FALSE, and printed

# }

Run the code above in your browser using DataLab