home *** CD-ROM | disk | FTP | other *** search
/ Hacker / Hacker.iso / HACKER / DECOMP / DECAF / TESTS / port.adb < prev    next >
Encoding:
Text File  |  1996-09-19  |  2.6 KB  |  102 lines

  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: Gilles Demailly
  4. --
  5. --
  6. -- Permission to use, copy, modify, and distribute this software and its
  7. -- documentation for any purpose and without fee is hereby granted,
  8. -- provided that the above copyright and authorship notice appear in all
  9. -- copies and that both that copyright notice and this permission notice
  10. -- appear in supporting documentation.
  11. -- 
  12. -- The ARA makes no representations about the suitability of this software
  13. -- for any purpose.  It is provided "as is" without express
  14. -- or implied warranty.
  15. -- 
  16.  
  17. --
  18. -- Procedure Port is a test procedure for package Basic_Definitions
  19. -- it checks the results of the bit manipulations functions
  20. -- for Unsigned_8 and Unsigned_64 types
  21. --
  22.  
  23. with Ada.Text_Io;
  24.  
  25. with Basic_Definitions;
  26. use Basic_Definitions;
  27.  
  28. procedure Port is
  29.  
  30.    OK : Boolean     := True;
  31.  
  32.    A1 : Unsigned_8  := 1;
  33.    A2 : Unsigned_8  := 2;
  34.    A3 : Unsigned_8  := 3;
  35.    A4 : Unsigned_8  := 4;
  36.     
  37.    B1 : Unsigned_64 := 1;
  38.    B2 : Unsigned_64 := 2;
  39.    B3 : Unsigned_64 := 3;
  40.    B4 : Unsigned_64 := 4;
  41.  
  42. begin
  43.     
  44.     Ada.Text_Io.Put_Line (" Basic Portability Tests in progress");
  45.     
  46.     A1 := Shift_Left (A1, 1);
  47.     A2 := Shift_Left (A2, 2);
  48.     A3 := Shift_Left (A3, 1);
  49.     A4 := Shift_Left (A4, 1);
  50.     if A1 /= 2 or A2 /= 8 or A3 /= 6 or A4 /= 8 then
  51.        OK := False;
  52.        Ada.Text_Io.Put_Line 
  53.           ("Shift_Left function non portable with Unsigned_8");
  54.     end if;
  55.     
  56.     A1 := 1;
  57.     A2 := 2;
  58.     A3 := 3;
  59.     A4 := 4;
  60.     
  61.     A1 := Shift_Right (A1, 1);
  62.     A2 := Shift_Right (A2, 2);
  63.     A3 := Shift_Right (A3, 1);
  64.     A4 := Shift_Right (A4, 1);
  65.     if A1 /= 0 or A2 /= 0 or A3 /= 1 or A4 /= 2 then
  66.        OK := False;
  67.        Ada.Text_Io.Put_Line 
  68.           ("Shift_Right function non portable with Unsigned_8");
  69.     end if;
  70.     
  71.     B1 := Shift_Left (B1, 1);
  72.     B2 := Shift_Left (B2, 2);
  73.     B3 := Shift_Left (B3, 1);
  74.     B4 := Shift_Left (B4, 1);
  75.     if B1 /= 2 or B2 /= 8 or B3 /= 6 or B4 /= 8 then
  76.        OK := False;
  77.        Ada.Text_Io.Put_Line 
  78.           ("Shift_Left function non portable with Unsigned_64");
  79.     end if;
  80.     
  81.     B1 := 1;
  82.     B2 := 2;
  83.     B3 := 3;
  84.     B4 := 4;
  85.     
  86.     B1 := Shift_Right (B1, 1);
  87.     B2 := Shift_Right (B2, 2);
  88.     B3 := Shift_Right (B3, 1);
  89.     B4 := Shift_Right (B4, 1);
  90.     if B1 /= 0 or B2 /= 0 or B3 /= 1 or B4 /= 2 then
  91.        OK := False;
  92.        Ada.Text_Io.Put_Line 
  93.           ("Shift_Right function non portable with Unsigned_64");
  94.     end if;
  95.     
  96.     
  97.     if OK then
  98.        Ada.Text_Io.Put_Line (" ... Tests completed");
  99.     end if;
  100.  
  101. end Port;
  102.