On Sun, Sep 14, 2008 at 03:08:57PM +0200, Carl Mäsak wrote:
> Recently, in November, we've had reason to clone the Rakudo Test.pm
> and add an implementation (viklund++) of is_deeply, for testing
> whether two arrays, pairs or hashes are deeply -- recursively --
> equivalent. The method does what you'd think it does, checks the types
> of its parameters and recurses as necessary.
> With the rich set of equality testing operators in Perl 6...
> ...and given constructs like [+] and <+>, it's actually a bit
> surprising to me that testing whether [1, [2, 3]] and [1, [2, 4]] are
> the deeply equivalent isn't more easily expressed than it is. (Or
> maybe it is easy with current constructs, and I missed it? Can't rule
> that out.)
> Couldn't an adverb to one or more of the existing equality operators
> do this nicely? Something like this:
> say [1, [2, 3]] eqv [1, [2, 4]] :deeply;
Doesn't infix:<eqv> already somewhat imply the "is deeply" semantics,
at least for arrays and hashes?
As far as current implementation status is concerned, I think
that the t/spec tests have this wrong in many cases -- they seem
to assume that infix:<eqv> tests object identity for equivalence
instead of comparing values. For example, t/spec/S29-any/eqv.t has:
ok !([1,2,3] eqv [4,5,6]), "eqv on anonymous array references (1)";
#?pugs 2 todo 'bug'
ok !([1,2,3] eqv [1,2,3]), "eqv on anonymous array references (2)";
ok !( eqv ), "eqv on anonymous array references (3)";
I think that the last two tests are incorrect, and that
[1,2,3] eqv [1,2,3] should give a True result.