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: 15231
Status: resolved
Priority: 0/
Queue: Test-Deep

People
Owner: Nobody in particular
Requestors: tshinnic [...] io.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.089
Fixed in: (no value)



Subject: eq_deeply() is not quite ready for general use - diagnostics on exceptions
I was wanting a simple procedure for comparing two data values/structures for 'equality'. The documentation for Test::Deep::eq_deeply looked like this routine would be perfect, as the docs said the routine could be used outside of a testing environment: This is the same as cmp_deeply() it just returns true or false, however it never outputs any diagnostics or talks to Test::Builder, so you can use it in a normal program, rather than in a test script. Unfortunately as I tested I found that there were side-effects from merely 'use'ing it. This is a simple example of the problem: perl -M"Test::Deep" -e "die 'boo!'" boo! at -e line 1. # Looks like your test died before it could output anything. That is, after 'use'ing Test::Deep any fatal (?) exceptions will cause the test environment diagnostic to appear. I imagine that 'use'ing Test::Builder is causing the side-effect. If this side-effect can't be easily fixed, could you add a caveat to the docs mentioning this (perhaps inconsequential to some) diagnostic gotcha? As well, if you have suggestions for equivalent functionality from other modules, that would be appreciated. Currently I'm reduced to using this: sub eq_deeply_alt { my ( $r1, $r2 ) = @_; my $s1 = Data::Dumper->new([$r1])->Indent(0)->Terse(1)->Sortkeys(1)->Dump(); my $s2 = Data::Dumper->new([$r2])->Indent(0)->Terse(1)->Sortkeys(1)->Dump(); return $s1 eq $s2; }
Good point, thanks. Test-Deep-0.091 is on it's way to CPAN right now, fixing that. You just do use Test::Deep::NoTest; print "different" unless eq_deeply($a, $b); which avoids loading Test::Builder and only exports the functions that are not Test::Builder related. It's a bit of a hacky way of doing things but then Test::Deep has long needed to be restructured in a deep comparison library and a small wrapper that ties it in to Test::Builder, F [guest - Sat Oct 22 19:51:21 2005]: Show quoted text
> I was wanting a simple procedure for comparing two data > values/structures for 'equality'. The documentation for > Test::Deep::eq_deeply looked like this routine would be perfect, as > the docs said the routine could be used outside of a testing > environment: > This is the same as cmp_deeply() it just returns true or false, > however it never outputs any diagnostics or talks to Test::Builder, > so you can use it in a normal program, rather than in a test > script. > > Unfortunately as I tested I found that there were side-effects from > merely 'use'ing it. This is a simple example of the problem: > perl -M"Test::Deep" -e "die 'boo!'" > boo! at -e line 1. > # Looks like your test died before it could output anything. > > That is, after 'use'ing Test::Deep any fatal (?) exceptions will cause > the test environment diagnostic to appear. I imagine that 'use'ing > Test::Builder is causing the side-effect. > > If this side-effect can't be easily fixed, could you add a caveat to > the docs mentioning this (perhaps inconsequential to some) > diagnostic gotcha? > > As well, if you have suggestions for equivalent functionality from > other modules, that would be appreciated. Currently I'm reduced to > using this: > sub eq_deeply_alt { > my ( $r1, $r2 ) = @_; > my $s1 = Data::Dumper->new([$r1])->Indent(0)->Terse(1)-
> >Sortkeys(1)->Dump();
> my $s2 = Data::Dumper->new([$r2])->Indent(0)->Terse(1)-
> >Sortkeys(1)->Dump();
> return $s1 eq $s2; > }