| 1 |
-- { dg-do run } |
| 2 |
|
| 3 |
with GNAT.Table; |
| 4 |
with Ada.Text_IO; use Ada.Text_IO; |
| 5 |
|
| 6 |
procedure test_table1 is |
| 7 |
type Rec is record |
| 8 |
A, B, C, D, E : Integer := 0; |
| 9 |
F, G, H, I, J : Integer := 1; |
| 10 |
K, L, M, N, O : Integer := 2; |
| 11 |
end record; |
| 12 |
|
| 13 |
R : Rec; |
| 14 |
|
| 15 |
package Tab is new GNAT.Table (Rec, Positive, 1, 4, 30); |
| 16 |
|
| 17 |
Last : Natural; |
| 18 |
|
| 19 |
begin |
| 20 |
R.O := 3; |
| 21 |
|
| 22 |
Tab.Append (R); |
| 23 |
|
| 24 |
for J in 1 .. 1_000_000 loop |
| 25 |
Last := Tab.Last; |
| 26 |
begin |
| 27 |
Tab.Append (Tab.Table (Last)); |
| 28 |
exception |
| 29 |
when others => |
| 30 |
Put_Line ("exception raise for J =" & J'Img); |
| 31 |
raise; |
| 32 |
end; |
| 33 |
|
| 34 |
if Tab.Table (Tab.Last) /= R then |
| 35 |
Put_Line ("Last is not what is expected"); |
| 36 |
Put_Line (J'Img); |
| 37 |
return; |
| 38 |
end if; |
| 39 |
end loop; |
| 40 |
end; |