waldo/ 0000755 0001762 0000144 00000000000 14520717652 011371 5 ustar ligges users waldo/NAMESPACE 0000644 0001762 0000144 00000001275 14415265275 012617 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(compare_proxy,Descriptor)
S3method(compare_proxy,EnumDescriptor)
S3method(compare_proxy,EnumValueDescriptor)
S3method(compare_proxy,FieldDescriptor)
S3method(compare_proxy,FileDescriptor)
S3method(compare_proxy,Message)
S3method(compare_proxy,MethodDescriptor)
S3method(compare_proxy,POSIXlt)
S3method(compare_proxy,ServiceDescriptor)
S3method(compare_proxy,data.table)
S3method(compare_proxy,default)
S3method(compare_proxy,xml_node)
S3method(print,waldo_compare)
export(compare)
export(compare_proxy)
import(rlang)
importFrom(glue,glue)
importFrom(methods,.hasSlot)
importFrom(methods,is)
importFrom(methods,slot)
importFrom(methods,slotNames)
waldo/LICENSE 0000644 0001762 0000144 00000000053 14520545026 012366 0 ustar ligges users YEAR: 2023
COPYRIGHT HOLDER: waldo authors
waldo/README.md 0000644 0001762 0000144 00000007546 14520545026 012656 0 ustar ligges users
# waldo
[](https://app.codecov.io/gh/r-lib/waldo?branch=main)
[](https://github.com/r-lib/waldo/actions/workflows/R-CMD-check.yaml)
The goal of waldo is to find and concisely describe the difference
between a pair of R objects, with the primary goal of making it easier
to figure out what’s gone wrong in your unit tests.
`waldo::compare()` is inspired by `all.equal()`, but takes additional
care to generate actionable insights by:
- Ordering the differences from most important to least important.
- Displaying the values of atomic vectors that are actually different.
- Carefully using colour to emphasise changes (while still being
readable when colour isn’t available).
- Using R code (not a text description) to show where differences arise.
- Where possible, comparing elements by name, rather than by position.
- Erring on the side of producing too much output, rather than too
little.
## Installation
You can install the released version of waldo from
[CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("waldo")
```
## Comparisons
``` r
library(waldo)
```
When comparing atomic vectors, `compare()` produces diffs (thanks to
[diffobj](https://github.com/brodieG/diffobj)) that highlight additions,
deletions, and changes, along with a little context:
- Deletion
``` r
compare(c("a", "b", "c"), c("a", "b"))
```
- Addition
``` r
compare(c("a", "b"), c("a", "b", "c"))
```
- Change
``` r
compare(c("a", "b", "c"), c("a", "B", "c"))
```
- Long vectors with short differences only show local context around
changes, not everything that’s the same.
``` r
compare(c("X", letters), c(letters, "X"))
```
Depending on the relative size of the differences and the width of your
console you’ll get one of three displays:
- The default display is to show the vectors one atop the other:
``` r
compare(letters[1:5], letters[1:6])
```
- If there’s not enough room for that, the two vectors are shown
side-by-side:
``` r
options(width = 20)
compare(letters[1:5], letters[1:6])
```
- And if there’s still not enough room for side-by-side, the each
element is given its own line:
``` r
options(width = 10)
compare(letters[1:5], letters[1:6])
```
When comparing more complex objects, waldo creates an executable code
path telling you where the differences lie:
- Unnamed lists are compared by position:
``` r
compare(list(factor("x")), list(1L))
```
- Named lists, including data frames, are compared by name. For example,
note that the following comparison reports a difference in the class
and names, but not the values of the columns.
``` r
df1 <- data.frame(x = 1:3, y = 3:1)
df2 <- tibble::tibble(rev(df1))
compare(df1, df2)
```
- Recursion can be arbitrarily deep:
``` r
x <- list(a = list(b = list(c = list(structure(1, e = 1)))))
y <- list(a = list(b = list(c = list(structure(1, e = "a")))))
compare(x, y)
```
waldo/man/ 0000755 0001762 0000144 00000000000 14520545653 012144 5 ustar ligges users waldo/man/waldo-package.Rd 0000644 0001762 0000144 00000001452 14520545026 015126 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/waldo-package.R
\docType{package}
\name{waldo-package}
\alias{waldo}
\alias{waldo-package}
\title{waldo: Find Differences Between R Objects}
\description{
Compare complex R objects and reveal the key differences. Designed particularly for use in testing packages where being able to quickly isolate key differences makes understanding test failures much easier.
}
\seealso{
Useful links:
\itemize{
\item \url{https://waldo.r-lib.org}
\item \url{https://github.com/r-lib/waldo}
\item Report bugs at \url{https://github.com/r-lib/waldo/issues}
}
}
\author{
\strong{Maintainer}: Hadley Wickham \email{hadley@posit.co}
Other contributors:
\itemize{
\item Posit Software, PBC [copyright holder, funder]
}
}
\keyword{internal}
waldo/man/compare_proxy.Rd 0000644 0001762 0000144 00000002453 14416245254 015324 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/proxy.R
\name{compare_proxy}
\alias{compare_proxy}
\title{Proxy for waldo comparison}
\usage{
compare_proxy(x, path = "x")
}
\arguments{
\item{x}{An object.}
\item{path}{Path}
}
\value{
A list with two components:
\itemize{
\item \code{object}: the modified object
\item \code{path}: an updated path showing what modification was applied
}
}
\description{
Use this generic to override waldo's default comparison if you need to
override the defaults (typically because your object stores data in an
external pointer).
waldo comes with methods for a few common cases:
\itemize{
\item data.table: the \code{.internal.selfref} and \code{index} attributes
are set to \code{NULL}. Both attributes are used for performance optimisation, and
don't affect the data.
\item \code{xml2::xml_node}: the underlying XML data is stored in memory in C,
behind an external pointer, so the we best can do is to convert the
object to a string.
\item Classes from the \code{RProtoBuf} package: like XML objects, these store
data in memory in C++ and only expose string names to R. Fortunately,
these have well-understood string representations that we can use for
comparisons. See
\url{https://protobuf.dev/reference/cpp/api-docs/google.protobuf.text_format/}
}
}
waldo/man/figures/ 0000755 0001762 0000144 00000000000 14520545653 013610 5 ustar ligges users waldo/man/figures/README/ 0000755 0001762 0000144 00000000000 14107730175 014541 5 ustar ligges users waldo/man/figures/README/unnamed-chunk-12.svg 0000644 0001762 0000144 00000004161 14520015300 020222 0 ustar ligges users