agpl_1.0.0_b5da3320/src/tests/t019_passing.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
with Text_Io; use Text_Io;
with Ada.Exceptions; use Ada.Exceptions;

procedure T019_Passing is

   type Junk is array (1 .. 1000) of Integer;

   type Thing is tagged record
      X    : Integer := 15;
      Fill : Junk := (others => 16#Dead#);
   end record;

   function Pass_Thru (This : Thing) return Thing is
   begin
      return This;
   end Pass_Thru;

   procedure Update (This : in out Thing) is
   begin
      This.X := 16#fff#;
   end Update;

begin
   declare
      A : Thing;
      B : Thing := A;
   begin
      Put_Line
        (Boolean'Image
           (Pass_Thru
              (Pass_Thru
                 (Pass_Thru
                    (A))).X
            = 15));

      Update (A);
   end;
exception
   when E : others =>
      Put_Line ("Exception: " & Exception_Information (E));
end T019_Passing;