tthlp9.pp 676 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. { this tests that class methods can be used in type helpers }
  2. program tthlp9;
  3. {$mode objfpc}
  4. {$modeswitch typehelpers}
  5. {$apptype console}
  6. type
  7. TInt32Helper = type helper for Int32
  8. class function Test: LongInt; static;
  9. end;
  10. TShortStringHelper = type helper for ShortString
  11. class function Test: LongInt; static;
  12. end;
  13. class function TInt32Helper.Test: LongInt;
  14. begin
  15. Result := SizeOf(Int32);
  16. end;
  17. class function TShortStringHelper.Test: LongInt;
  18. begin
  19. Result := SizeOf(AnsiChar);
  20. end;
  21. var
  22. i: LongInt;
  23. begin
  24. if LongInt.Test <> 4 then
  25. Halt(1);
  26. if i.Test <> 4 then
  27. Halt(2);
  28. if ShortString.Test <> 1 then
  29. Halt(3);
  30. Writeln('OK');
  31. end.