tanonfunc24.pp 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. program tanonfunc24;
  2. {$mode objfpc}
  3. {$modeswitch anonymousfunctions}
  4. {$modeswitch functionreferences}
  5. { test anonymous methods with extremely long symbol names }
  6. type
  7. tproc = reference to procedure;
  8. tprocrefname_01234567890123456789 = reference to procedure(c: char; i: longint);
  9. tlongclassname_01234567890123456789 = class
  10. procedure longmethodname_0123456789(p: tprocrefname_01234567890123456789);
  11. end;
  12. procedure foo(p: tproc);
  13. begin
  14. p();
  15. end;
  16. procedure tlongclassname_01234567890123456789.longmethodname_0123456789(
  17. p: tprocrefname_01234567890123456789);
  18. begin
  19. foo(
  20. procedure
  21. begin
  22. p('a', 123);
  23. end);
  24. end;
  25. procedure bar;
  26. var
  27. cls: tlongclassname_01234567890123456789;
  28. val: Integer;
  29. begin
  30. cls := tlongclassname_01234567890123456789.create;
  31. cls.longmethodname_0123456789(
  32. procedure(c: char; i: longint)
  33. begin
  34. if (c <> 'a') or (i <> 123) then
  35. halt(1);
  36. val := i;
  37. end);
  38. cls.free;
  39. if val <> 123 then
  40. halt(1);
  41. end;
  42. begin
  43. bar;
  44. end.