Debian Codegraph @

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

raw
1 MODULE testchar ;
2
3 FROM FIO IMPORT File, OpenToWrite, OpenToRead,
4 Close, WriteChar, ReadChar, IsNoError ;
5
6 FROM libc IMPORT printf, exit ;
7
8
9 (*
10 createFile -
11 *)
12
13 PROCEDURE createFile ;
14 VAR
15 fo: File ;
16 ch: CHAR ;
17 BEGIN
18 fo := OpenToWrite ("test.txt") ;
19 FOR ch := MIN (CHAR) TO MAX (CHAR) DO
20 WriteChar (fo, ch) ;
21 IF NOT IsNoError (fo)
22 THEN
23 printf ("failure to write: %c\n", ch);
24 exit (1)
25 END
26 END ;
27 Close (fo)
28 END createFile ;
29
30
31 (*
32 readFile -
33 *)
34
35 PROCEDURE readFile ;
36 VAR
37 fi : File ;
38 ch, in: CHAR ;
39 BEGIN
40 fi := OpenToRead ("test.txt") ;
41 FOR ch := MIN (CHAR) TO MAX (CHAR) DO
42 in := ReadChar (fi) ;
43 IF NOT IsNoError (fi)
44 THEN
45 printf ("failure to read: %c\n", ch);
46 exit (1)
47 END ;
48 IF ch # in
49 THEN
50 printf ("failure to verify: %c\n", ch);
51 exit (1)
52 END
53 END ;
54 Close (fi)
55 END readFile ;
56
57
58 (*
59 init -
60 *)
61
62 PROCEDURE init ;
63 BEGIN
64 createFile ;
65 readFile
66 END init ;
67
68
69 BEGIN
70 init
71 END testchar.