2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / ada / acats / tests / c2 / c250002.aw
blobfe2248155a2313ec76aef79f0c73abac479852e8
1 -- C250002.AW
2 --
3 --                             Grant of Unlimited Rights
4 --
5 --     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 --     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained 
7 --     unlimited rights in the software and documentation contained herein.
8 --     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making 
9 --     this public release, the Government intends to confer upon all 
10 --     recipients unlimited rights  equal to those held by the Government.  
11 --     These rights include rights to use, duplicate, release or disclose the 
12 --     released technical data and computer software in whole or in part, in 
13 --     any manner and for any purpose whatsoever, and to have or permit others 
14 --     to do so.
16 --                                    DISCLAIMER
18 --     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 --     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED 
20 --     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 --     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE 
22 --     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 --     PARTICULAR PURPOSE OF SAID MATERIAL.
24 --*
26 -- OBJECTIVE:
27 --      Check that characters in Latin-1 above ASCII.Del can be used in
28 --      identifiers, character literals and strings.
29 -- 
30 -- TEST DESCRIPTION:
31 --      This test utilizes the brackets scheme for representing Latin-1
32 --      character values in transportable 7 bit ASCII as proposed by
33 --      Robert Dewar; this test defines Character and String objects,
34 --      assigns and tests several sample values.  Several Identifiers
35 --      used in this test also include Characters via the bracket escape
36 --      sequence scheme.
38 --      Note that C250001 checks Wide_Characters and Wide_Strings.
40 -- SPECIAL REQUIREMENTS:
42 --      This file must be preprocessed before it can be executed as a test.
44 --      This test requires that all occurrences of the bracket escaped
45 --      characters be replaced with the corresponding 8 bit character.
47 --      Characters above ASCII.Del are represented by a 6 character sequence:
49 --          ["xx"]
51 --      where the character code represented is specified by two hexadecimal
52 --      digits (<xx>) upper case. For example the Latin-1 character with the
53 --      code 16#AB# is represented by the six character sequence:
55 --          ["AB"]
57 --      None of the values used in this test should be interpreted as
58 --      a control character.
60 --      The following function documents the translation algorithm:
62 --     function To_Char( S:String ) return Character is
63 --       Numerical : Natural := 0;
64 --       type Xlate is array(Character range '0'..'F') of Natural;
65 --       Xlation : Xlate
66 --               := ('0' =>  0, '1' =>  1, '2' =>  2, '3' =>  3, '4' =>  4,
67 --                   '5' =>  5, '6' =>  6, '7' =>  7, '8' =>  8, '9' =>  9,
68 --                   'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14,
69 --                   'F' => 15,  others => 0 );
70 --     begin
71 --       for I in S'Range loop
72 --         Numerical := Numerical * 16 + Xlation(S(I));
73 --       end loop;
74 --       return Character'Val(Numerical);
75 --     end To_Char;
78 -- CHANGE HISTORY:
79 --      10 JAN 96   SAIC   Initial version
80 --      12 NOV 96   SAIC   Changed file extension to .AW
82 --!
84 ----------------------------------------------------------------- C250002_0
86 package C250002_0 is
88   -- The extended characters used in this test start with
89   -- the character '["A1"]' 16#A1# and increase from there
91   type Tagged_["C0"]_Id is tagged record
92     Length, Width: Natural;
93   end record;
95   X_Char_A2 : constant Character := '["A2"]';
97   X_Char_A3_Through_A9 : constant String := 
98                "["A3"]["A4"]["A5"]["A6"]["A7"]["A8"]["A9"]";
100   X_Char_AA_AB : constant String := "["AA"]["AB"]";
102 end C250002_0;
104 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
106 -- no package body C250002_0 is required or allowed
108 ----------------------------------------------------------------- C250002_X
110 with Ada.Characters.Latin_1;
111 package C250002_["C1"] is
113   type Enum is ( Item, 'A', '["AD"]', AE_["C6"]["E6"]_ae,
114                  '["2D"]', '["FF"]' );
116   task type C2_["C2"] is
117     entry C2_["C3"];
118   end C2_["C2"];
120 end C250002_["C1"];
122 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
124 package body C250002_["C1"] is
126   task body C2_["C2"] is
127   begin
128     accept C2_["C3"];
129   end C2_["C2"];
131 end C250002_["C1"];
133 ------------------------------------------------------------------- C250002
135 with Report;
136 with C250002_0;
137 with C250002_["C1"];
139 with Ada.Tags;
141 procedure C250002 is
142   use C250002_0; 
144   My_Task: C250002_["C1"].C2_["C2"];
146   function Hex( N: Natural ) return String is
147     S : String := "xx";
148     T : String := "0123456789ABCDEF";
149   begin
150     S(1) := T(N  /  16 +1);
151     S(2) := T(N mod 16 +1);
152     return S;
153   end Hex;
155   procedure Match( Check : Character; Matching : Natural ) is
156   begin
157     if Check /= Character'Val( Matching ) then
158       Report.Failed( "Didn't match for " & Hex(Matching) );
159     end if;
160   end Match;
162   type Value_List is array(Positive range <>) of Natural;
164   procedure Match( Check : String; Matching : Value_List ) is
165   begin
166     if Check'Length /= Matching'Length then
167       Report.Failed( "Check'Length /= Matching'Length" );
168     else
169       for I in Check'Range loop
170         Match( Check(I), Matching(I - Check'First + Matching'First) );
171       end loop;
172     end if;
173   end Match;
175   TC_Count : Natural := 0;
177 begin  -- Main test procedure.
179   Report.Test ("C250002", "Check that characters above ASCII.Del can be " &
180                           "used in identifiers, character literals and " &
181                           "strings" );
183   Report.Comment( Ada.Tags.Expanded_Name(Tagged_["C0"]_Id'Tag) );
185   for Specials in C250002_["C1"].Enum loop
186     TC_Count := TC_Count +1;
187   end loop;
189   if TC_Count /= 6 then
190     Report.Failed("Expected 6 literals in Enum");
191   end if;
193   Match( X_Char_A2, 16#A2# );
195   Match(X_Char_A3_Through_A9,
196          (16#A3#,16#A4#,16#A5#,16#A6#,16#A7#,16#A8#,16#A9#) );
198   -- check catenations
200   Match( X_Char_A2 & X_Char_A2, (16#A2#,16#A2#) );
202   Match( X_Char_A2 & X_Char_AA_AB, (16#A2#,16#AA#,16#AB#) );
204   Match( X_Char_AA_AB & X_Char_A2, (16#AA#,16#AB#,16#A2#) );
206   Match( X_Char_AA_AB & X_Char_AA_AB,
207          (16#AA#,16#AB#,16#AA#,16#AB#) );
209   My_Task.C2_["C3"];
211   Report.Result;
213 end C250002;