From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: AUnit: access to local procedure needed when asserting exception
Date: Tue, 06 Dec 2011 19:16:40 +0100
Date: 2011-12-06T19:16:41+01:00 [thread overview]
Message-ID: <4ede5c09$0$6567$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <m27h29c2fq.fsf@pushface.org>
On 06.12.11 13:25, Simon Wright wrote:
> Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:
>
>> Consequently, when seeing procedure Test_Null mostly reproduced below,
>> the compiler diagnoses (correctly, I think)
>>
>> 66. AUnit.Assertions.Assert_Exception (Null_Raises'Access,
>> |
>> >>> subprogram must not be deeper than access type
>
> At this point I tend to just use 'Unrestricted_Access.
>
> 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 =>
return;
end;
-- No exception raised: register the failure message
Assert (False, Message, Source, Line);
end Generic_Assert_Exception;
OTOH, specific Assert procedures made for exceptions will create a way
to collect tests into two groups; one group for tests that
compare values and another group for testing exceptional situations,
I/O error, failures expressed as pre/post/inv, ...
next prev parent reply other threads:[~2011-12-06 18:16 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 [this message]
2011-12-06 20:02 ` Simon Wright
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