comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: AUnit: access to local procedure needed when asserting exception
Date: Tue, 06 Dec 2011 20:02:17 +0000
Date: 2011-12-06T20:02:17+00:00	[thread overview]
Message-ID: <m239cxbh9y.fsf@pushface.org> (raw)
In-Reply-To: 4ede5c09$0$6567$9b4e6d93@newsspool4.arcor-online.net

Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> On 06.12.11 13:25, Simon Wright wrote:
>> Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

>> I've never quite understood the point of this facility, what's wrong
>> with
>> 
>>    begin
>>       --  do whatever should raise The_Exception
>>       Assert (C, False, "should have raised The_Exception");
>>    exception
>>       when The_Exception => null;
>>    end;
>
> Nothing wrong. The line numbers will be one off or so.
> Actually, this is very close to how it is implemented
> for run-times that support exception handling.
>
> The generic was easily added.
>
>    generic
>       with procedure Proc;
>    procedure Generic_Assert_Exception
>      (Message : String;
>       Source  : String := GNAT.Source_Info.File;
>       Line    : Natural := GNAT.Source_Info.Line);
>    --  Generic equivalent of Assert_Exception.
>
>
>    procedure Generic_Assert_Exception
>      (Message : String;
>       Source  : String := GNAT.Source_Info.File;
>       Line    : Natural := GNAT.Source_Info.Line) is
>    begin
>       begin
>          Proc;
>       exception
>          when others =>
           ^^^^^^^^^^^

I quite often want to make sure that a specific exception has been
raised.

>             return;
>       end;
>
>       --  No exception raised: register the failure message
>       Assert (False, Message, Source, Line);
>
>    end Generic_Assert_Exception;



  reply	other threads:[~2011-12-06 20:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06  1:12 AUnit: access to local procedure needed when asserting exception Georg Bauhaus
2011-12-06 11:00 ` Georg Bauhaus
2011-12-06 12:25 ` Simon Wright
2011-12-06 18:16   ` Georg Bauhaus
2011-12-06 20:02     ` Simon Wright [this message]
2011-12-06 21:42       ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox