I can make a helper to compare environments, e.g.:
cmp_environment <- function (a, b) {
a <- as.list(a)
b <- as.list(b)
if (length(a) == 0) {
# Can't order an empty list
ut_cmp_identical(a, b)
} else {
ut_cmp_identical(a[order(names(a))], b[order(names(b))])
}
}
ok(cmp_environment( as.environment(list(a=1, b=2)), as.environment(list(a=1, b=2)) ) )
...but then the diff output doesn't include the previous expressions as.environment(list(a=1, b=2)), just +++ a[order(names(a))], which doesn't help. Need to either:-
Tell cmp_inner that we're a helper function, and the -1 should be upped to -2
Supply a "comparison filter" to convert to (ordered) list (which makes the helper shorter, but doesn't really solve the problem)
Expose cmp_inner, allow us to write our own comparison function.
I can make a helper to compare environments, e.g.:
...but then the diff output doesn't include the previous expressions
as.environment(list(a=1, b=2))
, just+++ a[order(names(a))]
, which doesn't help. Need to either:-cmp_inner
that we're a helper function, and the-1
should be upped to-2
cmp_inner
, allow us to write our own comparison function.