Subject: | Exporting 'isa' by default makes class difficult to use with Exporter |
Test::Deep exports 'isa' by default into the import()'ing namespace (for
Test::Deep::Isa objects). This breaks Exporter from working in that
namespace. Here's an example that I ran into:
## test.pl:
#!/usr/bin/perl
use strict;
use warnings;
use test;
print $name . "\n";
## test.pm:
use strict;
use warnings;
use Test::Deep;
use base qw(Exporter);
our @EXPORT = qw($name $is_num);
our $name = 'Eric Waters';
our $is_num = re('^\d+$');
1;
This code will die with undefined '$name'. If you add "qw(re)" to the
"use Test::Deep" call, it will work.
As you can see, I'm attempting to use a test module to make available to
my test scripts easy to use Test::Deep::.. objects ($is_str, in this
example). I can't do that, as Test::Deep->import() brings in 'isa',
which somehow breaks Exporter for my class. The solution is to:
use Test::Deep qw(:DEFAULT !isa);
But this is not intuitive. At the very least, this should be documented
in the code.