Debian Codegraph @

gcc/testsuite/gm2/pim/run/pass/For8.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 For8 ;
19
20 FROM libc IMPORT exit, printf ;
21 FROM SYSTEM IMPORT ADR ;
22 (* FROM EndFor IMPORT CheckLongintLongint ; *)
23
24 CONST
25 Check = TRUE ;
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 (%s)\n", ADR(e))
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 := -256000000000 TO 256000000000 BY 64000000000 DO
51 j := i ;
52 Assert(c<10, __FILE__, __LINE__, "for loop executed too many times") ;
53 INC(c) ;
54 (* CheckLongintLongint(i, 64000000000) *)
55 END ;
56 Assert(c=9, __FILE__, __LINE__, "for loop executed too few times") ;
57 Assert(i=256000000000, __FILE__, __LINE__, "for loop index") ;
58 exit(res)
59 END For8.