mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 18:08:05 +02:00
18 lines
332 B
ObjectPascal
18 lines
332 B
ObjectPascal
{ test syntax of a global generic function in mode objfpc }
|
|
|
|
program tgenfunc1;
|
|
|
|
{$mode objfpc}
|
|
|
|
generic function Add<T>(aLeft, aRight: T): T;
|
|
begin
|
|
Result := aLeft + aRight;
|
|
end;
|
|
|
|
begin
|
|
if specialize Add<LongInt>(2, 3) <> 5 then
|
|
Halt(1);
|
|
if specialize Add<String>('Hello', 'World') <> 'HelloWorld' then
|
|
Halt(2);
|
|
end.
|