[Israel.pm] Alternative for catching return value

Levenglick Dov-RM07994 DovL at freescale.com
Mon Nov 14 03:51:34 PST 2005


eval {$sysUnderTest->someAction($foo, $bar, foo, bar)};
die $@ if $@

Will work if $sysUnderTest->someAction() trys to die if it fails.
This should be the same as throwing a C++ exception

 
Best Regards,
Dov Levenglick
DSP SoC System and Applications Engineer,
Network and Computing Systems Group
Freescale Semiconductor Israel
Tel. +972-9-952-2804
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
 


-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of David Baird
Sent: Monday, November 14, 2005 1:26 PM
To: Perl in Israel
Subject: [Israel.pm] Alternative for catching return value


Our test scripts are filled with this kind of construction:

$ret = $sysUnderTest->someAction($foo, $bar, 'foo', 'bar');
die "System Under Test failed = $testEnv::return_dscr[$ret]\n"
    unless $ret == $testEnv::ACTION_SUCCESS;

or sometimes like this:

$ret = $sysUnderTest->Stop();
if (($ret != $testEnv::CMD_INVALID_FOR_STATE) &&
    ($ret != $testEnv::ACTION_SUCCESS) ) {

    $sysUnderTest->DESTROY;
    die "Stop failed = $testEnv::return_dscr[$ret]\n";
}

I think that the DESTROY method is called, because it has to return
the system under test to a neutral state, and perhaps there is some
misunderstanding on when the DESTROY of all objects will get called.

Could anyone come up with cleaner code which doesn't require defining
$ret, but still allows the debugger to catch the return value before
the test script dies?

Thank you,
David

_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list