with ada.text_io;
   with ada.integer_text_io;
   with Ada.Numerics.Discrete_Random;

    procedure testSort is
      subtype number is integer range 1..250;
      type theArray is Array (1..15) of number;
   
      myArray : theArray;
   
       procedure TestRandomNumberGenerator (a : out theArray)  is
          package myValues is new Ada.Numerics.Discrete_Random (number);
         g        : myValues.generator;
      begin
         myValues.reset(g);  
         for i in 1..15 loop  
            a(i) := myValues.Random(g);
            ada.integer_text_io.put (a(i),5);
         --  ada.text_io.new_line;
         end loop;
      end testRandomNumberGenerator;
   
       procedure swap (i : in out number; j : in out number) is
         temp : number; 
      begin
      -- ada.text_io.put (" entering swap ");
         temp := i;
         i    := j;
         j    := temp;
      end swap;

       PROCEDURE bubbleSort( A : in out theArray )is
         swapped : boolean;
      
      begin
      -- ada.integer_text_io.put (a'first);  -- DEBUG
      -- ada.integer_text_io.put (a'last);   -- DEBUG
         swapped := false; 
         while not swapped loop
            swapped := true;
            for i in a'first..a'last-1  loop
            --    ada.integer_text_io.put(i);
               if A(i) > A(i + 1) then
                  swap( A(i), A(i + 1) );
                  swapped := false;
               end if;
            end loop;
         end loop;
      end bubbleSort;
   
       procedure print (a : in theArray) is
      begin
         for i in a'first..a'last  loop
            ada.integer_text_io.put(a(i),5);
         end loop; 
      end print;
   
   begin
      testRandomNumberGenerator (myarray);
      ada.text_io.new_line;
      print(myArray);
      ADA.TEXT_IO.NEW_LINE;
   --  bubblesort (myArray);   --- testing bubble sort
      print (myArray);
    
      testRandomNumberGenerator (myarray);
      ada.text_io.new_line;
      print(myArray);
      ADA.TEXT_IO.NEW_LINE;
      INSERTIONSORT (myArray);   --- testing INSERTION SORT
      print (myArray);
   
      testRandomNumberGenerator (myarray);
      ada.text_io.new_line;
      print(myArray);
      ADA.TEXT_IO.NEW_LINE;
   -- bubblesort (myArray);   --- testing SELECTION sort
      print (myArray);
   
      testRandomNumberGenerator (myarray);
      ada.text_io.new_line;
      print(myArray);
      ADA.TEXT_IO.NEW_LINE;
   --  bubblesort (myArray);   --- testing QUICKSORT
      print (myArray);

   end testSort;