[tpm] testing; using eval to catch an error in a module
linux at alteeve.com
Sat Aug 29 10:01:04 PDT 2009
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:
$an->foo("some Illegal arg");
print "The module 'die'ed as planned and emitted error: [$@]\n";
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.
More information about the toronto-pm