[tpm] testing; using eval to catch an error in a module
Madison Kelly
linux at alteeve.com
Sat Aug 29 10:01:04 PDT 2009
Hi all,
I've been working on a test script for my module suite/hobby and I've
been having a bit of trouble. I want to trap errors in the module
without killing the test script. I was hoping I could do something like:
eval {
$an->foo("some Illegal arg");
}
if ($@)
{
print "The module 'die'ed as planned and emitted error: [$@]\n";
}
else
{
die "Testing of module death failed as [$@] wasn't set.\n";
}
I think this is because it's not a compile time error, but the perldoc
for eval shows trapping for a divide by zero error, which as I
understand it would trigger on execution, not compile.
Am I missing something fundamental? Should I be approaching my testing
in a different way?
I'm sorry is this is a simple question... I've been trying to make sure
I've got a good handle on a lot of perl topics recently and am starting
to get a wee blender-brain.
Thanks!
Madi
More information about the toronto-pm
mailing list