ravingmantis / unittest

Unit testing for R
4 stars 1 forks source link

Automagic diffs for ``==``, etc. #23

Open lentinj opened 3 months ago

lentinj commented 3 months ago

When the unevaluated call to ok is to == (or another known function), redirect it to a ut_cmp_eq() that can:

lentinj commented 3 months ago

For this to work we'd need some kind of ut_cmp_eq() to pass through to, e.g:

ut_cmp_eq <- function(a, b) unittest:::cmp_inner(
    a, b,
    comparison_fn = function(a, b) all(a == b),
    filter = function (x) writeLines(paste0("[", seq_along(x), "]", format(x))),
    context_lines = 1e8)
ut_cmp_eq(1:5, c(1, 4, 2, 9, 444))
ut_cmp_eq(1:5, c(1:3, 99, 5))

The formatting here is okay, but not sure it'd survive more complex objects.