Note that there are some explanatory texts on larger screens.

plurals
  1. POException Handling in Ada during Unit Test
    primarykey
    data
    text
    <p>I am attempting to write some unit tests for some Ada code I recently wrote, I have a particular case where I am expecting to get an Exception (if the code worked correctly I wouldn't but in this case all I'm doing is testing, not writing code). If I handle the exception in the Testing routine then I don't see how I can continue testing in that procedure.</p> <p>I.E. (This is very much an example and NOT compilable code)</p> <pre><code>procedure Test_Function is begin from -20 to 20 Result := SQRT(i); if Result = (Expected) then print "Passed"; end_if; exception: print "FAILED"; end Test_Function </code></pre> <p>My first thought is if I had a "deeper function" which actually did the call and the exception returned through that.</p> <p>I.E. (This is very much an example and NOT compilable code)</p> <pre><code>procedure Test_Function is begin from -20 to 20 Result := my_SQRT(i); if Result = (Expected) then print "Passed"; end_if; exception: print "FAILED"; end Test_Function function my_SQRT(integer) return Integer is begin return SQRT(i); exception: return -1; end my_SQRT; </code></pre> <p>And in theory I expect that would work, I just hate to have to keep writing sub functions when my test_function, is expected to do the actual testing.</p> <p>Is there a way to continue execution after hitting the exception IN Test_Function, rather than having to write a wrapper function and calling through that? OR Is there a easier/better way to handle this kind of scenario?</p> <p>*Sorry for the poor code example, but I think the idea should be clear, if not I'll re-write the code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload