OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxf/] [cxf1001.a] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CXF1001.A
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.
15
--
16
--                                    DISCLAIMER
17
--
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
--*
25
--
26
-- OBJECTIVE:
27
--      Check that values of 2 and 10 are allowable values for Machine_Radix
28
--      of a decimal first subtype.
29
--      Check that the value of Decimal.Max_Decimal_Digits is at least 18;
30
--      the value of Decimal.Max_Scale is at least 18; the value of
31
--      Decimal.Min_Scale is at most 0.
32
--
33
-- TEST DESCRIPTION:
34
--      This test examines the Machine_Radix attribute definition clause
35
--      and its effect on Decimal fixed point types, as well as several
36
--      constants from the package Ada.Decimal.
37
--      The first subtest checks that the Machine_Radix attribute will
38
--      return the value set for Machine_Radix by an attribute definition
39
--      clause.  The second and third subtests examine differences between
40
--      the binary and decimal scaling of a type, based on the radix
41
--      representation.  The final subtest examines the values
42
--      assigned to constants Min_Scale, Max_Scale, and Max_Decimal_Digits,
43
--      found in the package Ada.Decimal.
44
--
45
--
46
-- CHANGE HISTORY:
47
--      06 Dec 94   SAIC    ACVC 2.0
48
--      29 Dec 94   SAIC    Restructured Radix 10 and Radix 2 test blocks.
49
--
50
--!
51
 
52
with Report;
53
with Ada.Decimal;
54
 
55
procedure CXF1001 is
56
begin
57
 
58
   Report.Test ("CXF1001", "Check that values of 2 and 10 are allowable " &
59
                           "values for Machine_Radix of a decimal first " &
60
                           "subtype.  Check that the value of "           &
61
                           "Decimal.Max_Decimal_Digits is at least 18; "  &
62
                           "the value of Decimal.Max_Scale is at least "  &
63
                           "18; the value of Decimal.Min_Scale is at "    &
64
                           "most 0");
65
 
66
   Attribute_Check_Block:
67
   declare
68
 
69
      Del          : constant := 1.0/10**2;
70
      Const_Digits : constant :=  3;
71
      Two          : constant :=  2;
72
      Ten          : constant := 10;
73
 
74
      type Radix_2_Type_1  is delta 0.01  digits 7;
75
      type Radix_2_Type_2  is delta Ada.Decimal.Min_Delta digits 10;
76
      type Radix_2_Type_3  is
77
        delta 0.000_1 digits Ada.Decimal.Max_Decimal_Digits;
78
 
79
      type Radix_10_Type_1 is delta 10.0**(-Ada.Decimal.Max_Scale) digits 8;
80
      type Radix_10_Type_2 is delta 10.0**(-Ada.Decimal.Min_Scale) digits 6;
81
      type Radix_10_Type_3 is delta Ada.Decimal.Max_Delta digits 15;
82
 
83
 
84
      -- Use an attribute definition clause to set the Machine_Radix for a
85
      -- decimal first subtype to either 2 or 10.
86
      for Radix_2_Type_1'Machine_Radix  use 2;
87
      for Radix_2_Type_2'Machine_Radix  use Two;
88
      for Radix_2_Type_3'Machine_Radix  use 10-8;
89
 
90
      for Radix_10_Type_1'Machine_Radix use 2*15/Const_Digits;
91
      for Radix_10_Type_2'Machine_Radix use Ten;
92
      for Radix_10_Type_3'Machine_Radix use Radix_10_Type_2'Machine_Radix;
93
 
94
 
95
   begin
96
 
97
      -- Check that the attribute 'Machine_Radix returns the value assigned
98
      -- by the attribute definition clause.
99
 
100
      if Radix_2_Type_1'Machine_Radix /= 2  or else
101
         Radix_2_Type_2'Machine_Radix /= 2  or else
102
         Radix_2_Type_3'Machine_Radix /= 2
103
      then
104
         Report.Failed("Incorrect radix value returned, 2 expected");
105
      end if;
106
 
107
      if Radix_10_Type_1'Machine_Radix /= 10  or else
108
         Radix_10_Type_2'Machine_Radix /= 10  or else
109
         Radix_10_Type_3'Machine_Radix /= 10
110
      then
111
         Report.Failed("Incorrect radix value returned, 10 expected");
112
      end if;
113
 
114
   exception
115
      when others => Report.Failed ("Exception raised in Attr_Check_Block");
116
   end Attribute_Check_Block;
117
 
118
 
119
 
120
   Radix_Block:
121
   -- Premises:
122
   --   1) Choose several numbers, from types using either decimal scaling or
123
   --      binary scaling.
124
   --   1) Repetitively add these numbers to themselves.
125
   --   3) Validate that the result is the expected result, regardless of the
126
   --      scaling used in the definition of the type.
127
   declare
128
 
129
      Number_Of_Values : constant :=    3;
130
      Loop_Count       : constant := 1000;
131
 
132
      type Radix_2_Type  is delta 0.0001 digits 10;
133
      type Radix_10_Type is delta 0.0001 digits 10;
134
 
135
      for Radix_2_Type'Machine_Radix  use  2;
