Debian Codegraph @

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

raw
1 (* Copyright (C) 2009 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 arith5 ;
19
20 FROM libc IMPORT printf ;
21 FROM M2RTS IMPORT Halt ;
22
23 CONST
24 i = CMPLX (0.0, 1.0) ;
25 one = CMPLX (1.0, 0.0) ;
26 two = CMPLX (2.0, 0.0) ;
27 zero = CMPLX (0.0, 0.0) ;
28 three= CMPLX (3.0, 0.0) ;
29 foo = CMPLX (4.0, 1.0) ;
30
31
32 PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ;
33 BEGIN
34 IF NOT b
35 THEN
36 Halt ('failure', __FILE__, __FUNCTION__, l)
37 END
38 END Assert ;
39
40 PROCEDURE getOne () : LONGCOMPLEX ;
41 BEGIN
42 RETURN one
43 END getOne ;
44
45 VAR
46 a, b, c, d: LONGCOMPLEX ;
47 BEGIN
48 a := i ;
49 b := a*getOne() ;
50 c := i*i ;
51 d := -one ;
52
53 Assert(c=-one, __LINE__) ;
54
55 Assert(c=d, __LINE__) ;
56
57 printf("RE(foo) = %Lg\n", RE(foo)) ;
58 printf("IM(foo) = %Lg\n", IM(foo)) ;
59
60 printf("RE(i*i) = %Lg\n", RE(i*i)) ;
61 printf("IM(i*i) = %Lg\n", IM(i*i)) ;
62
63 printf("RE(-one) = %Lg\n", RE(-one)) ;
64 printf("IM(-one) = %Lg\n", IM(-one)) ;
65
66 Assert(i*i=-one, __LINE__)
67 END arith5.