Subject: | throws_ok breaks tests that depend on caller stack |
Hiya,
I find Test::Exception quite useful for the most part - kudos.
Run into a little snag where, for abstract methods I do this in the parent class:
package Foo;
sub an_abstract_method { shift->subclass_responsibility; }
sub subclass_responsibility {
my $class = shift->class;
my $method = (caller(1))[3];
$method =~ s/.*:://;
confess( "abstract method '$method' not implemented for $class" );
}
if I wanna test that using Test::Exception, I find the caller stack gets changed under my feet:
throws_ok( Foo->an_abstract_method, qr/abstract method 'an_abstract_method'/, 'blah' );
results in a failed test because the 'subclass_responsibility' is returning:
abstract method '_try_as_caller' not implemented for Foo
So I have to resort to using eval {} & Test::More's like()... Any way around it in Test::Exception?
-Steve