tb0672.pp 670 B

123456789101112131415161718192021222324252627282930313233
  1. program tb0672;
  2. {$mode objfpc}
  3. type
  4. generic TTest<T> = class
  5. class function Test(aArg: T): LongInt;
  6. end;
  7. class function TTest.Test(aArg: T): LongInt;
  8. begin
  9. Result := Ord(aArg);
  10. end;
  11. type
  12. TEnum = (teOne, teTwo, teThree);
  13. TTestBoolean = specialize TTest<Boolean>;
  14. TTestChar = specialize TTest<Char>;
  15. TTestWideChar = specialize TTest<WideChar>;
  16. TTestEnum = specialize TTest<TEnum>;
  17. begin
  18. if TTestBoolean.Test(True) <> Ord(True) then
  19. Halt(1);
  20. if TTestChar.Test(#42) <> Ord(#42) then
  21. Halt(2);
  22. if TTestWideChar.Test(#1234) <> Ord(#1234) then
  23. Halt(3);
  24. if TTestEnum.Test(teTwo) <> Ord(teTwo) then
  25. Halt(4);
  26. Writeln('ok');
  27. end.