comp.lang.ada
 help / color / mirror / Atom feed
* AUnit: access to local procedure needed when asserting exception
@ 2011-12-06  1:12 Georg Bauhaus
  2011-12-06 11:00 ` Georg Bauhaus
  2011-12-06 12:25 ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Georg Bauhaus @ 2011-12-06  1:12 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-12-06 21:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2011-12-06 21:42       ` Georg Bauhaus

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