expect_equal {tinytest}R Documentation

Express expectations

Description

Express expectations

Usage

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

expect_identical(current, target)

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

expect_true(current)

expect_false(current)

expect_error(current, pattern = ".*")

expect_warning(current, pattern = ".*")

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)

...

Passed to all.equal

pattern

[character] A regular expression to match the message.

Details

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

Value

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

Note

Each expect_haha function can also be called as checkHaha. Although the interface is not entirely the same, it is expected that this makes migration from the RUnit framework a little easier, for those who wish to do so.

See Also

Other test-functions: ignore

Examples

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


[Package tinytest version 0.9.4 Index]