[fpc-devel] Tests in Delphi XE3 regarding Type Helpers

Sven Barth pascaldragon at googlemail.com
Thu Nov 29 09:53:03 CET 2012


Hello together!

Could someone with access to Delphi XE3 please compile and run the 
attached tests and provide me with the output of the test or (in case of 
an error) with the output of the compiler?
The tthlperrX.pas tests should not compile, so here I'd like to get the 
error messages.
The other tests should compile, so please try to adjust them until they 
do and report me any adjustments you made. If you can't get them to 
compile then please report me the errors you get with the initial test file.

Thank you.

Regards,
Sven
-------------- next part --------------
program tthlperr1;

begin
  42.DoTest; // <- no helper in scope
end.
-------------- next part --------------
program tthlperr2;

type
  TOrdinalHelper = record helper for LongInt // <- adjust type so that first call compiles!
    procedure DoTest1;
  end;

procedure TOrdinalHelper.DoTest1;
begin

end;

begin
  42.DoTest1; // <- should work
  42.DoTest2; // <- compile error
end.
-------------- next part --------------
program tthlpminus;

type
  TOrdinalHelper = record helper for LongInt // <- adjust, so that test compiles
    procedure DoTest;
  end;

procedure TOrdinalHelper.DoTest;
begin
  Writeln(Self);
end;

begin
  42.DoTest;
  -42.DoTest;
end.
-------------- next part --------------
program tthlpself;

type
  TIntegerHelper = record helper for Integer
    procedure DoTest;
  end;

  TStringHelper = record helper for String
    procedure DoTest;
  end;

procedure TStringHelper.DoTest;
begin
  Writeln(Self);
  Self := 'Hello ' + Self + ' World';
end;

procedure TIntegerHelper.DoTest;
begin
  Writeln(Self);
  Self := Self div 2;
end;

var
  i: Integer;
  s: String;
begin
  i := 42;
  i.DoTest;
  Writeln(i);

  s := 'Type Helper';
  s.DoTest;
  Writeln(s);
end.
-------------- next part --------------
program tthlpsize;

type
  TByteHelper = record helper for Byte
    function DoTest: String;
  end;

  TWordHelper = record helper for Word
    function DoTest: String;
  end;

  TLongWordHelper = record helper for LongWord
    function DoTest: String;
  end;

  TUInt64Helper = record helper for UInt64
    function DoTest: String;
  end;

  TSmallIntHelper = record helper for SmallInt
    function DoTest: String;
  end;

  TShortHelper = record helper for Short
    function DoTest: String;
  end;

  TLongIntHelper = record helper for LongInt
    function DoTest: String;
  end;

  TInt64Helper = record helper for Int64
    function DoTest: String;
  end;

function TInt64Helper.DoTest: String;
begin
  Result := 'Int64';
end;

function TLongIntHelper.DoTest: String;
begin
  Result := 'LongInt';
end;

function TShortHelper.DoTest: String;
begin
  Result := 'Short';
end;

function TSmallIntHelper.DoTest: String;
begin
  Result := 'SmallInt';
end;

function TUInt64Helper.DoTest: String;
begin
  Result := 'UInt64';
end;

function TLongWordHelper.DoTest: String;
begin
  Result := 'LongWord';
end;

function TWordHelper.DoTest: String;
begin
  Result := 'Word';
end;

function TByteHelper.DoTest: String;
begin
  Result := 'Byte';
end;

begin
  Writeln(0, #9, 0.DoTest);
  Writeln(-1, #9, -1.DoTest);
  Writeln($ABCD, #9, $ABCD.DoTest);
  Writeln(-32987, #9, -32987.DoTest);
  Writeln(2345678, #9, 2345678.DoTest);
  Writeln(-2345678, #9, -2345678.DoTest);
  Writeln($1234567887654321, #9, $1234567887654321.DoTest);
  Writeln(-9876543211234, #9, -9876543211234.DoTest);
  Writeln(9876543211234, #9, 9876543211234.DoTest);
end.


More information about the fpc-devel mailing list