Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Deep CPAN distribution.

Report information
The Basics
Id: 64983
Status: resolved
Priority: 0/
Queue: Test-Deep

People
Owner: Nobody in particular
Requestors: ZERO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: [FR] Method is_not_deeply
Hi, I suggest to add a method, which will return true if two complex structures are not equal. Currently, we may find difference between the deep structures in this way: ok( eq_hash($a, $b), 'Hashes are equal'); ok( ! eq_hash($a, $c), 'Hashes are NOT equal, and it is correct'); But as you said in the pod, eq_* methods may be deprecated, and using of is_deeply() is better way. By-turn, is_deeply() isn't just a boolean function; it produce output in TAP format, so I cannot use it like not_ok(is_deeply(...)) or whatever. So, I need a function is_not_deeply(), which fails if structures are equal. Why is it necessary: for example, we test a method like clone(), which must duplicate an object fully, but must not leave references to some underlying data. Then, we make a cloned object, call some methods on it and must make sure that methods works with them own copy of data, not with parts of previous object. Method is_not_deeply() can be very useful for this purpose. Could you consider a possibility of this feature implementation, please? Thanks! -- Oleg Alistratov
Thanks for the feature request. Test::More has delegated any additional deep structure comparison to Test::Deep. I've moved this bug into their queue. They may already have a solution for you. Alternatively, perl5i provides a universal is_equal() method which can be used to compare structures as well as diff() for both arrays and hashes to display diagnostics. That can be used to construct is_not_deeply() with diagnostics better than Test::More can. http://search.cpan.org/~mschwern/perl5i-v2.4.1/lib/perl5i/Meta.pm#is_equal http://search.cpan.org/~mschwern/perl5i-v2.4.1/lib/perl5i.pm#diff() PS In the future, please use the Test-Simple bug queue. The Test-More queue exists only for historical purposes. On Fri Jan 21 09:13:24 2011, ZERO wrote: Show quoted text
> I suggest to add a method, which will return true if two complex > structures are not equal. > > Currently, we may find difference between the deep structures in this way: > > ok( eq_hash($a, $b), 'Hashes are equal'); > ok( ! eq_hash($a, $c), 'Hashes are NOT equal, and it is correct'); > > But as you said in the pod, eq_* methods may be deprecated, and using of > is_deeply() is better way. > > By-turn, is_deeply() isn't just a boolean function; it produce output in > TAP format, so I cannot use it like not_ok(is_deeply(...)) or whatever. > > So, I need a function is_not_deeply(), which fails if structures are
equal. Show quoted text
> > Why is it necessary: for example, we test a method like clone(), which > must duplicate an object fully, but must not leave references to some > underlying data. Then, we make a cloned object, call some methods on it > and must make sure that methods works with them own copy of data, not > with parts of previous object. Method is_not_deeply() can be very useful > for this purpose. > > Could you consider a possibility of this feature implementation, please? > > Thanks!
Subject: Re: [rt.cpan.org #64983] [FR] Method is_not_deeply
Date: Mon, 24 Jan 2011 14:24:31 +0200
To: bug-Test-Deep [...] rt.cpan.org
From: Oleg Alistratov <ali [...] ali.org.ua>
On 22.01.2011 05:16, Michael G Schwern via RT wrote: Show quoted text
> Test::More has delegated any additional deep structure comparison to > Test::Deep. I've moved this bug into their queue. They may already > have a solution for you.
Thank you. Test::Deep::eq_deeply() looks eminently suitable. Show quoted text
> Alternatively, perl5i provides a universal is_equal() method which can > be used to compare structures as well as diff() for both arrays and > hashes to display diagnostics. That can be used to construct > is_not_deeply() with diagnostics better than Test::More can.
Show quoted text
> PS In the future, please use the Test-Simple bug queue. The Test-More > queue exists only for historical purposes.
Sorry, I'll take into account. -- Oleg Alistratov
Right. You should use: ok( ! eq_deeply(...), "desc") -- rjbs