From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5312057f44240abb X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.14.100 with SMTP id o4mr4587996pbc.6.1323195406555; Tue, 06 Dec 2011 10:16:46 -0800 (PST) Path: lh20ni76586pbb.0!nntp.google.com!news1.google.com!goblin3!goblin.stu.neva.ru!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!xlned.com!feeder1.xlned.com!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 06 Dec 2011 19:16:40 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: AUnit: access to local procedure needed when asserting exception References: <4edd6c0a$0$6581$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Message-ID: <4ede5c09$0$6567$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 06 Dec 2011 19:16:41 CET NNTP-Posting-Host: 314c8c4e.newsspool4.arcor-online.net X-Trace: DXC=Gh8W8BJLh>_cHTX3jMdOHK X-Complaints-To: usenet-abuse@arcor.de Xref: news1.google.com comp.lang.ada:19372 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Date: 2011-12-06T19:16:41+01:00 List-Id: On 06.12.11 13:25, Simon Wright wrote: > Georg Bauhaus 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, ...