1-- C45304C.DEP
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-- OBJECTIVE:
26--     CHECK THAT CONSTRAINT_ERROR IS RAISED BY
27--     "+" AND "-" FOR PREDEFINED LONG_INTEGER WHEN THE RESULT IS
28--     OUTSIDE THE RANGE OF THE BASE TYPE.
29
30-- APPLICABILITY CRITERIA:
31--     THIS TEST IS APPLICABLE IF THE IMPLEMENTATION HAS A
32--     PREDEFINED TYPE LONG_INTEGER.
33
34--     IF LONG_INTEGER IS NOT SUPPORTED, THEN THE DECLARATION OF
35--     "TEST_VAR" MUST BE REJECTED.
36
37-- *** NOTE: This test has been modified since ACVC version 1.11 to    -- 9X
38-- ***       remove incompatibilities associated with the transition   -- 9X
39-- ***       to Ada 9X.                                                -- 9X
40
41-- HISTORY:
42--     TBN 10/07/86  CREATED ORIGINAL TEST.
43--     JET 12/30/87  ADDED CODE TO PREVENT OPTIMIZATION.
44--     JRL 03/30/93 REMOVED NUMERIC_ERROR FROM TEST.
45
46WITH REPORT; USE REPORT;
47PROCEDURE C45304C IS
48
49     TEST_VAR : LONG_INTEGER;               -- N/A => ERROR.
50
51     -- THESE FUNCTIONS ARE TO PREVENT OPTIMIZATION.
52
53     FUNCTION IDENT_LONG (X : LONG_INTEGER) RETURN LONG_INTEGER IS
54     BEGIN
55          IF EQUAL (3, 3) THEN
56               RETURN X;
57          ELSE
58               RETURN 0;
59          END IF;
60     END IDENT_LONG;
61
62     FUNCTION LONG_OK (X : LONG_INTEGER) RETURN BOOLEAN IS
63     BEGIN
64          RETURN X = IDENT_LONG(X);
65     END LONG_OK;
66
67BEGIN
68     TEST ("C45304C", "CHECK THAT CONSTRAINT_ERROR " &
69                      "IS RAISED BY ""+"" AND ""-"" FOR PREDEFINED " &
70                      "LONG_INTEGER WHEN THE RESULT IS OUTSIDE THE " &
71                      "RANGE OF THE BASE TYPE");
72
73     DECLARE
74          B : LONG_INTEGER := LONG_INTEGER'LAST;
75     BEGIN
76          IF LONG_OK (B + IDENT_LONG(1)) THEN
77               FAILED ("NO EXCEPTION RAISED FOR ADDITION - " &
78                       "LONG_OK RETURNS TRUE");
79          ELSE
80               FAILED ("NO EXCEPTION RAISED FOR ADDITION - " &
81                       "LONG_OK RETURNS FALSE");
82          END IF;
83
84     EXCEPTION
85          WHEN CONSTRAINT_ERROR =>
86               NULL;
87          WHEN OTHERS =>
88               FAILED ("UNEXPECTED EXCEPTION RAISED - 1");
89     END;
90
91     DECLARE
92          B : LONG_INTEGER := LONG_INTEGER'FIRST;
93     BEGIN
94          IF LONG_OK (B - IDENT_LONG(1)) THEN
95               FAILED ("NO EXCEPTION RAISED FOR SUBTRACTION - " &
96                       "LONG_OK RETURNS TRUE");
97          ELSE
98               FAILED ("NO EXCEPTION RAISED FOR SUBTRACTION - " &
99                       "LONG_OK RETURNS FALSE");
100          END IF;
101
102     EXCEPTION
103          WHEN CONSTRAINT_ERROR =>
104               NULL;
105          WHEN OTHERS =>
106               FAILED ("UNEXPECTED EXCEPTION RAISED - 2");
107     END;
108
109     RESULT;
110END C45304C;
111