@@ -50,6 +50,8 @@ TRTTIExposeTests = class (TTestCase)
5050 procedure IndexedProperties ;
5151 procedure IndexedPropertiesDefault ;
5252 procedure IndexedPropertiesCustom ;
53+
54+ procedure PropertyEnumeration ;
5355 end ;
5456
5557type
@@ -83,6 +85,14 @@ TSimpleClass = class
8385
8486 TSimpleEnumeration = (seZero, seOne, seTwo);
8587
88+ TClassWithEnumeration = class
89+ private
90+ FTest : TSimpleEnumeration;
91+ published
92+ property EnumField : TSimpleEnumeration read FTest write FTest;
93+ function TestFunc (arg : TSimpleEnumeration) : Boolean;
94+ end ;
95+
8696 TTestInstance = class
8797 private
8898 FValue : String;
@@ -252,6 +262,13 @@ procedure TSimpleClass.DecValue;
252262 Dec(FValue);
253263end ;
254264
265+ // TestFunc
266+ //
267+ function TClassWithEnumeration.TestFunc (arg : TSimpleEnumeration) : Boolean;
268+ begin
269+ Result := arg = FTest;
270+ end ;
271+
255272// Stuff
256273//
257274procedure TWrappedObject.Stuff (obj : TGenericWrapper<Integer>);
@@ -629,6 +646,34 @@ procedure TRTTIExposeTests.IndexedPropertiesCustom;
629646 end ;
630647end ;
631648
649+ // PropertyEnumeration
650+ //
651+ procedure TRTTIExposeTests.PropertyEnumeration ;
652+ const
653+ cTestCode =
654+ ' var c := new TClassWithEnumeration;' #13 #10
655+ +' c.EnumField := seOne;' #13 #10
656+ +' Print(c.TestFunc(seOne));' #13 #10
657+ +' Print(c.TestFunc(seTwo));' #13 #10
658+ ;
659+
660+ var
661+ prog : IdwsProgram;
662+ exec : IdwsProgramExecution;
663+ begin
664+ FUnit.ExposeRTTI(TypeInfo(TSimpleEnumeration));
665+ FUnit.ExposeRTTI(TypeInfo(TClassWithEnumeration));
666+
667+ prog := FCompiler.Compile(cTestCode);
668+
669+ CheckEquals(' ' , prog.Msgs.AsInfo, ' Compile' );
670+
671+ exec:=prog.Execute;
672+
673+ CheckEquals(' ' , prog.Msgs.AsInfo, ' Exec Msgs' );
674+ CheckEquals(' TrueFalse' , exec.Result.ToString, ' Exec Result' );
675+ end ;
676+
632677// SimpleClass
633678//
634679procedure TRTTIExposeTests.SimpleClass ;
0 commit comments