0
votes

I need some simple Ada code for test my "system". In order to test it I need some example of code that raise a storage error and a tasking error (I know normally they are avoided but I need to simulate this problems). I know that seems a basic request but I am a little new on ada coding and I find a little difficult to solve these tasks. I have tried to search on the internet for a fitted solution but all are not usable for my needs(or too specific or wrong). What I am searching is to create an .adb with a function/procedure that raises these two errors.

1

1 Answers

2
votes

I hope you’ll be happy with different procedures for the two errors?

For Storage_Error,

procedure Storage is
   procedure Recursive is
   begin
      Recursive;
   end Recursive;
begin
   Recursive;
end Storage;

and for Tasking_Error,

procedure Tasking is
   task T is
      entry E;
   end T;
   task body T is
   begin
      null;
   end;
begin
   delay 0.01;
   T.E;
end Tasking;

This raises the exception because, when the main program calls T.E, there’s no task there at all. To explore this, replace the null; by e.g. delay 5.0; - the program waits 5 seconds before the exception terminates it.