fpc/tests/test/thlp47.pp
svenbarth 7b216d7fa6 Fix for Mantis #27120.
pdecobj.pas, parse_object_members:
  * also allow class fields for helper types

+ added tests

git-svn-id: trunk@29270 -
2014-12-12 13:57:43 +00:00

57 lines
935 B
ObjectPascal

{ This tests that class variables for the various helper kinds work correctly }
program thlp47;
{$mode objfpc}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}
type
TObjectHelper = class helper for TObject
public
class procedure Init;
public class var
Value: LongInt;
end;
TGuidHelper = record helper for TGuid
public
class procedure Init; static;
public class var
Value: LongInt;
end;
TLongIntHelper = type helper for LongInt
public
class procedure Init; static;
public class var
Value: LongInt;
end;
class procedure TObjectHelper.Init;
begin
Value := 42;
end;
class procedure TGuidHelper.Init;
begin
Value := 21;
end;
class procedure TLongIntHelper.Init;
begin
Value := 84;
end;
begin
TObject.Init;
if TObject.Value <> 42 then
Halt(1);
TGuid.Init;
if TGuid.Value <> 21 then
Halt(2);
LongInt.Init;
if LongInt.Value <> 84 then
Halt(3);
end.