如何引发对 Finalize 的多次调用?
Finalize 的实现稍微复杂一些:Ada 参考手册指出 Finalize 过程应该始终是幂等的。 Ada 编译器可以对同一对象多次调用 Finalize,特别是在发生异常时。
我需要测试私有控制的类型,
type T is private;
private
type T is new Ada.Finalization.Controlled with ...
我可以更改源以使类型受到可见控制
type T is new Ada.Finalization.Controlled with private;
,然后只需调用 Finalize (My_T);
(甚至是 My_T.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 call 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于测试目的,我使用了子包。它允许测试私人部分。
假设你的包裹是:
我会用类似的东西进行测试:
For the purpose of testing, I use a child package. It allows to tests the private part.
Assuming your package is:
I would test with something like: