* fix for Mantis #35693: IsOrdinal also needs to return true for enums (with that AsOrdinal will work correctly as well)

* extended RTTI test by a test for enums

git-svn-id: trunk@42219 -
This commit is contained in:
svenbarth 2019-06-13 21:08:38 +00:00
parent d1830fc589
commit a2a403e2e5
2 changed files with 21 additions and 1 deletions

View File

@ -1548,7 +1548,7 @@ end;
function TValue.IsOrdinal: boolean;
begin
result := (Kind in [tkInteger, tkInt64, tkQWord, tkBool]) or
result := (Kind in [tkInteger, tkInt64, tkQWord, tkBool, tkEnumeration]) or
((Kind in [tkClass, tkClassRef, tkInterfaceRaw, tkUnknown]) and not Assigned(FData.FAsPointer));
end;

View File

@ -60,6 +60,7 @@ type
procedure TestMakeExtended;
procedure TestMakeCurrency;
procedure TestMakeComp;
procedure TestMakeEnum;
procedure TestDataSize;
procedure TestDataSizeEmpty;
@ -665,6 +666,25 @@ begin
CheckFalse(hadexcept, 'Had unsigned type conversion exception');
end;
procedure TTestCase1.TestMakeEnum;
var
e: TTestEnum;
v: TValue;
begin
e := te1;
TValue.Make(@e, TypeInfo(e), v);
Check(not v.IsClass);
Check(not v.IsArray);
Check(not v.IsEmpty);
Check(not v.IsOpenArray);
Check(not v.IsObject);
Check(v.IsOrdinal);
Check(v.GetReferenceToRawData <> @e);
Check(TTestEnum(v.AsOrdinal) = te1);
end;
procedure TTestCase1.TestGetIsReadable;
var
c: TRttiContext;