tb0163.pp 1.1 KB

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