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

People
Owner: Nobody in particular
Requestors: ewaters [...] uarc.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.099
  • 0.102
Fixed in: (no value)



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.
On Mon Jun 02 14:10:41 2008, ewaters@uarc.com wrote: Show quoted text
> 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.
Luckily for you, I found a way to fix this without breaking anything else... I hope. isa() is a documented function of Test::Deep, it's unfortunate that it clashes with UNIVERSAL::isa() but Test::Deep was built to be easy to use in .t scripts. You should be able to get away with just use Test::Deep qw(!isa); Anyway, as of 0.103 (just released), isa() will behave as UNIVERSAL::isa() when called with 2 arguments and as regular Test::Deep::isa when called with 1. It's somewhat ugly but should clear up the problem without breaking old code.