Browse Source

some bug #896 related tests

pierre 25 years ago
parent
commit
7a5fcf6931
3 changed files with 66 additions and 0 deletions
  1. 16 0
      tests/webtbf/tbug896.pp
  2. 16 0
      tests/webtbf/tbug896a.pp
  3. 34 0
      tests/webtbs/tbug896.pp

+ 16 - 0
tests/webtbf/tbug896.pp

@@ -0,0 +1,16 @@
+
+var
+  dat : file;
+  j : longint;
+  Buffer : Array[0..2047] of byte;
+
+begin
+  for j:=0 to 2047 do
+    Buffer[j]:=j and $ff;
+  Assign(dat,'tbug896.txt');
+  Rewrite(dat,1);
+  for j:= 0 to 2047 do
+  { write should not be allowed for untyped files }
+    write (dat,Buffer[j]);
+  Close(dat);
+end.

+ 16 - 0
tests/webtbf/tbug896a.pp

@@ -0,0 +1,16 @@
+
+var
+  dat : file of byte;
+  j : longint;
+  Buffer : Array[0..2047] of byte;
+
+begin
+  for j:=0 to 2047 do
+    Buffer[j]:=j and $ff;
+  Assign(dat,'tbug896.txt');
+  Rewrite(dat,1);
+  for j:= 0 to 2047 do
+  { writeln should not be allowed for typed files }
+    writeln (dat,Buffer[j]);
+  Close(dat);
+end.

+ 34 - 0
tests/webtbs/tbug896.pp

@@ -0,0 +1,34 @@
+
+var
+  dat,dat2 : file of byte;
+  j : longint;
+  Buffer,Buffer2 : Array[0..2047] of byte;
+
+begin
+  for j:=0 to 2047 do
+    Buffer[j]:=j and $ff;
+  Assign(dat,'tbug896.txt');
+  Rewrite(dat,1);
+  for j:= 0 to 2047 do
+    write (dat,Buffer[j]);
+  Close(dat);
+  Assign(dat2,'tbug896a.txt');
+  Rewrite(dat2);
+  for j:= 0 to 2047 do
+    write (dat2,Buffer[j]);
+  Close(dat2);
+  Reset(dat);
+  Reset(dat2,1);
+  for j:=0 to 2047 do
+    begin
+      read(dat,Buffer[j]);
+      read(dat2,Buffer2[j]);
+      if Buffer[j]<>Buffer2[j] then
+        begin
+          Writeln('Error in typed file handling');
+          Halt(1);
+        end;
+    end;
+  Close(dat);
+  close(dat2);
+end.