Currently, throwing is_deeply() a code ref causes it to barf.

perl -MTest::More -wle 'print is_deeply sub {}, sub {}'
WHOA!  No type in _deep_check
This should never happen!  Please contact the author immediately!
# Looks like your test died before it could output anything.


is_deeply() doesn't know what to do with code refs.  What should it do?

What it *shouldn't* do is what Test.pm does, namely execute the code ref and
compare the values returned.  It would just compare the refernces.

This much is obvious, this should pass:

        is_deeply \&foo, \&foo;

The same code ref is being compared.  But here's the tricky part.

        is_deeply sub { 42 }, sub { 42 };

Does that pass?  ie. Are we just comparing the reference value or should
is_deeply() decompile the subroutine and see if they contain the same code?
(Technical considerations aside, for the moment).

Given that is_deeply() considers these to be equivalent:

        is_deeply [ 42 ], [ 42 ];

I think comparing the decompiled source code is consistent, but is it 
useful?  Anyone have use cases for this?


-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
Don't try the paranormal until you know what's normal.
        -- "Lords and Ladies" by Terry Prachett

Reply via email to