expect_equal_xl: Extensions of equality tests for tinytest

View source: R/expectations_xl.R

expect_equal_xlR Documentation

Extensions of equality tests for tinytest

Description

Building on the tinytest functions for testing equality with optional enhanced object diffing and additional test feedback through addtional attributes.

Usage

expect_equal_xl(
  current,
  target,
  useDiffObj = TRUE,
  tol = sqrt(.Machine$double.eps),
  info = NA_character_,
  mode = getOption("diffobj.mode", "unified"),
  format = getOption("diffobj.format", "ansi256"),
  ...
)

expect_identical_xl(
  current,
  target,
  useDiffObj = TRUE,
  info = NA_character_,
  mode = getOption("diffobj.mode", "unified"),
  format = getOption("diffobj.format", "ansi256"),
  ...
)

expect_equivalent_xl(
  current,
  target,
  useDiffObj = TRUE,
  tol = sqrt(.Machine$double.eps),
  info = NA_character_,
  mode = getOption("diffobj.mode", "unified"),
  format = getOption("diffobj.format", "ansi256"),
  ...
)

Arguments

current

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

target

[R object or expression] Expected outcome

useDiffObj

[logical] Whether you should use diffPrint for the diff field in the resulting tinytest object

tol

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

info

An additional attribute to pass around with the tinytest object

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 and returned as a test attributes

Details

While tinytest does now support the passing of additional information with the info field in its tests, they are not yet supported in the as.data.frame.tinytests method.

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_xl(1 + 1, 2, score = 3) # TRUE
expect_equal_xl(1 - 1, 2, name = "check 1-1==2", score = 1, totalpts = 2) # FALSE

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