Debian Codegraph @

gcc/testsuite/gm2/pimlib/logitech/run/pass/realinput2.mod

raw
1 (* Copyright (C) 2009-2020 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 realinput2 ;
19
20 FROM RealInOut IMPORT ReadReal ;
21 FROM FIO IMPORT FlushBuffer, StdOut, StdIn ;
22 FROM PushBackInput IMPORT PutString, PutCh, GetCh ;
23 FROM ASCII IMPORT lf ;
24 FROM Termbase IMPORT ReadProcedure, AssignRead ;
25 FROM libc IMPORT exit, printf ;
26
27
28 PROCEDURE Assert (b: BOOLEAN; l: CARDINAL) ;
29 BEGIN
30 IF NOT b
31 THEN
32 FlushBuffer(StdOut) ;
33 printf("%s:%d:regression test failed during execution\n",
34 __FILE__, l) ;
35 exit(1)
36 END
37 END Assert ;
38
39
40 (*
41 MyRead -
42 *)
43
44 PROCEDURE MyRead (VAR ch: CHAR) ;
45 BEGIN
46 ch := GetCh(StdIn)
47 END MyRead ;
48
49
50 PROCEDURE Status () : BOOLEAN ;
51 BEGIN
52 RETURN( TRUE )
53 END Status ;
54
55 VAR
56 x : REAL ;
57 ch: CHAR ;
58 ok: BOOLEAN ;
59 BEGIN
60 AssignRead(MyRead, Status, ok) ;
61 ch := PutCh(lf) ;
62 PutString("0.0123") ;
63 ReadReal(x) ;
64 Assert(x=0.0123, __LINE__)
65 END realinput2.