Debian Codegraph @

gcc/testsuite/gm2/isolib/run/pass/skiplinetest.mod

raw
1 MODULE skiplinetest ;
2
3 FROM ChanConsts IMPORT OpenResults, old, read, write;
4 FROM IOChan IMPORT ChanId;
5 FROM StdChans IMPORT StdOutChan ;
6 IMPORT StreamFile;
7 FROM TextIO IMPORT ReadString, SkipLine, WriteLn, WriteString;
8 FROM StrLib IMPORT StrEqual ;
9 FROM libc IMPORT exit, printf ;
10
11
12 PROCEDURE StressSkip ;
13 VAR
14 stdout,
15 cid : ChanId;
16 filename: ARRAY [0..20] OF CHAR ;
17 str : ARRAY [0..79] OF CHAR ;
18 result : OpenResults;
19 BEGIN
20 stdout := StdOutChan();
21 filename := 'testdata';
22
23 StreamFile.Open (cid, filename, write+old, result) ;
24 IF result = opened
25 THEN
26 WriteString (cid, '# line1');
27 WriteLn (cid);
28 WriteString (cid, '# line2');
29 WriteLn (cid) ;
30 StreamFile.Close (cid);
31 END ;
32
33 StreamFile.Open (cid, filename, read, result) ;
34 IF result = opened
35 THEN
36 SkipLine (cid);
37 ReadString (cid, str);
38 IF NOT StrEqual (str, '# line2')
39 THEN
40 printf ("ReadString failed, read %s\n", str) ;
41 exit (1)
42 END ;
43 WriteString (stdout, str);
44 WriteLn (stdout) ;
45 StreamFile.Close (cid)
46 END
47 END StressSkip ;
48
49
50 BEGIN
51 StressSkip
52 END skiplinetest.