Debian Codegraph @

gcc/testsuite/gm2/pim/run/pass/For7.mod

raw
1 (* Copyright (C) 2005, 2006 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 MODULE For7 ;
19
20 FROM libc IMPORT exit, printf ;
21 FROM SYSTEM IMPORT ADR ;
22 (* FROM EndFor IMPORT CheckLongintInteger ; *)
23
24 CONST
25 PseudoCheck = FALSE ;
26
27 VAR
28 res: INTEGER ;
29
30 PROCEDURE Assert (v: BOOLEAN; f: ARRAY OF CHAR; l: CARDINAL; e: ARRAY OF CHAR) ;
31 VAR
32 r: INTEGER ;
33 BEGIN
34 IF v
35 THEN
36 r := printf("successfully evaluated assertion\n")
37 ELSE
38 r := printf("%s:%d assertion failed when evaluating %s\n", ADR(f), l, ADR(e)) ;
39 res := 1
40 END
41 END Assert ;
42
43 VAR
44 c : INTEGER ;
45 n, i, j: LONGINT ;
46 BEGIN
47 res := 0 ;
48 n := 4 ;
49 c := 0 ;
50 FOR i := -256 TO 256 BY 64 DO
51 printf("i = %d\n", i);
52 j := i ;
53 Assert(c<10, __FILE__, __LINE__, "for loop executed too many times") ;
54 INC(c) ;
55 (* CheckLongintInteger(i, 64) *)
56 END ;
57 Assert(c=9, __FILE__, __LINE__, "for loop executed too few times") ;
58 Assert(i=256, __FILE__, __LINE__, "for loop index") ;
59 exit(res)
60 END For7.