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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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.15.41 with SMTP id u9mr28018118pbc.3.1323201737795; Tue, 06 Dec 2011 12:02:17 -0800 (PST) Path: lh20ni76863pbb.0!nntp.google.com!news1.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: AUnit: access to local procedure needed when asserting exception Date: Tue, 06 Dec 2011 20:02:17 +0000 Organization: A noiseless patient Spider Message-ID: References: <4edd6c0a$0$6581$9b4e6d93@newsspool3.arcor-online.net> <4ede5c09$0$6567$9b4e6d93@newsspool4.arcor-online.net> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="1815"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kOx7bk6WIyQwN1PT9ChthATw27fKBHdw=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:Wn4jUhyXUZrW1Cc0XmCu5VK5Hf4= sha1:IUbOUgVXTCzFYzqwxxzf0Ud/GP0= Xref: news1.google.com comp.lang.ada:19373 Content-Type: text/plain; charset=us-ascii Date: 2011-12-06T20:02:17+00:00 List-Id: Georg Bauhaus writes: > On 06.12.11 13:25, Simon Wright wrote: >> Georg Bauhaus 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;