开发者

How can I provoke multiple calls to Finalize?

In a recent AdaCore Gem there's a statement

The implementation of Finalize is slightly more complicated: the Ada reference manual indicates that a Finalize procedure should always be idempotent. An Ada compiler is free to call Finalize multiple times on the same object, in particular when exceptions occur.

I need to test a privately controlled type,

   type T is private;
private
   type T is new Ada.Finalization.Controlled with ...

I can change the source to make the type visibly controlled

   type T is new Ada.Finalization.Controlled with private;

and then just ca开发者_StackOverflow中文版ll Finalize (My_T); (or even My_T.Finalize?); but is there any way I can cause multiple finalizations without this change to the software-under-test?


For the purpose of testing, I use a child package. It allows to tests the private part. Assuming your package is:

package A is
   type T is private;
private
   type T is new Ada.Finalization.Controlled with ...
end A;

I would test with something like:

package body A.Test is
   procedure Test_Finalize is
       My_T : T;
   begin
       My_T.Finalize;
   end Test_Finalize;
end A.Test;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