waldo/ 0000755 0001762 0000144 00000000000 14120163722 011356 5 ustar ligges users waldo/NAMESPACE 0000644 0001762 0000144 00000001235 14120157774 012610 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,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 00000000045 13637650412 012373 0 ustar ligges users YEAR: 2020
COPYRIGHT HOLDER: RStudio
waldo/README.md 0000644 0001762 0000144 00000010037 14107730523 012642 0 ustar ligges users
# waldo
[](https://codecov.io/gh/r-lib/waldo?branch=master)
[](https://github.com/r-lib/waldo/actions)
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:
- Addition
``` asciicast
compare(c("a", "b", "c"), c("a", "b"))
```
- Deletion
``` asciicast
compare(c("a", "b"), c("a", "b", "c"))
```
- Change
``` asciicast
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.
``` asciicast
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:
``` asciicast
compare(letters[1:5], letters[1:6])
```
- If there’s not enough room for that, the two vectors are shown
side-by-side:
``` asciicast
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:
``` asciicast
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:
``` asciicast
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.
``` asciicast
df1 <- data.frame(x = 1:3, y = 3:1)
df2 <- tibble::tibble(rev(df1))
compare(df1, df2)
```
- Recursion can be arbitrarily deep:
``` asciicast
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 14120161300 012117 5 ustar ligges users waldo/man/waldo-package.Rd 0000644 0001762 0000144 00000001446 14073210415 015123 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@rstudio.com}
Other contributors:
\itemize{
\item RStudio [copyright holder]
}
}
\keyword{internal}
waldo/man/compare_proxy.Rd 0000644 0001762 0000144 00000002477 14075620577 015340 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} attribute is set to \code{NULL}. This is
an external pointer that is used for performance optimisation, and
doesn'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://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.text_format}
}
}
waldo/man/figures/ 0000755 0001762 0000144 00000000000 14120161300 013563 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 00000003612 14107730523 020236 0 ustar ligges users