mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 15:28:14 +02:00
FpDebug: test ".." intrinsic operator / Fix error checking
This commit is contained in:
parent
25c7f3c141
commit
8208144cdf
@ -1368,6 +1368,8 @@ begin
|
||||
// exit(WResult);
|
||||
|
||||
Result := FValue.AsString;
|
||||
if IsError(FValue.LastError) then
|
||||
SetLastError(FValue.LastError);
|
||||
end;
|
||||
|
||||
function TFpPasParserValueAddressOf.GetAsWideString: WideString;
|
||||
@ -1385,6 +1387,8 @@ begin
|
||||
end;
|
||||
|
||||
Result := FValue.AsWideString;
|
||||
if IsError(FValue.LastError) then
|
||||
SetLastError(FValue.LastError);
|
||||
end;
|
||||
|
||||
constructor TFpPasParserValueAddressOf.Create(AValue: TFpValue;
|
||||
@ -1641,7 +1645,7 @@ begin
|
||||
end;
|
||||
a := TmpVal.DataAddress;
|
||||
if IsTargetAddr(a) and IsReadableMem(a) then
|
||||
TFpValueConstChar(TmpVal2).SetAddress(a + Offs-1);
|
||||
TFpValueConstWithType(TmpVal2).SetAddress(a + Offs-1);
|
||||
end;
|
||||
skWideString: begin
|
||||
//TODO: move to FpDwarfValue.member ??
|
||||
@ -3820,6 +3824,7 @@ begin
|
||||
|
||||
tmp := Items[0].ResultValue;
|
||||
if (tmp = nil) or not IsTargetAddr(tmp.Address) then begin
|
||||
SetError(fpErrAnyError, []);
|
||||
// seterror / cant take address
|
||||
exit;
|
||||
end;
|
||||
|
@ -487,7 +487,10 @@ begin
|
||||
else
|
||||
DoWritePointerWatchResultData(MemberValue, EntryRes, Addr);
|
||||
|
||||
if (i = StartIdx) and (MemberValue <> nil) and FEncounteredError then begin
|
||||
if (i = StartIdx) and (MemberValue <> nil) and FEncounteredError and
|
||||
(ti <> nil) and (ti.Flags * [sfDynArray, sfStatArray] <> [])
|
||||
then begin
|
||||
FEncounteredError := False;
|
||||
MLoc := MemberValue.Address;
|
||||
if IsValidLoc(MLoc) then
|
||||
Context.ReadMemory(MLoc, SizeVal(1), @Dummy);
|
||||
|
@ -1589,10 +1589,11 @@ procedure TTestWatches.TestWatchesIntrinsic;
|
||||
end;
|
||||
|
||||
var
|
||||
ExeName: String;
|
||||
ExeName, vn, d1: String;
|
||||
t: TWatchExpectationList;
|
||||
Src: TCommonSource;
|
||||
BrkPrg, BrkFoo, BrkFooVar, BrkFooConstRef: TDBGBreakPoint;
|
||||
i: Integer;
|
||||
begin
|
||||
if SkipTest then exit;
|
||||
if not TestControlCanTest(ControlTestWatchIntrinsic) then exit;
|
||||
@ -1642,25 +1643,217 @@ begin
|
||||
t.Add('pos', PREFIX+'pos(''e'', Short0)', weInteger( 5, #1, 0)).IgnTypeName();
|
||||
t.Add('pos', PREFIX+'pos(''e'', ''1e'')', weInteger( 2, #1, 0)).IgnTypeName();
|
||||
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3)', weAnsiStr('bcd', #1)).IgnTypeName();
|
||||
// dwarf2 incorrectly does SREF: PChar
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3)', weAnsiStr('bcd', #1)).IgnTypeName().IgnAll(stDwarf2);
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3)', weAnsiStr('cde', #1)).IgnTypeName().IgnAll(stDwarf3Up);
|
||||
t.Add('substr', PREFIX+'substr(Short0, 4,3)', weAnsiStr('def', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3, false)', weAnsiStr('bcd', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3, false)', weAnsiStr('bcd', #1)).IgnTypeName().IgnAll(stDwarf2);
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3, false)', weAnsiStr('cde', #1)).IgnTypeName().IgnAll(stDwarf3Up);
|
||||
t.Add('substr', PREFIX+'substr(Short0, 4,3, false)', weAnsiStr('def', #1)).IgnTypeName();
|
||||
// 0 based
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 2,3, true)', weAnsiStr('cde', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(Short0, 4,3, true)', weAnsiStr('ef1', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(Short0, 4,3, true)', weAnsiStr('ef1', #1)).IgnTypeName().IgnAll(stDwarf2);
|
||||
// cut off
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 10, 30)', weAnsiStr('456', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(SRef1, 10, 30)', weAnsiStr('456', #1)).IgnTypeName().IgnAll(stDwarf2);
|
||||
//t.Add('substr', PREFIX+'substr(SRef1, 10, 30)', weAnsiStr('567', #1)).IgnTypeName().IgnAll(stDwarf3Up);
|
||||
|
||||
t.Add('substr', PREFIX+'substr(SHORT1[1], -4, 2, true)', weAnsiStr('23', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(SHORT1[1], -4, 2, true)', weAnsiStr('23', #1)).IgnTypeName()
|
||||
.IgnAll(stDwarf2);
|
||||
|
||||
t.Add('substr', PREFIX+'PtrRef1, 2, 4, true)', weAnsiStr('cdef', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'PCRef1, 2, 4, true)', weAnsiStr('cdef', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(PtrRef1, 2, 4, true)', weAnsiStr('cdef', #1)).IgnTypeName();
|
||||
t.Add('substr', PREFIX+'substr(PCRef1, 2, 4, true)', weAnsiStr('cdef', #1)).IgnTypeName();
|
||||
|
||||
|
||||
t.Add('string[..]', 'SRef1[3..5]', weAnsiStr('cde').IgnTypeName()).IgnAll(stDwarf2);
|
||||
t.Add('string[..]', 'SRef1[2..6][2]', weChar('c').IgnTypeName()).IgnAll(stDwarf2);
|
||||
t.Add('string[..]', 'SRef1[2..6][2..3]', weAnsiStr('cd').IgnTypeName()).IgnAll(stDwarf2);
|
||||
// not avail for pchar
|
||||
// t.Add('pchar[..]', 'PCRef1[2..4]', weAnsiStr('cde').IgnTypeName()).IgnAll(stDwarf2);
|
||||
// t.Add('string[..]', '@SRef1[1][2..4]', weAnsiStr('cde').IgnTypeName()).IgnAll(stDwarf2);
|
||||
|
||||
|
||||
for i := 0 to 2 do begin
|
||||
case i of
|
||||
0: begin
|
||||
vn := 'dotdotArray1a';
|
||||
d1 := '';
|
||||
end;
|
||||
1: begin
|
||||
vn := 'dotdotArrayP1a';
|
||||
d1 := '^';
|
||||
end;
|
||||
2: begin
|
||||
vn := 'dotdotArrayPPa^';
|
||||
d1 := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
t.Add('..', vn+'[2..4]'+d1, weStatArray([
|
||||
////weMatchErr('error|fail'),
|
||||
weRecord([wePointer(weAnsiStr('ABCDE')).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([weMatch('nil',skPointer).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([wePointer(weAnsiStr('bcdef123456')).N('p1'), weMatch('nil',skPointer).N('p2') ])
|
||||
], 3))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', vn+'[2..4]'+d1+'.p1', weStatArray([
|
||||
wePointer(weAnsiStr('ABCDE').IgnTypeName()),
|
||||
weMatch('nil',skPointer),
|
||||
wePointer(weAnsiStr('bcdef123456').IgnTypeName())
|
||||
], 3))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', vn+'[2..4]'+d1+'.p1[0]', weStatArray([
|
||||
weChar('A', #1).IgnTypeName(),
|
||||
weMatchErr('error|fail'),
|
||||
weChar('b', #1).IgnTypeName()
|
||||
], 3))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
|
||||
t.Add('..', vn+'[1..4]'+d1, weStatArray([
|
||||
weRecord([wePointerAddr(pointer(1), weMatchErr('error|fail')).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([wePointer(weAnsiStr('ABCDE')).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([weMatch('nil',skPointer).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([wePointer(weAnsiStr('bcdef123456')).N('p1'), weMatch('nil',skPointer).N('p2') ])
|
||||
], 4))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', vn+'[1..4]'+d1+'.p1', weStatArray([
|
||||
wePointerAddr(pointer(1), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('ABCDE').IgnTypeName()),
|
||||
weMatch('nil',skPointer),
|
||||
wePointer(weAnsiStr('bcdef123456').IgnTypeName())
|
||||
], 4))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', vn+'[1..4]'+d1+'.p1^', weStatArray([
|
||||
weMatchErr('error|fail'),
|
||||
weChar('A', #1).IgnTypeName(),
|
||||
weMatchErr('error|fail'),
|
||||
weChar('b', #1).IgnTypeName()
|
||||
],4))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', vn+'[1..4]'+d1+'.p1[0]', weStatArray([
|
||||
weMatchErr('error|fail'),
|
||||
weChar('A', #1).IgnTypeName(),
|
||||
weMatchErr('error|fail'),
|
||||
weChar('b', #1).IgnTypeName()
|
||||
],4))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', vn+'[1..4]'+d1+'.p1[1]', weStatArray([
|
||||
weMatchErr('error|fail'),
|
||||
weChar('B', #1).IgnTypeName(),
|
||||
weMatchErr('error|fail'),
|
||||
weChar('c', #1).IgnTypeName()
|
||||
],4))
|
||||
.ChrIdxExpPChar
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
t.Add('..', '@'+vn+'[1..4]'+d1+'.p1^', weStatArray([
|
||||
wePointerAddr(pointer(1), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('ABCDE').IgnTypeName()),
|
||||
weMatch('nil',skPointer),
|
||||
wePointer(weAnsiStr('bcdef123456').IgnTypeName())
|
||||
], 4))
|
||||
.ChrIdxExpPChar
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', '@'+vn+'[1..4]'+d1+'.p1[0]', weStatArray([
|
||||
wePointerAddr(pointer(1), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('ABCDE').IgnTypeName()),
|
||||
weMatch('nil',skPointer),
|
||||
wePointer(weAnsiStr('bcdef123456').IgnTypeName())
|
||||
], 4))
|
||||
.ChrIdxExpPChar
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', '@'+vn+'[1..4]'+d1+'.p1[1]', weStatArray([
|
||||
wePointerAddr(pointer(2), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('BCDE').IgnTypeName()),
|
||||
wePointerAddr(pointer(1), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('cdef123456').IgnTypeName())
|
||||
], 4))
|
||||
.ChrIdxExpPChar
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
t.Add('..', '@('+vn+'[1..4]'+d1+'.p1[1])', weStatArray([
|
||||
wePointerAddr(pointer(2), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('BCDE').IgnTypeName()),
|
||||
wePointerAddr(pointer(1), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('cdef123456').IgnTypeName())
|
||||
], 4))
|
||||
.ChrIdxExpPChar
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
|
||||
|
||||
t.Add('..', '(@'+vn+'[1..4]'+d1+'.p1[1])[2]', weStatArray([
|
||||
weMatchErr('error|fail'),
|
||||
weChar('D').IgnTypeName(),
|
||||
weMatchErr('error|fail'),
|
||||
weChar('e').IgnTypeName()
|
||||
], 4))
|
||||
.ChrIdxExpPChar
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
//t.Add('..', '(@'+vn+'[1..4]'+d1+'.p1[1])[1..2]', weStatArray([
|
||||
// weMatchErr('error|fail'),
|
||||
// weAnsiStr('BC').IgnTypeName(),
|
||||
// weMatchErr('error|fail'),
|
||||
// weAnsiStr('cd').IgnTypeName()
|
||||
//], 4))
|
||||
//.ChrIdxExpPChar
|
||||
//.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
|
||||
case i of
|
||||
0: begin
|
||||
vn := 'dotdotArray2a';
|
||||
d1 := '';
|
||||
end;
|
||||
1: begin
|
||||
vn := 'dotdotArrayP2a';
|
||||
d1 := '^';
|
||||
end;
|
||||
else continue;
|
||||
end;
|
||||
|
||||
t.Add('..', vn+'[0..1][0..2]'+d1, weStatArray([
|
||||
//TODO: detect outer array error
|
||||
weStatArray([
|
||||
weMatchErr('error|fail'),
|
||||
weMatchErr('error|fail'),
|
||||
weMatchErr('error|fail')
|
||||
], 3)
|
||||
.AddFlag(ehIgnKindArrayType),
|
||||
weStatArray([
|
||||
weRecord([wePointer(weAnsiStr('abcdef123456')).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([wePointerAddr(pointer(1), weMatchErr('error|fail')).N('p1'), weMatch('nil',skPointer).N('p2') ]),
|
||||
weRecord([wePointer(weAnsiStr('ABCDE')).N('p1'), weMatch('nil',skPointer).N('p2') ])
|
||||
], 3)
|
||||
.AddFlag(ehIgnKindArrayType)
|
||||
], 2))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
t.Add('..', vn+'[0..1][0..2]'+d1+'.p1', weStatArray([
|
||||
//weMatchErr('error|fail'),
|
||||
weStatArray([
|
||||
weMatchErr('error|fail'),
|
||||
weMatchErr('error|fail'),
|
||||
weMatchErr('error|fail')
|
||||
], 3)
|
||||
.AddFlag(ehIgnKindArrayType),
|
||||
weStatArray([
|
||||
wePointer(weAnsiStr('abcdef123456').IgnTypeName()),
|
||||
wePointerAddr(pointer(1), weMatchErr('error|fail')),
|
||||
wePointer(weAnsiStr('ABCDE').IgnTypeName())
|
||||
], 3)
|
||||
.AddFlag(ehIgnKindArrayType)
|
||||
], 2))
|
||||
.AddFlag(ehIgnKindArrayType);
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
AddWatches(t, 'glob var', 'gv', 001, 'B');
|
||||
AddWatches(t, 'glob MyClass1', 'MyClass1.mc', 002, 'C');
|
||||
t.EvaluateWatches;
|
||||
t.CheckResults;
|
||||
|
||||
|
||||
RunToPause(BrkFoo);
|
||||
|
Binary file not shown.
@ -109,6 +109,7 @@ var
|
||||
v_array: array [3..4] of variant;
|
||||
|
||||
SRef0, SRef1, SRef2, SRef3, SRef4: String;
|
||||
SConst: Ansistring;
|
||||
PCRef1: PChar;
|
||||
PtrRef1: Pointer;
|
||||
Short0: Shortstring;
|
||||
@ -942,6 +943,23 @@ var
|
||||
post: byte; // padding, must not be changed
|
||||
end;
|
||||
|
||||
// Intrinsic ..
|
||||
type
|
||||
TRecPP = record
|
||||
p1, p2: pchar;
|
||||
end;
|
||||
PRecPP = ^TRecPP;
|
||||
TRecArray = array of TRecPP;
|
||||
PTRecArray = ^TRecArray;
|
||||
PRecArray = array of PRecPP;
|
||||
var
|
||||
dotdotArray1a, dotdotArray1b: TRecArray;
|
||||
dotdotArray2a, dotdotArray2b: array of array of TRecPP;
|
||||
dotdotArrayP1a, dotdotArrayP1b: PRecArray;
|
||||
dotdotArrayP2a, dotdotArrayP2b: array of array of PRecPP;
|
||||
|
||||
dotdotArrayPPa, dotdotArrayPPb: PTRecArray;
|
||||
i1,i2: integer;
|
||||
|
||||
begin
|
||||
U8Data1 := #$2267; //#$E2#$89#$A7;
|
||||
@ -1169,9 +1187,9 @@ begin
|
||||
|
||||
SRef0 := '';
|
||||
SRef1 := 'abcdef123456';
|
||||
SRef1 := inttostr(random(9))+SRef1;
|
||||
SRef2 := inttostr(random(9))+SRef1;
|
||||
SRef3 := SRef2;
|
||||
SRef3 := inttostr(random(9))+SRef1;
|
||||
SRef4 := SRef3;
|
||||
|
||||
PCRef1 := @SRef1[1];
|
||||
PtrRef1 := PCRef1;
|
||||
@ -1187,6 +1205,60 @@ begin
|
||||
SetLength(ARef3, 10);
|
||||
ARef4 := ARef3;
|
||||
|
||||
// .. intrinsic
|
||||
SConst := 'ABCDE';
|
||||
SetLength(dotdotArray1a, 5);
|
||||
SetLength(dotdotArray1b, 5);
|
||||
SetLength(dotdotArray2a, 6, 5);
|
||||
SetLength(dotdotArray2b, 6, 5);
|
||||
|
||||
dotdotArray1a[0].p1 := @SRef1[1];
|
||||
pointer(dotdotArray1a[1].p1) := pointer(1);
|
||||
dotdotArray1a[2].p1 := @SConst[1];
|
||||
dotdotArray1a[3].p1 := nil;
|
||||
dotdotArray1a[4].p1 := @SRef1[2];
|
||||
|
||||
pointer(dotdotArray1b[0].p1) := pointer(1);
|
||||
dotdotArray1b[1].p1 := @SRef1[1];
|
||||
dotdotArray1b[2].p1 := nil;
|
||||
dotdotArray1b[3].p1 := nil;
|
||||
dotdotArray1b[4].p1 := @SRef1[3];
|
||||
|
||||
dotdotArray2a[0] := nil;
|
||||
dotdotArray2a[1][0].p1 := @SRef1[1];
|
||||
pointer(dotdotArray2a[1][1].p1) := pointer(1);
|
||||
dotdotArray2a[1][2].p1 := @SConst[1];
|
||||
dotdotArray2a[1][3].p1 := nil;
|
||||
dotdotArray2a[1][4].p1 := @SRef1[2];
|
||||
pointer(dotdotArray2a[2][0].p1) := pointer(1);
|
||||
dotdotArray2a[2][1].p1 := pointer(-1);
|
||||
dotdotArray2a[2][2].p1 := @SConst[1];
|
||||
dotdotArray2a[2][3].p1 := nil;
|
||||
dotdotArray2a[2][4].p1 := @SRef1[2];
|
||||
dotdotArray2a[3] := nil;
|
||||
dotdotArray2a[4][0].p1 := @SRef1[1];
|
||||
pointer(dotdotArray2a[4][1].p1) := pointer(1);
|
||||
dotdotArray2a[4][2].p1 := @SConst[1];
|
||||
dotdotArray2a[4][3].p1 := nil;
|
||||
dotdotArray2a[4][4].p1 := @SRef1[2];
|
||||
|
||||
SetLength(dotdotArrayP1a, 5);
|
||||
SetLength(dotdotArrayP1b, 5);
|
||||
SetLength(dotdotArrayP2a, 6, 5);
|
||||
SetLength(dotdotArrayP2b, 6, 5);
|
||||
for i1 := 0 to 4 do
|
||||
for i2 := 0 to 5 do begin
|
||||
dotdotArrayP1a[i1] := @dotdotArray1a[i1];
|
||||
dotdotArrayP1b[i1] := @dotdotArray1b[i1];
|
||||
dotdotArrayP2a[i1][i2] := @dotdotArray2a[i1][i2];
|
||||
dotdotArrayP2b[i1][i2] := @dotdotArray2b[i1][i2];
|
||||
end;
|
||||
|
||||
dotdotArrayPPa := @dotdotArray1a;
|
||||
dotdotArrayPPb := @dotdotArray1b;
|
||||
|
||||
|
||||
|
||||
BreakDummy:= 1; // TEST_BREAKPOINT=Prg
|
||||
|
||||
Foo(
|
||||
|
@ -255,7 +255,7 @@ type
|
||||
function TestFalse(Name: string; Got: Boolean; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean;
|
||||
|
||||
function CheckResult(AnWatchExp: TWatchExpectation): Boolean;
|
||||
function CheckData(AContext: TWatchExpTestCurrentData; AnIgnoreRsn: String; AnIsNested: Boolean = True): Boolean; virtual;
|
||||
function CheckData(AContext: TWatchExpTestCurrentData; AnIgnoreRsn: String; AnIsNested: Boolean = True; ASkipErrCheck: Boolean = False): Boolean; virtual;
|
||||
function VerifyDebuggerState: Boolean; virtual;
|
||||
function VerifySymType(AContext: TWatchExpTestCurrentData; AnIgnoreRsn: String): Boolean; virtual;
|
||||
function VerifyTypeName(AContext: TWatchExpTestCurrentData; AnIgnoreRsn: String): Boolean; virtual;
|
||||
@ -345,6 +345,7 @@ function weUniStr(AExpVal: string; ATypeName: String=#1): TWatchExpectationResul
|
||||
function wePointer(ATypeName: String=''): TWatchExpectationResult;
|
||||
function wePointer(AExpVal: TWatchExpectationResult; ATypeName: String=''): TWatchExpectationResult;
|
||||
function wePointerAddr(AExpVal: Pointer; ATypeName: String=''): TWatchExpectationResult;
|
||||
function wePointerAddr(AExpVal: Pointer; AExpSubVal: TWatchExpectationResult; ATypeName: String=''): TWatchExpectationResult;
|
||||
|
||||
function weStatArray(const AExpVal: Array of TWatchExpectationResult; ATypeName: String=''): TWatchExpectationResult; overload;
|
||||
function weStatArray(const AExpVal: Array of TWatchExpectationResult; AExpFullLen: Integer; ATypeName: String=''): TWatchExpectationResult; overload;
|
||||
@ -656,6 +657,18 @@ begin
|
||||
Result.ExpPointerValue := AExpVal;
|
||||
end;
|
||||
|
||||
function wePointerAddr(AExpVal: Pointer; AExpSubVal: TWatchExpectationResult;
|
||||
ATypeName: String): TWatchExpectationResult;
|
||||
begin
|
||||
Result := Default(TWatchExpectationResult);
|
||||
Result.ExpResultKind := rkPointerAddr;
|
||||
Result.ExpSymKind := skPointer;
|
||||
Result.ExpTypeName := ATypeName;
|
||||
Result.ExpPointerValue := AExpVal;
|
||||
SetLength(Result.ExpSubResults, 1);
|
||||
Result.ExpSubResults[0] := AExpSubVal;
|
||||
end;
|
||||
|
||||
function weStatArray(const AExpVal: array of TWatchExpectationResult;
|
||||
ATypeName: String): TWatchExpectationResult;
|
||||
var
|
||||
@ -1431,7 +1444,7 @@ begin
|
||||
with Debugger.CurLocation do
|
||||
FTest.TestBaseName := FTest.TestBaseName + ' ' + TstTestName + ' WATCH: '+TstWatch.Expression+' AT '+ SrcFile + ':' + IntToStr(SrcLine) +')';
|
||||
if TstStackFrame > 0 then
|
||||
FTest.TestBaseName := FTest.TestBaseName + ' (Stack: ' + IntToStr(TstStackFrame) + ')';
|
||||
FTest.TestBaseName := FTest.TestBaseName + ' (Stack: ' + IntToStr(TstStackFrame) + ') ';
|
||||
if not VerifyDebuggerState then
|
||||
exit;
|
||||
FTest.LogText('###### ' + TstTestName + ' // ' + TstWatch.Expression + '###### '+LineEnding);
|
||||
@ -1447,6 +1460,9 @@ begin
|
||||
WatchVal := TstWatch.Values[Thread, Stack];
|
||||
Context.WatchRes := WatchVal.ResultData;
|
||||
|
||||
//debugln([' ## ## ', WatchVal.Expression]);
|
||||
//debugln([FWatchResultPrinter.PrintWatchValue(WatchVal.ResultData,wdfDefault)]); debugln;
|
||||
|
||||
if (Context.WatchRes <> nil) and
|
||||
(Context.WatchRes.ValueKind = rdkPCharOrString)
|
||||
then begin
|
||||
@ -1481,7 +1497,7 @@ begin
|
||||
end;
|
||||
if ehExpectErrorText in ehf then begin
|
||||
Result := TestTrue('TstWatch.value is NOT valid', WatchVal.Validity in [ddsError, ddsInvalid], Context, AnIgnoreRsn);
|
||||
Result := CheckData(Context, AnIgnoreRsn);
|
||||
Result := CheckData(Context, AnIgnoreRsn, True, True);
|
||||
exit;
|
||||
end;
|
||||
if ehExpectNotFound in ehf then begin
|
||||
@ -1525,9 +1541,26 @@ begin
|
||||
end;
|
||||
|
||||
function TWatchExpectationList.CheckData(AContext: TWatchExpTestCurrentData;
|
||||
AnIgnoreRsn: String; AnIsNested: Boolean): Boolean;
|
||||
AnIgnoreRsn: String; AnIsNested: Boolean; ASkipErrCheck: Boolean): Boolean;
|
||||
var
|
||||
ehf: TWatchExpErrorHandlingFlags;
|
||||
begin
|
||||
ehf := AContext.Expectation.ExpErrorHandlingFlags[Compiler.SymbolType];
|
||||
AContext.IsNested := AnIsNested;
|
||||
|
||||
// TODO: can be pre-printed for an error
|
||||
if not ASkipErrCheck then begin
|
||||
if ehExpectError in ehf then begin
|
||||
Result := TestTrue('IsErr', AContext.WatchRes.ValueKind in [rdkError, rdkPrePrinted], AContext, AnIgnoreRsn);
|
||||
exit;
|
||||
end;
|
||||
if ehExpectErrorText in ehf then begin
|
||||
Result := TestTrue('IsErr', AContext.WatchRes.ValueKind in [rdkError, rdkPrePrinted], AContext, AnIgnoreRsn);
|
||||
Result := CheckResultMatch(AContext, AnIgnoreRsn);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
case AContext.Expectation.ExpResultKind of
|
||||
rkMatch: Result := CheckResultMatch(AContext, AnIgnoreRsn);
|
||||
rkInteger: Result := CheckResultNum(AContext, False, AnIgnoreRsn);
|
||||
@ -1979,7 +2012,7 @@ begin
|
||||
if AContext.WatchRes.ValueKind = rdkPrePrinted then begin
|
||||
g := FWatchResultPrinter.PrintWatchValue(AContext.WatchRes, wdfDefault);
|
||||
|
||||
e := '(\$[0-9a-fA-F]*|nil)';
|
||||
e := '(\$[0-9a-fA-F]*\^?|nil)';
|
||||
tn := GetExpTypeNameAsRegEx(Expect);
|
||||
if (tn <> '') and
|
||||
(Length(Expect.ExpSubResults) = 1) and
|
||||
@ -1989,7 +2022,7 @@ begin
|
||||
tn := ''; // char pointer to not (always?) include the type
|
||||
if tn <> '' then
|
||||
e := tn+'\('+e+'\)';
|
||||
e := '^'+e+'([:\s=]|$)';
|
||||
e := '^'+e+'\^?([:\s=]|$)';
|
||||
|
||||
Result := TestMatches('Data', e, g, AContext, AnIgnoreRsn);
|
||||
|
||||
@ -2022,7 +2055,7 @@ begin
|
||||
SubContext := AContext;
|
||||
SubContext.WatchRes := TWatchResultDataPrePrinted.Create(g);
|
||||
SubContext.Expectation := Expect.ExpSubResults[0];
|
||||
FTest.TestBaseName := n + ' / deref value';
|
||||
FTest.TestBaseName := n + ' / deref value ';
|
||||
|
||||
Result := CheckData(SubContext, AnIgnoreRsn);
|
||||
|
||||
@ -2049,7 +2082,7 @@ begin
|
||||
SubContext := AContext;
|
||||
SubContext.WatchRes := AContext.WatchRes.DerefData;
|
||||
SubContext.Expectation := Expect.ExpSubResults[0];
|
||||
FTest.TestBaseName := n + ' / deref value';
|
||||
FTest.TestBaseName := n + ' / deref value ';
|
||||
|
||||
Result := VerifyTypeName(SubContext, AnIgnoreRsn);
|
||||
// TODO: check type specifics, like ValueKind, ByteSize, ... // ehIgnData
|
||||
@ -2093,8 +2126,11 @@ begin
|
||||
end
|
||||
else begin
|
||||
Result := TestTrue('ValKind', AContext.WatchRes.ValueKind = rdkPointerVal, AContext, AnIgnoreRsn);
|
||||
Result := TestEquals('Ptr-Addr', TDBGPtr(Expect.ExpPointerValue), AContext.WatchRes.DataAddress, AContext, AnIgnoreRsn);
|
||||
end;
|
||||
end;
|
||||
if (Length(Expect.ExpSubResults) = 1) then
|
||||
Result := CheckResultPointer(AContext, AnIgnoreRsn);
|
||||
end;
|
||||
|
||||
function TWatchExpectationList.CheckResultArray(
|
||||
@ -2150,7 +2186,7 @@ debugln([' expect ',Expect.ExpFullArrayLen,' got "',v,'"' ]);
|
||||
n := FTest.TestBaseName;
|
||||
SubContext := AContext;
|
||||
for i := 0 to min(e, length(Expect.ExpSubResults)) - 1 do begin
|
||||
FTest.TestBaseName := n + ' Idx='+IntToStr(i);
|
||||
FTest.TestBaseName := n + ' Idx='+IntToStr(i)+' ';
|
||||
AContext.WatchRes.SetSelectedIndex(i);
|
||||
|
||||
if PrePrint then
|
||||
@ -2238,7 +2274,7 @@ begin
|
||||
SubContext.WatchRes := TWatchResultDataPrePrinted.Create(
|
||||
FWatchResultPrinter.PrintWatchValue(AContext.WatchRes.Fields[j].Field, wdfDefault)
|
||||
);
|
||||
FTest.TestBaseName := n + ' Idx=' + IntToStr(i);
|
||||
FTest.TestBaseName := n + ' Idx=' + IntToStr(i)+' ';
|
||||
SubContext.Expectation := sr;
|
||||
Result := CheckData(SubContext, AnIgnoreRsn);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user