views:

171

answers:

1

I'm currently refactoring a test suite built up by a colleague and would like to use Test::Class[::Most] while doing so. As I started I figured out I could really use a couple of Moose roles to decouple code a little bit. However, it seems it's not quite possible -- I'm getting error messages like this one:

Prototype mismatch: sub My::Test::Class::Base::blessed: none vs ($) at
/usr/lib/perl5/vendor_perl/5.8.8/Sub/Exporter.pm line 896

So the question is: can I use Moose together with Test::Class and if so, how?

PS: The code goes like this:

package My::Test::Class::Base;
use Moose;
use Test::Class::Most;

with 'My::Cool::Role';

has attr => ( ... );
+6  A: 

Test::Deep (loaded via Test::Most via Test::Class::Most) is exporting its own blessed along with a lot of other stuff it probably shouldn't be. Its not documented. Moose is also exporting the more common Scalar::Util::blessed. Since Scalar::Util::blessed is fairly common, Test::Deep should not be exporting its own different blessed.

Unfortunately, there's no good way to stop it. I'd suggest in My::Test::Class::Base doing the following hack:

package My::Test::Class::Base;

# Test::Class::Most exports Test::Most exports Test::Deep which exports
# an undocumented blessed() which clashes with Moose's blessed().
BEGIN {
    require Test::Deep;
    @Test::Deep::EXPORT = grep { $_ ne 'blessed' } @Test::Deep::EXPORT;
}

use Moose;
use Test::Class::Most;

and reporting the problem to Test::Deep and Test::Most.

Schwern
I guess it's no use to report this problem, since it has been reported almost three years ago: https://rt.cpan.org/Public/Bug/Display.html?id=27699Thanks for your workaround, I'll add my comment to that bug report.
rassie
Report it to Test::Most. It doesn't have to export everything from Test::Deep.
Schwern
Done so already: https://rt.cpan.org/Public/Bug/Display.html?id=57501
rassie