expect_equal_with_diff: Test for equality with explicit difference

View source: R/expectations.R

expect_equal_with_diffR Documentation

Test for equality with explicit difference

Description

Test for equality with explicit difference

Usage

expect_equal_with_diff(
  current,
  target,
  tol = sqrt(.Machine$double.eps),
  mode = getOption("diffobj.mode", "unified"),
  format = getOption("diffobj.format", "ansi256"),
  ...
)

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

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)

mode

[character] Comparison mode passed to diffPrint, defaults to using the “diffobj.mode” global option value with “unified” as fallback if no such option is set

format

[character] Comparison mode passed to diffPrint, defaults to to using the “diffobj.format” global option value with “ansi256” as fallback if no such option is set

...

Passed to all.equal

Details

expect_equivalent_with_diff calls expect_equal_with_diff 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

Examples

library(tinytest)
using(ttdo)
expect_equal_with_diff(1 + 1, 2)		# TRUE
expect_equal_with_diff(1 - 1, 2)		# FALSE
expect_equivalent_with_diff(2, c(x=2))	# TRUE
expect_equivalent_with_diff(2, c(x=2))	# TRUE

ttdo documentation built on March 7, 2023, 5:27 p.m.