testobj2.pp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. { Source provided for Free Pascal Bug Report 2043 }
  2. { Submitted by "Luis Castedo" on 2002-07-16 }
  3. { e-mail: [email protected] }
  4. program tb1;
  5. {$MODE TP}
  6. uses
  7. Objects;
  8. const
  9. csFName1 = 'tb1_1.tmp';
  10. csFName2 = 'tb1_2.tmp';
  11. var
  12. pStream1: PStream;
  13. pStream2: PStream;
  14. lAux : Longint;
  15. error : boolean;
  16. f : file;
  17. begin
  18. error := false;
  19. Write('Error checking for object streams...');
  20. { Legal operation on pStream1 }
  21. pStream1 := New(PDosStream, Init(csFName1, stCreate));
  22. { Faulty operation on pStream2 }
  23. pStream2 := New(PDosStream, Init(csFName2, stOpenRead));
  24. if pStream2^.Status = stOk then
  25. error := true;
  26. { Legal operation on pStream1 }
  27. pStream1^.Write(lAux, SizeOf(lAux));
  28. { Normally, if the values are not shared, this should be ok! }
  29. if pStream1^.Status <> stOk then
  30. error := true;
  31. pStream2^.Free;
  32. pStream1^.Free;
  33. Assign(f,csFName1);
  34. Erase(f);
  35. if error then
  36. Begin
  37. WriteLn('FAILED! Errors are mixed up!');
  38. halt(1);
  39. end
  40. else
  41. Writeln('Success!');
  42. end.