Debian Codegraph @

gcc/testsuite/gm2/complex/run/pass/arith3.mod

raw
1 (* Copyright (C) 2009-2021 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 arith3 ;
19
20 FROM M2RTS IMPORT Halt ;
21 FROM libc IMPORT printf ;
22
23 CONST
24 i = CMPLX (0.0, 1.0) ;
25 one = CMPLX (1.0, 0.0) ;
26 zero = CMPLX (0.0, 0.0) ;
27
28 PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ;
29 BEGIN
30 IF NOT b
31 THEN
32 Halt ('failure', __FILE__, __FUNCTION__, l)
33 END
34 END Assert ;
35
36 PROCEDURE getOne () : COMPLEX ;
37 BEGIN
38 RETURN one
39 END getOne ;
40
41 VAR
42 a, b, c: COMPLEX ;
43 BEGIN
44 printf ("main module starting\n");
45 printf ("a := i\n");
46 a := i ;
47 printf ("b := a*getOne()\n");
48 b := a*getOne() ;
49 printf ("c := i*i\n");
50 c := i*i ;
51
52 printf ("Assert (c=-one)\n");
53 Assert(c=-one, __LINE__) ;
54
55 printf ("Assert (i*i=-one)\n");
56 Assert(i*i=-one, __LINE__) ;
57 printf ("main module finishing, all done\n");
58 END arith3.