bug0194.pp 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. {$Q+}
  2. type
  3. tproc = function : longint;
  4. var
  5. f : tproc;
  6. fa : array [0..1] of tproc;
  7. function dummy : longint;
  8. begin
  9. dummy:=25;
  10. end;
  11. const
  12. prog_has_errors : boolean = false;
  13. procedure Wrong(const s : string);
  14. begin
  15. writeln(s);
  16. prog_has_errors:=True;
  17. end;
  18. Begin
  19. f:=@dummy;
  20. if f()<>25 then
  21. Wrong('f() does not call dummy !!');
  22. if pointer(@f)=pointer(@dummy) then
  23. Wrong('@f returns value of f !');
  24. if longint(f)=longint(@f) then
  25. Wrong('longint(@f)=longint(f) !!!!');
  26. if f<>@dummy then
  27. Wrong('f does not return the address of dummy');
  28. if longint(@f)=longint(@dummy) then
  29. Wrong('longint(@f) returns address of dummy instead of address of f');
  30. fa[0]:=@dummy;
  31. if longint(@f)=longint(@fa[0]) then
  32. Wrong('arrays of procvar also wrong');
  33. if longint(f)<>longint(fa[0]) then
  34. Wrong('arrays of procvar and procvars are handled differently !!');
  35. if prog_has_errors then
  36. Halt(1);
  37. End.