mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 14:09:17 +02:00
* only check result if the call itself succeeded (e.g. didn't fail due to the invoke manager not supporting the calling convention)
git-svn-id: trunk@37700 -
This commit is contained in:
parent
eaf878e106
commit
0954572af9
@ -25,7 +25,7 @@ type
|
|||||||
);
|
);
|
||||||
TInvokeFlags = set of TInvokeFlag;
|
TInvokeFlags = set of TInvokeFlag;
|
||||||
private
|
private
|
||||||
function DoInvoke(aCodeAddress: CodePointer; aArgs: TValueArray; aCallConv: TCallConv; aResultType: PTypeInfo; aFlags: TInvokeFlags): TValue;
|
function DoInvoke(aCodeAddress: CodePointer; aArgs: TValueArray; aCallConv: TCallConv; aResultType: PTypeInfo; aFlags: TInvokeFlags; out aValid: Boolean): TValue;
|
||||||
procedure DoStaticInvokeTestOrdinalCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; aResult: Int64);
|
procedure DoStaticInvokeTestOrdinalCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; aResult: Int64);
|
||||||
procedure DoStaticInvokeTestAnsiStringCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; constref aResult: AnsiString);
|
procedure DoStaticInvokeTestAnsiStringCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; constref aResult: AnsiString);
|
||||||
procedure DoStaticInvokeTestUnicodeStringCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; constref aResult: UnicodeString);
|
procedure DoStaticInvokeTestUnicodeStringCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; constref aResult: UnicodeString);
|
||||||
@ -66,14 +66,16 @@ end;
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
function TTestInvoke.DoInvoke(aCodeAddress: CodePointer; aArgs: TValueArray;
|
function TTestInvoke.DoInvoke(aCodeAddress: CodePointer; aArgs: TValueArray;
|
||||||
aCallConv: TCallConv; aResultType: PTypeInfo; aFlags: TInvokeFlags): TValue;
|
aCallConv: TCallConv; aResultType: PTypeInfo; aFlags: TInvokeFlags; out aValid: Boolean): TValue;
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
Result := Rtti.Invoke(aCodeAddress, aArgs, aCallConv, aResultType, ifStatic in aFlags, ifConstructor in aFlags);
|
Result := Rtti.Invoke(aCodeAddress, aArgs, aCallConv, aResultType, ifStatic in aFlags, ifConstructor in aFlags);
|
||||||
|
aValid := True;
|
||||||
except
|
except
|
||||||
on e: ENotImplemented do
|
on e: ENotImplemented do begin
|
||||||
Status('Ignoring unimplemented functionality of test');
|
Status('Ignoring unimplemented functionality of test');
|
||||||
else
|
aValid := False;
|
||||||
|
end else
|
||||||
raise;
|
raise;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -81,9 +83,10 @@ end;
|
|||||||
procedure TTestInvoke.DoStaticInvokeTestOrdinalCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; aResult: Int64);
|
procedure TTestInvoke.DoStaticInvokeTestOrdinalCompare(const aTestName: String; aAddress: CodePointer; aCallConv: TCallConv; aValues: TValueArray; aReturnType: PTypeInfo; aResult: Int64);
|
||||||
var
|
var
|
||||||
resval: TValue;
|
resval: TValue;
|
||||||
|
valid: Boolean;
|
||||||
begin
|
begin
|
||||||
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic]);
|
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic], valid);
|
||||||
if Assigned(aReturnType) and (resval.AsOrdinal <> aResult) then begin
|
if valid and Assigned(aReturnType) and (resval.AsOrdinal <> aResult) then begin
|
||||||
Fail('Result of test "%s" is unexpected; expected: %s, got: %s', [aTestName, IntToStr(aResult), IntToStr(resval.AsOrdinal)]);
|
Fail('Result of test "%s" is unexpected; expected: %s, got: %s', [aTestName, IntToStr(aResult), IntToStr(resval.AsOrdinal)]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -93,9 +96,10 @@ procedure TTestInvoke.DoStaticInvokeTestAnsiStringCompare(
|
|||||||
aValues: TValueArray; aReturnType: PTypeInfo; constref aResult: AnsiString);
|
aValues: TValueArray; aReturnType: PTypeInfo; constref aResult: AnsiString);
|
||||||
var
|
var
|
||||||
resval: TValue;
|
resval: TValue;
|
||||||
|
valid: Boolean;
|
||||||
begin
|
begin
|
||||||
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic]);
|
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic], valid);
|
||||||
if Assigned(aReturnType) and (resval.AsAnsiString <> aResult) then begin
|
if valid and Assigned(aReturnType) and (resval.AsAnsiString <> aResult) then begin
|
||||||
Fail('Result of test "%s" is unexpected; expected: "%s", got: "%s"', [aTestName, aResult, resval.AsString]);
|
Fail('Result of test "%s" is unexpected; expected: "%s", got: "%s"', [aTestName, aResult, resval.AsString]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -106,9 +110,10 @@ procedure TTestInvoke.DoStaticInvokeTestUnicodeStringCompare(
|
|||||||
);
|
);
|
||||||
var
|
var
|
||||||
resval: TValue;
|
resval: TValue;
|
||||||
|
valid: Boolean;
|
||||||
begin
|
begin
|
||||||
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic]);
|
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic], valid);
|
||||||
if Assigned(aReturnType) and (resval.AsUnicodeString <> aResult) then begin
|
if valid and Assigned(aReturnType) and (resval.AsUnicodeString <> aResult) then begin
|
||||||
Fail('Result of test "%s" is unexpected; expected: "%s", got: "%s"', [aTestName, aResult, resval.AsString]);
|
Fail('Result of test "%s" is unexpected; expected: "%s", got: "%s"', [aTestName, aResult, resval.AsString]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -463,9 +468,10 @@ procedure TTestInvoke.TestTObject;
|
|||||||
var
|
var
|
||||||
resval: TValue;
|
resval: TValue;
|
||||||
rescls: TTestClass;
|
rescls: TTestClass;
|
||||||
|
valid: Boolean;
|
||||||
begin
|
begin
|
||||||
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic]);
|
resval := DoInvoke(aAddress, aValues, aCallConv, aReturnType, [ifStatic], valid);
|
||||||
if Assigned(aReturnType) then begin
|
if valid and Assigned(aReturnType) then begin
|
||||||
rescls := TTestClass(PPointer(resval.GetReferenceToRawData)^);
|
rescls := TTestClass(PPointer(resval.GetReferenceToRawData)^);
|
||||||
if (rescls.fString <> aResult.fString) or (rescls.fValue <> aResult.fValue) then
|
if (rescls.fString <> aResult.fString) or (rescls.fValue <> aResult.fValue) then
|
||||||
Fail('Result of test "%s" is unexpected; expected: "%s"/%s, got: "%s"/%s', [aTestName, aResult.fString, IntToStr(aResult.fValue), rescls.fString, IntToStr(rescls.fValue)]);
|
Fail('Result of test "%s" is unexpected; expected: "%s"/%s, got: "%s"/%s', [aTestName, aResult.fString, IntToStr(aResult.fValue), rescls.fString, IntToStr(rescls.fValue)]);
|
||||||
|
Loading…
Reference in New Issue
Block a user