Re: Test::Deep 0.108 and the future of Test::Deep

2010-10-18 Thread Michael G Schwern
On 2010.10.16 3:29 PM, Fergal Daly wrote:
 I tried to port this import statement to Perl but functions vs methods
 makes a general implementation impossible unless you have knowledge of
 the module being imported. However there's nothing stopping individual
 modules adopting the convention. It's particularly useful if the
 module exports a large and growing number of symbols. So I could
 imagine the follwoing interface.
 
 use Test::Deep2 qw($deep); # import the module as $deep
 
 $deep-is_deeply($foo, $deep-set([1,2,3,4]));
 
 So no namespace pollution but still access to all Test::Deep symbols
 with little typing.

I'm +1 to using this sort of solution for all the fiddly little special
comparison functions, but not the entire interface.

Exporting test functions is fine, they're unlikely to clash and they get used
plenty.  Exporting ninety bazillion little helper functions with names that
are likely to clash and only get rarely used... not so much.  Huffman encoding.

Exporting a $Deep which the user can use for $Deep-re or $Deep-superhashof
sounds like a good compromise.


-- 
Defender of Lexical Encapsulation


Re: Test::Deep 0.108 (and the Test::Most philosophy)

2010-10-18 Thread Aristotle Pagaltzis
* Ovid publiustemp-perl...@yahoo.com [2010-10-17 16:25]:
 Modules are poor place for evangelism about unrelated
 conventions in general, but I feel this especially strongly
 about Test:: modules with break-the-CPAN level adoption such
 as Test::Deep.

 That arguments you made are compelling, so I need to ask your
 point of view about this:

#!/usr/bin/env perl
use Test::Most

ok 1, '1 is true';

 use Test::Most tests = 42 is loosely equivalent to:

use strict;
use warnings;
use Test::Exception 0.88;
use Test::Differences 0.500;
use Test::Deep 0.106;
use Test::Warn 0.11;
use Test::More tests = 42;

 Test::Most, like Test::Class::Most, not only imports the most
 common testing functions, but also imports strict and warnings
 for you.  I didn't do this lightly. I did this because I see
 a lot of test suites forgetting one or the other and in the
 case of test suites, it's terribly important to not miss those
 because they stop so many errors (for example, many warnings
 are actually symptoms of underlying bugs and that's what a test
 suite is about, right?).

 So did I do the wrong thing here?  I'd love to hear pro and con
 arguments.

That looks fine to me. The primary purpose of Test::Most is to
cut down on typing. Enabling strictures and warnings for the user
fits right into its mission. More importantly,

use strict;
use warnings;

is hardly an experimental interface unproven by practice. :-)
Whereas new approaches to namespaces very definitely are.

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/