Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automagic diffs for ==, etc. #23

Open
lentinj opened this issue Aug 2, 2024 · 1 comment
Open

Automagic diffs for ==, etc. #23

lentinj opened this issue Aug 2, 2024 · 1 comment

Comments

@lentinj
Copy link
Contributor

lentinj commented Aug 2, 2024

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

  • Implicitly do all(x == y) (possibly this is something ok() should be doing anyway, and accepting all(isTRUE(result)) as success)
  • Generate useful failure output by evaluating each half of the == on it's own, in the appropriate environment
@lentinj
Copy link
Contributor Author

lentinj commented Aug 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant