xref: /original-bsd/usr.bin/f77/tests/tests/fm014.f (revision fa921481)
1c
2c     comment section.
3c
4c     fm014
5c
6c             this routine tests the fortran   computed go to statement.
7c     because the form of the computed go to is so straightforward, the
8c     tests mainly relate to the range of possible statement numbers
9c     which are used.
10c
11c      references
12c        american national standard programming language fortran,
13c              x3.9-1978
14c
15c        section 11.2, computed go to statement
16c
17c
18c      **********************************************************
19c
20c         a compiler validation system for the fortran language
21c     based on specifications as defined in american national standard
22c     programming language fortran x3.9-1978, has been developed by the
23c     federal cobol compiler testing service.  the fortran compiler
24c     validation system (fcvs) consists of audit routines, their related
25c     data, and an executive system.  each audit routine is a fortran
26c     program, subprogram or function which includes tests of specific
27c     language elements and supporting procedures indicating the result
28c     of executing these tests.
29c
30c         this particular program/subprogram/function contains features
31c     found only in the subset as defined in x3.9-1978.
32c
33c         suggestions and comments should be forwarded to -
34c
35c                  department of the navy
36c                  federal cobol compiler testing service
37c                  washington, d.c.  20376
38c
39c      **********************************************************
40c
41c
42c
43c     initialization section
44c
45c     initialize constants
46c      **************
47c     i01 contains the logical unit number for the card reader.
48      i01 = 5
49c     i02 contains the logical unit number for the printer.
50      i02 = 6
51c     system environment section
52c
53cx010    this card is replaced by contents of fexec x-010 control card.
54c     the cx010 card is for overriding the program default i01 = 5
55c     (unit number for card reader).
56cx011    this card is replaced by contents of fexec x-011 control card.
57c     the cx011 card is for systems which require additional
58c     fortran statements for files associated with cx010 above.
59c
60cx020    this card is replaced by contents of fexec x-020 control card.
61c     the cx020 card is for overriding the program default i02 = 6
62c     (unit number for printer).
63cx021    this card is replaced by contents of fexec x-021 control card.
64c     the cx021 card is for systems which require additional
65c     fortran statements for files associated with cx020 above.
66c
67      ivpass=0
68      ivfail=0
69      ivdele=0
70      iczero=0
71c
72c     write page headers
73      write (i02,90000)
74      write (i02,90001)
75      write (i02,90002)
76      write (i02, 90002)
77      write (i02,90003)
78      write (i02,90002)
79      write (i02,90004)
80      write (i02,90002)
81      write (i02,90011)
82      write (i02,90002)
83      write (i02,90002)
84      write (i02,90005)
85      write (i02,90006)
86      write (i02,90002)
87      ivtnum = 131
88c
89c     test 131  -  test of the simplist form of the computed go to
90c           statement with three possible branches.
91c
92c
93      if (iczero) 31310, 1310, 31310
94 1310 continue
95      icon01=0
96      i=3
97      go to ( 1312, 1313, 1314 ), i
98 1312 icon01 = 1312
99      go to 1315
100 1313 icon01 = 1313
101      go to 1315
102 1314 icon01 = 1314
103 1315 continue
104      go to 41310
10531310 ivdele = ivdele + 1
106      write (i02,80003) ivtnum
107      if (iczero) 41310, 1321, 41310
10841310 if ( icon01 - 1314 )  21310, 11310, 21310
10911310 ivpass = ivpass + 1
110      write (i02,80001) ivtnum
111      go to 1321
11221310 ivfail = ivfail + 1
113      ivcomp=icon01
114      ivcorr = 1314
115      write (i02,80004) ivtnum, ivcomp ,ivcorr
116 1321 continue
117      ivtnum = 132
118c
119c     test 132  -  this tests the computed go to in conjunction with the
120c           the unconditional go to statement.  this test is not
121c           intended to be an example of good structured programming.
122c
123c
124      if (iczero) 31320, 1320, 31320
125 1320 continue
126      ivon01=0
127      j=1
128      go to 1326
129 1322 j = 2
130      ivon01=ivon01+2
131      go to 1326
132 1323 j = 3
133      ivon01=ivon01 * 10 + 3
134      go to 1326
135 1324 j = 4
136      ivon01=ivon01 * 100 + 4
137      go to 1326
138 1325 ivon01 = ivon01 + 1
139      go to 1327
140 1326 go to ( 1322, 1323, 1324, 1325, 1326 ), j
141 1327 continue
142      go to 41320
14331320 ivdele = ivdele + 1
144      write (i02,80003) ivtnum
145      if (iczero) 41320, 1331, 41320
14641320 if ( ivon01 - 2305 )  21320, 11320, 21320
14711320 ivpass = ivpass + 1
148      write (i02,80001) ivtnum
149      go to 1331
15021320 ivfail = ivfail + 1
151      ivcomp=ivon01
152      ivcorr=2305
153      write (i02,80004) ivtnum, ivcomp ,ivcorr
154 1331 continue
155      ivtnum = 133
156c
157c     test 133  -  this is a test of the computed go to statement with
158c           a single statement label as the list of possible branches.
159c
160c
161      if (iczero) 31330, 1330, 31330
162 1330 continue
163      ivon01=0
164      k=1
165      go to ( 1332 ), k
166 1332 ivon01 = 1
167      go to 41330
16831330 ivdele = ivdele + 1
169      write (i02,80003) ivtnum
170      if (iczero) 41330, 1341, 41330
17141330 if ( ivon01 - 1 )  21330, 11330, 21330
17211330 ivpass = ivpass + 1
173      write (i02,80001) ivtnum
174      go to 1341
17521330 ivfail = ivfail + 1
176      ivcomp=ivon01
177      ivcorr=1
178      write (i02,80004) ivtnum, ivcomp ,ivcorr
179 1341 continue
180      ivtnum = 134
181c
182c     test 134  -  this is a test of five (5) digit statement numbers
183c           which exceed the integer 32767 used in the computed go to
184c           statement with three possible branches.
185c
186c
187      if (iczero) 31340, 1340, 31340
188 1340 continue
189      ivon01=0
190      l=2
191      go to ( 99991, 99992, 99993 ), l
19299991 ivon01=1
193      go to 1342
19499992 ivon01=2
195      go to 1342
19699993 ivon01=3
197 1342 continue
198      go to 41340
19931340 ivdele = ivdele + 1
200      write (i02,80003) ivtnum
201      if (iczero) 41340, 1351, 41340
20241340 if ( ivon01 - 2 )  21340, 11340, 21340
20311340 ivpass = ivpass + 1
204      write (i02,80001) ivtnum
205      go to 1351
20621340 ivfail = ivfail + 1
207      ivcomp=ivon01
208      ivcorr=2
209      write (i02,80004) ivtnum, ivcomp ,ivcorr
210 1351 continue
211c
212c     write page footings and run summaries
21399999 continue
214      write (i02,90002)
215      write (i02,90006)
216      write (i02,90002)
217      write (i02,90002)
218      write (i02,90007)
219      write (i02,90002)
220      write (i02,90008)  ivfail
221      write (i02,90009) ivpass
222      write (i02,90010) ivdele
223c
224c
225c     terminate routine execution
226      stop
227c
228c     format statements for page headers
22990000 format (1h1)
23090002 format (1h )
23190001 format (1h ,10x,34hfortran compiler validation system)
23290003 format (1h ,21x,11hversion 1.0)
23390004 format (1h ,10x,38hfor official use only - copyright 1978)
23490005 format (1h ,5x,4htest,5x,9hpass/fail, 5x,8hcomputed,8x,7hcorrect)
23590006 format (1h ,5x,46h----------------------------------------------)
23690011 format (1h ,18x,17hsubset level test)
237c
238c     format statements for run summaries
23990008 format (1h ,15x,i5,19h errors encountered)
24090009 format (1h ,15x,i5,13h tests passed)
24190010 format (1h ,15x,i5,14h tests deleted)
242c
243c     format statements for test results
24480001 format (1h ,4x,i5,7x,4hpass)
24580002 format (1h ,4x,i5,7x,4hfail)
24680003 format (1h ,4x,i5,7x,7hdeleted)
24780004 format (1h ,4x,i5,7x,4hfail,10x,i6,9x,i6)
24880005 format (1h ,4x,i5,7x,4hfail,4x,e12.5,3x,e12.5)
249c
25090007 format (1h ,20x,20hend of program fm014)
251      end
252