tinitdon.pp 848 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. {
  2. this file checks that calling done from init is
  3. done correctly
  4. }
  5. program test_init_done;
  6. type
  7. pobject = ^tobject;
  8. tobject = object
  9. val : longint;
  10. constructor init (call_done : boolean);
  11. destructor done; virtual;
  12. procedure check;
  13. end;
  14. constructor tobject.init (call_done : boolean);
  15. begin
  16. val:=7;
  17. if call_done then
  18. begin
  19. done;
  20. fail;
  21. end;
  22. end;
  23. destructor tobject.done;
  24. begin
  25. check;
  26. end;
  27. procedure tobject.check;
  28. begin
  29. if val<>7 then
  30. begin
  31. writeln('Error in codegeneration');
  32. halt(1);
  33. end;
  34. end;
  35. var
  36. obj1 : tobject;
  37. obj2 : pobject;
  38. begin
  39. obj1.init(false);
  40. obj1.done;
  41. new(obj2,init(true));
  42. if assigned(obj2) then
  43. begin
  44. writeln('Error in codegeneration of fail');
  45. halt(1);
  46. end;
  47. end.