Debian Codegraph @

gcc/testsuite/gm2/pimlib/run/pass/limittests.mod

raw
1 (* Copyright (C) 2017 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 3, 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,
17 Boston, MA 02110-1301, USA. *)
18
19 MODULE limittests ;
20
21 FROM Builtins IMPORT isfinite ;
22 FROM FpuIO IMPORT WriteLongReal, LongRealToStr ;
23 FROM StrLib IMPORT StrEqual ;
24 FROM libc IMPORT exit, printf ;
25 FROM StrIO IMPORT WriteLn ;
26 FROM FIO IMPORT FlushBuffer, StdOut ;
27
28
29 PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ;
30 BEGIN
31 IF NOT b
32 THEN
33 FlushBuffer (StdOut) ;
34 printf ("%s:%d:regression test failed during execution\n",
35 __FILE__, l) ;
36 r := 1
37 END
38 END Assert ;
39
40
41 VAR
42 a: REAL;
43 r: INTEGER ;
44 BEGIN
45 r := 0 ;
46 a := 1.0 / 0.0 ;
47 IF isfinite (a) = 0
48 THEN
49 printf ("detected infinite number\n")
50 ELSE
51 printf ("failed to detect infinite number\n") ;
52 r := 1
53 END ;
54 a := 1.0 / 1.0 ;
55 IF isfinite (a) = 1
56 THEN
57 printf ("detected finite number\n")
58 ELSE
59 printf ("failed to detect finite number\n") ;
60 r := 2
61 END ;
62 IF r = 0
63 THEN
64 printf ("all tests passed\n")
65 END ;
66 exit (r)
67 END limittests.