From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: AUnit: access to local procedure needed when asserting exception
Date: Tue, 06 Dec 2011 02:12:42 +0100
Date: 2011-12-06T02:12:42+01:00 [thread overview]
Message-ID: <4edd6c0a$0$6581$9b4e6d93@newsspool3.arcor-online.net> (raw)
In agreement with AUnit's docs, I wanted to write a test routine
that tests for an exception being raised. To do so, I wrote
a local procedure that would become a parameter of a generic
procedure Assert_Exception. However, this generic is gone from AUnit
(the one distributed with both GNAT GPL 2010 and 2011),
and seems to have been replaced with a non-generic procedure that
takes an object of pointer-to-procedure type instead.
The pointer-to-procedure,
type Throwing_Exception_Proc is access procedure;
is defined at library level in AUnit.Assertions.
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
procedure Test_Null (Test : in out Test_Case'Class)
is
procedure Null_Raises is
Position : Natural;
begin
Position := Find (Search_Test(Test).Buffer,
Get_Null_Pattern, 1);
end Null_Raises;
--procedure Assert_Raises is
-- new AUnit.Assertions.Assert_Exception (Null_Raises);
begin
AUnit.Assertions.Assert_Exception (Null_Raises'Access,
"null string raises Pattern_Error");
end Test_Null;
I should be able to write the tests differently, so that everything
necessary for the test routine is declared at the same level as
the pointer-to-procedure type requires. But why is the simpler
generic gone? I also imagine that the authors of AUnit have had good
reason to introduce a named type---preventing access to local procedures.
Am I missing something?
Georg
next reply other threads:[~2011-12-06 1:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 1:12 Georg Bauhaus [this message]
2011-12-06 11:00 ` AUnit: access to local procedure needed when asserting exception Georg Bauhaus
2011-12-06 12:25 ` Simon Wright
2011-12-06 18:16 ` Georg Bauhaus
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