tgenconst1.pp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. { %NORUN }
  2. {$mode objfpc}
  3. {
  4. test all possible constants
  5. }
  6. program tgenconst1;
  7. type
  8. TEnums = (Blaise, Pascal);
  9. kNames = set of TEnums;
  10. kChars = set of char;
  11. type
  12. generic TBoolean<const U: boolean> = record end;
  13. generic TString<const U: string> = record end;
  14. generic TFloat<const U: single> = record end;
  15. generic TInteger<const U: integer> = record end;
  16. generic TChar<const U: char> = record end;
  17. generic TByte<const U: byte> = record end;
  18. generic TQWord<const U: QWord> = record end;
  19. generic TEnum<const U: TEnums> = record end;
  20. generic TNames<const U: kNames> = record end;
  21. generic TChars<const U: kChars> = record end;
  22. generic TPointer<const U: pointer> = record end;
  23. var
  24. a: specialize TBoolean<true>;
  25. b: specialize TString<'string'>;
  26. c: specialize TFloat<1>;
  27. d: specialize TInteger<10>;
  28. e: specialize TByte<255>;
  29. f: specialize TChar<'a'>;
  30. g: specialize TEnum<Pascal>;
  31. h: specialize TNames<[Blaise,Pascal]>;
  32. i: specialize TChars<['a','b']>;
  33. j: specialize TQWord<10>;
  34. k: specialize TPointer<nil>;
  35. begin
  36. end.