Subject: | Test::Exception doesn't play well SUPER |
I'm having a devil of a time replicating this in a clean test, otherwise
I would send a patch. Here's about the smallest test case I can reproduce:
#!/usr/bin/perl
use strict;
use warnings;
{
package My::Test::More;
use base 'Test::Class';
INIT { Test::Class->runtests }
use Test::More;
sub mytest : Tests(1) {
diag shift->{stuff};
ok 1, 'parent mytest';
}
}
{
package My::Test::Class;
use Test::More;
use Test::Exception;
use SUPER;
BEGIN { @My::Test::Class::ISA = 'My::Test::More' }
sub mytest : Tests(2) {
shift->{stuff} = 'foo';
super;
ok 1, 'mytest called';
}
}
1;
Run that and it produces:
1..3
# undef
ok 1 - parent mytest
You must call super() from a method call at test.pl line 27
not ok 2 - mytest died (Can't use an undefined value as a HASH
reference at test.pl line 12.)
# Failed test 'mytest died (Can't use an undefined value as a HASH
reference at test.pl line 12.)'
# at test.pl line 9.
# (in My::Test::Class->mytest)
ok 3 # skip mytest died
# Looks like you failed 1 test of 3.
If you remove the Test::Exception line, it works correctly:
1..3
# undef
ok 1 - parent mytest
# foo
ok 2 - parent mytest
ok 3 - mytest called
This appears to be because Sub::Uplevel overrides CORE::GLOBALL::caller.
In SUPER.pm, Replacing all calls to caller with CORE::caller seems to
fix the problem.
Cheers,
Ovid