testobj2.pp 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. begin
  17. error := false;
  18. Write('Error checking for object streams...');
  19. { Legal operation on pStream1 }
  20. pStream1 := New(PDosStream, Init(csFName1, stCreate));
  21. { Faulty operation on pStream2 }
  22. pStream2 := New(PDosStream, Init(csFName2, stOpenRead));
  23. if pStream2^.Status = stOk then
  24. error := true;
  25. { Legal operation on pStream1 }
  26. pStream1^.Write(lAux, SizeOf(lAux));
  27. { Normally, if the values are not shared, this should be ok! }
  28. if pStream1^.Status <> stOk then
  29. error := true;
  30. pStream2^.Free;
  31. pStream1^.Free;
  32. if error then
  33. Begin
  34. WriteLn('FAILED! Errors are mixed up!');
  35. halt(1);
  36. end
  37. else
  38. Writeln('Success!');
  39. end.