Debian Codegraph @

gcc/testsuite/gm2/pim/options/optimize/run/pass/testadd.mod

raw
1 (* Copyright (C) 2005, 2006, 2007, 2008 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 testadd ;
19
20 FROM addition IMPORT add ;
21
22 FROM libc IMPORT exit, printf ;
23 FROM SYSTEM IMPORT ADR ;
24
25 VAR
26 res: INTEGER ;
27
28 PROCEDURE Assert (v: BOOLEAN; f: ARRAY OF CHAR; l: CARDINAL; e: ARRAY OF CHAR) ;
29 VAR
30 r: INTEGER ;
31 BEGIN
32 IF v
33 THEN
34 r := printf("successfully evaluated assertion (%s)\n", ADR(e))
35 ELSE
36 r := printf("%s:%d assertion failed when evaluating %s\n", ADR(f), l, ADR(e)) ;
37 res := 1
38 END
39 END Assert ;
40
41
42 BEGIN
43 res := 0 ;
44 Assert(add(1, 2)=3, __FILE__, __LINE__, "3") ;
45 Assert(add(2, 1)=3, __FILE__, __LINE__, "3") ;
46 Assert(add(0, 1)=1, __FILE__, __LINE__, "1") ;
47 Assert(add(0, 0)=0, __FILE__, __LINE__, "0") ;
48 Assert(add(1024, 1024)=2048, __FILE__, __LINE__, "2048") ;
49 Assert(add(10000, 20000)=30000, __FILE__, __LINE__, "30000") ;
50 exit(res)
51 END testadd.