--  Default_Value and Default_Component_Value (RM 3.5(56.3), 3.6(22.2)): objects, components
--  and allocators of the types made without a value take the default, which derived types
--  inherit and `<>` in an aggregate gives; the prover knows the values.
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Defaults;
procedure Main is
   type Level is range 0 .. 10 with Default_Value => 5;
   type Small is new Level range 0 .. 9;
   type Count is new Integer with Default_Value => 1;
   type Colour is (Red, Green, Blue) with Default_Value => Green;
   type Row is array (Positive range <>) of Integer with Default_Component_Value => 7;
   type Levels is array (1 .. 3) of Level;
   type Grid is array (1 .. 2, 1 .. 2) of Integer with Default_Component_Value => -1;
   type Rec is record
      F : Level;
      G : Row (1 .. 3);
      H : Colour;
   end record;
   type Level_Ptr is access Level;
   procedure Free is new Ada.Unchecked_Deallocation (Level, Level_Ptr);
   N : constant Positive := 4;
   X : Level;
   S : Small;
   K : Count;
   C : Colour;
   Y : Row (1 .. N);
   L : Levels;
   M : Grid;
   Z : Rec;
   B : constant Levels := (1 => 2, others => <>);
   P : Level_Ptr := new Level;
   H : Defaults.Handle;
begin
   pragma Assert (X = 5 and S = 5 and K = 1 and C = Green);
   pragma Assert (Y (4) = 7 and L (2) = 5 and M (2, 1) = -1);
   pragma Assert (Z.F = 5 and Z.G (3) = 7 and Z.H = Green);
   pragma Assert (B (1) = 2 and B (3) = 5);
   pragma Assert (P.all = 5);
   pragma Assert (Defaults.Value (H) = 42 and Defaults.Value (Defaults.Shared) = 42);
   Ada.Text_IO.Put_Line (Level'Image (X) & Small'Image (S) & Count'Image (K) & " " & Colour'Image (C));
   Ada.Text_IO.Put_Line (Integer'Image (Y (4)) & Level'Image (L (2)) & Integer'Image (M (2, 1)));
   Ada.Text_IO.Put_Line (Level'Image (Z.F) & Integer'Image (Z.G (3)) & Level'Image (B (3)) & Level'Image (P.all));
   Ada.Text_IO.Put_Line (Integer'Image (Defaults.Value (H)));
   Free (P);
end Main;
