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
program tthlperr1;

begin
  42.DoTest; // <- no helper in scope
end.
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.
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.
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.
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.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to