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/] [cxa/] [cxaa014.a] - Blame information for rev 154

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
-- CXAA014.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 the exception Mode_Error is raised when an attempt is made
28
--      to check for the end of a line or page using the predefined functions
29
--      End_Of_Line or End_Of_Page on a text file with mode Append_File.
30
--
31
-- TEST DESCRIPTION:
32
--      A scenario is created that demonstrates the potential for the
33
--      incorrect usage of predefined text processing subprograms, which
34
--      results in the raising of a Mode_Error exception.
35
--      A count is kept to ensure that each anticipated exception is in fact
36
--      raised and handled properly.
37
--
38
-- APPLICABILITY CRITERIA:
39
--      This test is applicable only to implementations that support text
40
--      files.
41
--
42
--
43
-- CHANGE HISTORY:
44
--      06 Dec 94   SAIC    ACVC 2.0
45
--      28 Feb 97   PWB.CTA Allowed for non-support of some IO operations
46
--!
47
 
48
with Ada.Text_IO;
49
with Report;
50
 
51
procedure CXAA014 is
52
   use Ada;
53
   Text_File     : Text_IO.File_Type;
54
   Text_Filename : constant String :=
55
                              Report.Legal_File_Name ( Nam => "CXAA014" );
56
   Incomplete : exception;
57
 
58
begin
59
 
60
         Report.Test ("CXAA014", "Check that the exception Mode_Error is "  &
61
                                 "raised when an attempt is made to check " &
62
                                 "for the end of a line or page using the " &
63
                                 "predefined functions End_Of_Line or "     &
64
                                 "End_Of_Page on a text file with mode "    &
65
                                 "Append_File");
66
 
67
         Test_for_Text_IO_Support:
68
         begin
69
 
70
-- Use_Error will be raised if Text_IO operations or external files are not
71
-- supported.
72
 
73
            Text_IO.Create (Text_File, Text_IO.Out_File, Text_Filename);
74
 
75
   exception
76
 
77
       when Text_IO.Use_Error | Text_IO.Name_Error =>
78
          Report.Not_Applicable
79
             ( "Files not supported - Create as Out_File for Text_IO" );
80
          raise Incomplete;
81
 
82
   end Test_for_Text_IO_Support;
83
 
84
 
85
-- The application writes some amount of data to the file.
86
 
87
            for I in 1 .. 10 loop
88
               Text_IO.Put_Line (Text_File, "Data entered into the file");
89
            end loop;
90
 
91
            Text_IO.Close (Text_File);
92
 
93
            Operational_Test_Block:
94
            declare
95
               TC_Number_Of_Forced_Mode_Errors : constant Natural := 2;
96
               TC_Mode_Errors : Natural := 0;
97
            begin
98
 
99
               Text_IO.Open (Text_File, Text_IO.Append_File, Text_Filename);
100
 
101
               Test_for_End_Of_Line:
102
               declare
103
                  TC_End_Of_Line : Boolean;
104
               begin
105
 
106
-- During the course of its processing, the application may attempt to
107
-- invoke the End_Of_Line function on a file that is currently in Append_File
108
-- mode (instead of the anticipated In_File mode).  This results in the
109
-- raising of Mode_Error.
110
 
111
                  TC_End_Of_Line := Text_IO.End_Of_Line (Text_File);
112
                  Report.Failed ("Exception not raised by End_Of_Line");
113
 
114
-- An exception handler present within the application handles the exception
115
-- and processing can continue.
116
 
117
               exception
118
                  when Text_IO.Mode_Error =>
119
                     TC_Mode_Errors := TC_Mode_Errors + 1;
120
                  when others =>
121
                     Report.Failed("Exception in End_Of_Line processing");
122
               end Test_for_End_Of_Line;
123
 
124
 
125
               Test_for_End_Of_Page:
126
               declare
127
                  TC_End_Of_Page : Boolean;
128
               begin
129
 
130
-- Again, during the course of its processing, the application incorrectly
131
-- assumes that the file mode is In_File, this time attempting to call the
132
-- End_Of_Page function for the file (that is currently in Append_File mode).
133
 
134
                  TC_End_Of_Page := Text_IO.End_Of_Page (Text_File);
135
                  Report.Failed ("Exception not raised by End_Of_Page");
136
 
137
-- Once again, an exception handler present within the application handles
138
-- the exception and processing continues.
139
 
140
               exception
141
                  when Text_IO.Mode_Error =>
142
                     TC_Mode_Errors := TC_Mode_Errors + 1;
143
                  when others =>
144
                     Report.Failed("Exception in End_Of_Page processing");
145
               end Test_for_End_Of_Page;
146
 
147
 
148
               if (TC_Mode_Errors /= TC_Number_Of_Forced_Mode_Errors) then
149
                  Report.Failed ("Incorrect number of exceptions handled");
150
               end if;
151
 
152
            end Operational_Test_Block;
153
 
154
            Deletion:
155
            begin
156
               -- Delete the external file.
157
               if Text_IO.Is_Open (Text_File) then
158
                  Text_IO.Delete (Text_File);
159
               else
160
                  Text_IO.Open (Text_File, Text_IO.In_File, Text_Filename);
161
                  Text_IO.Delete (Text_File);
162
               end if;
163
            exception
164
               when others =>
165
                  Report.Failed
166
                     ( "Delete not properly implemented for Text_IO" );
167
            end Deletion;
168
 
169
         Report.Result;
170
 
171
exception
172
   when Incomplete =>
173
      Report.Result;
174
   when others     =>
175
      Report.Failed ( "Unexpected exception" );
176
      Report.Result;
177
 
178
end CXAA014;

powered by: WebSVN 2.1.0

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