136
      for Radix_10_Type'Machine_Radix use 10;
137
 
138
      type Result_Record_Type is record
139
         Rad_2  : Radix_2_Type;
140
         Rad_10 : Radix_10_Type;
141
      end record;
142
 
143
      type Result_Array_Type is array (1..Number_Of_Values)
144
        of Result_Record_Type;
145
 
146
      Result_Array : Result_Array_Type := ((50.00,  50.00),
147
                                           (613.00, 613.00),
148
                                           (72.70,  72.70));
149
 
150
      function Repetitive_Radix_2_Add (Value : in Radix_2_Type)
151
        return Radix_2_Type is
152
         Result : Radix_2_Type := 0.0;
153
      begin
154
        for i in 1..Loop_Count loop
155
           Result := Result + Value;
156
        end loop;
157
        return Result;
158
      end Repetitive_Radix_2_Add;
159
 
160
      function Repetitive_Radix_10_Add (Value : in Radix_10_Type)
161
        return Radix_10_Type is
162
         Result : Radix_10_Type := 0.0;
163
      begin
164
        for i in 1..Loop_Count loop
165
           Result := Result + Value;
166
        end loop;
167
        return Result;
168
      end Repetitive_Radix_10_Add;
169
 
170
   begin
171
 
172
      -- Radix 2 Cases, three different values.
173
      -- Compare the result of the repetitive addition with the expected
174
      -- Radix 2 result, as well as with the Radix 10 value after type
175
      -- conversion.
176
 
177
      if Repetitive_Radix_2_Add(0.05) /= Result_Array(1).Rad_2  or
178
         Repetitive_Radix_2_Add(0.05) /= Radix_2_Type(Result_Array(1).Rad_10)
179
      then
180
         Report.Failed("Incorrect Radix 2 Result, Case 1");
181
      end if;
182
 
183
      if Repetitive_Radix_2_Add(0.613) /=
184
         Result_Array(2).Rad_2            or
185
         Repetitive_Radix_2_Add(0.613) /=
186
         Radix_2_Type(Result_Array(2).Rad_10)
187
      then
188
         Report.Failed("Incorrect Radix 2 Result, Case 2");
189
      end if;
190
 
191
      if Repetitive_Radix_2_Add(0.0727)  /=
192
         Result_Array(3).Rad_2              or
193
         Repetitive_Radix_2_Add(0.0727)  /=
194
         Radix_2_Type(Result_Array(3).Rad_10)
195
      then
196
         Report.Failed("Incorrect Radix 2 Result, Case 3");
197
      end if;
198
 
199
      -- Radix 10 Cases, three different values.
200
      -- Compare the result of the repetitive addition with the expected
201
      -- Radix 10 result, as well as with the Radix 2 value after type
202
      -- conversion.
203
 
204
      if Repetitive_Radix_10_Add(0.05) /= Result_Array(1).Rad_10  or
205
         Repetitive_Radix_10_Add(0.05) /= Radix_10_Type(Result_Array(1).Rad_2)
206
      then
207
         Report.Failed("Incorrect Radix 10 Result, Case 1");
208
      end if;
209
 
210
      if Repetitive_Radix_10_Add(0.613) /=
211
         Result_Array(2).Rad_10            or
212
         Repetitive_Radix_10_Add(0.613) /=
213
         Radix_10_Type(Result_Array(2).Rad_2)
214
      then
215
         Report.Failed("Incorrect Radix 10 Result, Case 2");
216
      end if;
217
 
218
      if Repetitive_Radix_10_Add(0.0727) /=
219
         Result_Array(3).Rad_10             or
220
         Repetitive_Radix_10_Add(0.0727) /=
221
         Radix_10_Type(Result_Array(3).Rad_2)
222
      then
223
         Report.Failed("Incorrect Radix 10 Result, Case 3");
224
      end if;
225
 
226
   exception
227
      when others => Report.Failed ("Exception raised in Radix_Block");
228
   end Radix_Block;
229
 
230
 
231
 
232
   Size_Block:
233
   -- Check the implementation max/min values of constants declared in
234
   -- package Ada.Decimal.
235
   declare
236
      Minimum_Required_Size : constant := 18;
237
      Maximum_Allowed_Size  : constant :=  0;
238
   begin
239
 
240
      -- Check that the Max_Decimal_Digits value is at least 18.
241
      if not (Ada.Decimal.Max_Decimal_Digits >= Minimum_Required_Size) then
242
         Report.Failed("Insufficient size provided for Max_Decimal_Digits");
243
      end if;
244
 
245
      -- Check that the Max_Scale value is at least 18.
246
      if not (Ada.Decimal.Max_Scale >= Minimum_Required_Size) then
247
         Report.Failed("Insufficient size provided for Max_Scale");
248
      end if;
249
 
250
      -- Check that the Min_Scale value is at most 0.
251
      if not (Ada.Decimal.Min_Scale <= Maximum_Allowed_Size) then
252
         Report.Failed("Too large a value provided for Min_Scale");
253
      end if;
254
 
255
   exception
256
      when others => Report.Failed ("Exception raised in Size_Block");
257
   end Size_Block;
258
 
259
   Report.Result;
260
 
261
end CXF1001;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.