terecs_u1.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. { %norun }
  2. unit terecs_u1;
  3. {$mode delphi}
  4. interface
  5. type
  6. HWND = integer;
  7. TFoo = record
  8. hWnd : HWND;
  9. private
  10. F1: Integer;
  11. F2: Byte;
  12. public
  13. type
  14. TBar = Integer;
  15. const
  16. C: TBar = 1;
  17. var
  18. F3: TBar;
  19. F4: Byte;
  20. class var
  21. F5: TBar;
  22. function Test(n: TBar): TBar;
  23. class function Test1(n: TBar): TBar; static;
  24. procedure Set3(const Value: TBar);
  25. class procedure Set5(const Value: TBar); static;
  26. property P3: TBar read F3 write Set3;
  27. class property P5: TBar read F5 write Set5;
  28. class constructor Create;
  29. class destructor Destroy;
  30. procedure Test2;
  31. procedure Test3;
  32. end;
  33. procedure Test4(AFoo: TFoo);
  34. implementation
  35. function TFoo.Test(n: TBar): TBar;
  36. begin
  37. Result := F3 + F4 + n;
  38. end;
  39. class function TFoo.Test1(n: TBar): TBar;
  40. begin
  41. Result := C + n;
  42. end;
  43. class constructor TFoo.Create;
  44. begin
  45. F5 := 6;
  46. end;
  47. class destructor TFoo.Destroy;
  48. begin
  49. WriteLn('TFoo.Destroy');
  50. end;
  51. procedure TFoo.Set3(const Value: TBar);
  52. begin
  53. F3 := Value;
  54. end;
  55. class procedure TFoo.Set5(const Value: TBar); static;
  56. begin
  57. F5 := Value;
  58. end;
  59. procedure TFoo.Test2;
  60. begin
  61. if Self.C <> 1 then
  62. halt(50);
  63. if Self.F3 <> 7 then
  64. halt(51);
  65. end;
  66. procedure TFoo.Test3;
  67. begin
  68. Test4(Self);
  69. end;
  70. procedure Test4(AFoo: TFoo);
  71. begin
  72. if AFoo.C <> 1 then
  73. halt(100);
  74. if AFoo.P3 <> 7 then
  75. halt(101);
  76. end;
  77. end.