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