From a37d0771997bc902bff4a1553dc8f32416f2ea1d Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 31 Jan 2022 01:04:48 +0100 Subject: [PATCH] Debugger: Update LazDebuggerFp testcase for new LazDebuggerIntf / SetNumValue --- .../lazdebuggerfp/test/testwatches.pas | 113 ++++++++++-------- .../lazdebugtestbase/testdbgtestsuites.pas | 12 +- .../lazdebugtestbase/ttestwatchutilities.pas | 80 ++++++++++--- 3 files changed, 131 insertions(+), 74 deletions(-) diff --git a/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas b/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas index 6bb8336cd8..176a095170 100644 --- a/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas +++ b/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas @@ -628,7 +628,7 @@ procedure TTestWatches.TestWatchesValue; t.Add(AName, p+'Longint'+e, weInteger (5000+n, 'Longint', 4)); t.Add(AName, p+'Int64'+e, weInteger (50000+n, 'Int64', 8)); t.Add(AName, p+'IntRange'+e, weInteger (-50+n, 'TIntRange',0)); - t.Add(AName, p+'CardinalRange'+e, weInteger(50+n, 'TCardinalRange',0)); + t.Add(AName, p+'CardinalRange'+e, weCardinal(50+n, 'TCardinalRange',0)); t.Add(AName, p+'Byte_2'+e, weCardinal(240+n, 'Byte', 1)); t.Add(AName, p+'Word_2'+e, weCardinal(65501+n, 'Word', 2)); @@ -671,6 +671,8 @@ procedure TTestWatches.TestWatchesValue; t.Tests[-1]^.AddFlag(ehExpectError); // TODO: check error msg {$ENDIF} //t.Add(p+'Comp'+e, weInteger(150.125+n, 'Comp' )); +//TODO: currency // integer is wrong, but lets check it + t.Add(AName, p+'Currency'+e, weInteger(125123+n*1000, 'Currency' )); t.Add(AName, p+'Currency'+e, weFloat(125.123+n, 'Currency' ))^.AddFlag([ehNotImplementedData]) .SkipIf(ALoc = tlPointerAny); @@ -928,42 +930,42 @@ StartIdxClassConst := t.Count; //TODO: element by index - t.Add(AName, p+'ArrayEnum1'+e, weStatArray(weInteger([500+n,701,702,703]) )) + t.Add(AName, p+'ArrayEnum1'+e, weStatArray(weCardinal([500+n,701,702,703], 'WORD') )) .SkipIf(ALoc = tlParam).SkipIf(ALoc = tlPointer); t.AddIndexFromPrevious(['EnVal1','EnVal2','EnVal3','EnVal4', 'gvEnum', 'gvEnumA', 'gvEnum1', 'gcEnum', 'gcEnumA', 'gcEnum1', p+'Enum'+e, p+'EnumA'+e, p+'Enum1'+e], [0,1,2,3, 2,0,1, 2,0,1, 2,0,1]); - t.Add(AName, p+'ArrayEnum3'+e, weStatArray(weInteger([200+n,701,702,703]), 'TArrayEnum')); + t.Add(AName, p+'ArrayEnum3'+e, weStatArray(weCardinal([200+n,701,702,703], 'WORD'), 'TArrayEnum')); t.AddIndexFromPrevious(['EnVal1','EnVal2','EnVal3','EnVal4', 'gvEnum', 'gvEnumA', 'gvEnum1', 'gcEnum', 'gcEnumA', 'gcEnum1', p+'Enum'+e, p+'EnumA'+e, p+'Enum1'+e], [0,1,2,3, 2,0,1, 2,0,1, 2,0,1]); - t.Add(AName, p+'ArrayEnumSub1'+e, weStatArray(weInteger([600+n,801]) )) + t.Add(AName, p+'ArrayEnumSub1'+e, weStatArray(weCardinal([600+n,801], 'WORD') )) .SkipIf(ALoc = tlParam).SkipIf(ALoc = tlPointer); t.AddIndexFromPrevious(['EnVal1','EnVal2', 'gvEnumA', 'gvEnum1', 'gcEnumA', 'gcEnum1', p+'EnumA'+e, p+'Enum1'+e], [0,1, 0,1, 0,1, 0,1]); - t.Add(AName, p+'ArrayEnumSub3'+e, weStatArray(weInteger([100+n,801]), 'TArrayEnumSub')); + t.Add(AName, p+'ArrayEnumSub3'+e, weStatArray(weCardinal([100+n,801], 'WORD'), 'TArrayEnumSub')); t.AddIndexFromPrevious(['EnVal1','EnVal2', 'gvEnumA', 'gvEnum1', 'gcEnumA', 'gcEnum1', p+'EnumA'+e, p+'Enum1'+e], [0,1, 0,1, 0,1, 0,1]); - t.Add(AName, p+'ArrayEnum2'+e, weStatArray(weInteger([300+n,701,702,703]) )) + t.Add(AName, p+'ArrayEnum2'+e, weStatArray(weCardinal([300+n,701,702,703], 'WORD') )) .SkipIf(ALoc = tlParam).SkipIf(ALoc = tlPointer); t.AddIndexFromPrevious(['EnVal1','EnVal2','EnVal3','EnVal4', 'gvEnum', 'gvEnumA', 'gvEnum1', 'gcEnum', 'gcEnumA', 'gcEnum1', p+'Enum'+e, p+'EnumA'+e, p+'Enum1'+e], [0,1,2,3, 2,0,1, 2,0,1, 2,0,1]); - t.Add(AName, p+'ArrayEnum4'+e, weStatArray(weInteger([800+n,701,702,703]), 'TArrayEnumElem')); + t.Add(AName, p+'ArrayEnum4'+e, weStatArray(weCardinal([800+n,701,702,703], 'WORD'), 'TArrayEnumElem')); t.AddIndexFromPrevious(['EnVal1','EnVal2','EnVal3','EnVal4', 'gvEnum', 'gvEnumA', 'gvEnum1', 'gcEnum', 'gcEnumA', 'gcEnum1', p+'Enum'+e, p+'EnumA'+e, p+'Enum1'+e], [0,1,2,3, 2,0,1, 2,0,1, 2,0,1]); - t.Add(AName, p+'ArrayEnumSub2'+e, weStatArray(weInteger([400+n,801]) )) + t.Add(AName, p+'ArrayEnumSub2'+e, weStatArray(weCardinal([400+n,801], 'WORD') )) .SkipIf(ALoc = tlParam).SkipIf(ALoc = tlPointer); t.AddIndexFromPrevious(['EnVal1','EnVal2', 'gvEnumA', 'gvEnum1', 'gcEnumA', 'gcEnum1', p+'EnumA'+e, p+'Enum1'+e], [0,1, 0,1, 0,1, 0,1]); - t.Add(AName, p+'ArrayEnumSub4'+e, weStatArray(weInteger([700+n,801]), 'TArrayEnumSubElem')); + t.Add(AName, p+'ArrayEnumSub4'+e, weStatArray(weCardinal([700+n,801], 'WORD'), 'TArrayEnumSubElem')); t.AddIndexFromPrevious(['EnVal1','EnVal2', 'gvEnumA', 'gvEnum1', 'gcEnumA', 'gcEnum1', p+'EnumA'+e, p+'Enum1'+e], [0,1, 0,1, 0,1, 0,1]); @@ -1016,7 +1018,7 @@ for i := StartIdx to t.Count-1 do // bitpacked t.Add(AName, p+'BitPackBoolArray'+e, weStatArray(weBool([True, False, True, True]) )); t.AddIndexFromPrevious(['0','1','2','3'], [0,1,2,3]); - t.Add(AName, p+'BitPackTinyArray'+e, weStatArray(weInteger([1, 0, 3, 2]) )); + t.Add(AName, p+'BitPackTinyArray'+e, weStatArray(weCardinal([1, 0, 3, 2], 'TTinyRange') )); t.AddIndexFromPrevious(['0','1','2','3'], [0,1,2,3]); t.Add(AName, p+'BitPackTinyNegArray'+e, weStatArray(weInteger([2, -2, 0, -1]) )); t.AddIndexFromPrevious(['0','1','2','3'], [0,1,2,3]); @@ -1039,8 +1041,8 @@ for i := StartIdx to t.Count-1 do t.AddIndexFromPrevious(['0','1'], [0,1]); t.AddIndexFromPrevious(['0','1','2'], [0,1,2]); t.Add(AName, p+'BitPackTinyArray2'+e, weStatArray([ - weStatArray(weInteger([1, 0, 3])), - weStatArray(weInteger([2, 3, 0])) + weStatArray(weCardinal([1, 0, 3], 'TTinyRange')), + weStatArray(weCardinal([2, 3, 0], 'TTinyRange')) ])); t.AddIndexFromPrevious(['0','1'], [0,1]); t.AddIndexFromPrevious(['0','1','2'], [0,1,2]); @@ -1073,7 +1075,11 @@ for i := StartIdx to t.Count-1 do ], 'TBitPackBoolRecord') ); t.AddMemberFromPrevious(); t.Add(AName, p+'BitPackTinyRecord'+e, weRecord([ - weInteger(1).N('a'), weInteger(1).N('b'), weInteger(0).N('c'), weInteger(3).N('d'), weInteger(0).N('e') + weCardinal(1, 'TTinyRange').N('a'), + weCardinal(1, 'TTinyRange').N('b'), + weCardinal(0, 'TTinyRange').N('c'), + weCardinal(3, 'TTinyRange').N('d'), + weCardinal(0, 'TTinyRange').N('e') ], 'TBitPackTinyRecord') ); t.AddMemberFromPrevious(); t.Add(AName, p+'BitPackTinyNegRecord'+e, weRecord([ @@ -1107,8 +1113,8 @@ for i := StartIdx to t.Count-1 do t.AddIndexFromPrevious(['0','1','2','3'], [0,1,2,3]); t.Add(AName, p+'BitPackTinyArrayRecord'+e, weRecord([ - weStatArray(weInteger([1, 0, 3, 2])).N('a'), - weStatArray(weInteger([2, 3, 0, 1])).N('b') + weStatArray(weCardinal([1, 0, 3, 2], 'TTinyRange')).N('a'), + weStatArray(weCardinal([2, 3, 0, 1], 'TTinyRange')).N('b') ], 'TBitPackTinyArrayRecord') ); t.AddMemberFromPrevious(); t.AddIndexFromPrevious(['0','1','2','3'], [0,1,2,3]); @@ -1180,9 +1186,10 @@ begin //t.Add('gvBitPackBoolArray', weStatArray(weBool([True, False, True, True]) )); //t.Add('MyClass2.cl_c_Byte', weStatArray(weBool([True, False, True, True]) )); //t.Add('MyClass2.cl_c_ShortRec', weStatArray(weBool([True, False, True, True]) )); -//t.EvaluateWatches; -//t.CheckResults; -//exit; +t.Add('', 'gcPChar', wePointer(weAnsiStr(''), 'PChar')); +t.EvaluateWatches; +t.CheckResults; +exit; t.Add('U8Data1', weAnsiStr(''''#$E2#$89#$A7'''', 'Utf8String')) //t.Add('U8Data1', weAnsiStr(''''#$2267'''', 'Utf8String')) @@ -1932,6 +1939,7 @@ procedure TTestWatches.TestWatchesTypeCast; p, e, val: String; Thread, n, StartIdx, i: Integer; we: PWatchExpectation; + v: QWord; begin p := APrefix; n := AOffs; @@ -1952,22 +1960,24 @@ procedure TTestWatches.TestWatchesTypeCast; Thread := Debugger.Threads.Threads.CurrentThreadId; StartIdx := t.Count; // tlConst => Only eval the watch. No tests - val := t2.Tests[0]^.TstWatch.Values[Thread, 0].Value; - t.Add(AName+' Int', 'PtrUInt('+p+'Instance1'+e+')', weCardinal(StrToQWordDef(val, qword(-7)), 'PtrUInt', -1)); + v := t2.Tests[0]^.TstWatch.Values[Thread, 0].NumValueRaw; + val := t2.Tests[0]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; + t.Add(AName+' Int', 'PtrUInt('+p+'Instance1'+e+')', weCardinal(v, 'PtrUInt', -1)); t.Add(AName+' TClass1', 'TClass1('+p+'Instance1_Int'+e+')', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); t.Add(AName+' TClass1', 'TClass1('+val+')', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); t.Add(AName+' TClass1', 'TClass1(Pointer('+p+'Instance1_Int'+e+'))', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); t.Add(AName+' TClass1', 'TClass1(Pointer('+val+'))', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); - val := t2.Tests[1]^.TstWatch.Values[Thread, 0].Value; + val := t2.Tests[1]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; t.Add(AName+' PTxInstance1', 'PTxInstance1(@'+p+'Instance1'+e+')^', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); t.Add(AName+' PTxInstance1', 'PTxInstance1('+val+')^', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); t.Add(AName+' PTxInstance1', 'PTxInstance1(Pointer(@'+p+'Instance1'+e+'))^', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); t.Add(AName+' PTxInstance1', 'PTxInstance1(Pointer('+val+'))^', weMatch('FAnsi *=[ $0-9A-F()]*\^?:? *'''+AChr1+'T', skClass)); - val := t2.Tests[2]^.TstWatch.Values[Thread, 0].Value; - t.Add(AName+' Ansi', 'PtrUInt('+p+'Ansi5'+e+')', weCardinal(StrToQWordDef(val, qword(-7)), 'PtrUInt', -1)); + v := t2.Tests[2]^.TstWatch.Values[Thread, 0].NumValueRaw; + val := t2.Tests[2]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; + t.Add(AName+' Ansi', 'PtrUInt('+p+'Ansi5'+e+')', weCardinal(v, 'PtrUInt', -1)); t.Add(AName+' AnsiString', 'AnsiString('+p+'Ansi5_Int'+e+')', weAnsiStr(AChr1+'bcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghij') ).IgnKindPtr(stDwarf2) .IgnKind(stDwarf3Up); @@ -1975,8 +1985,9 @@ StartIdx := t.Count; // tlConst => Only eval the watch. No tests weAnsiStr(AChr1+'bcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghijAbcdefghij') ).IgnKindPtr(stDwarf2) .IgnKind(stDwarf3Up); - val := t2.Tests[3]^.TstWatch.Values[Thread, 0].Value; - t.Add(AName+' DynArray', 'PtrUInt('+p+'IntDynArray4'+e+')', weCardinal(StrToQWordDef(val, qword(-7)), 'PtrUInt', -1)); + v := t2.Tests[3]^.TstWatch.Values[Thread, 0].NumValueRaw; + val := t2.Tests[3]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; + t.Add(AName+' DynArray', 'PtrUInt('+p+'IntDynArray4'+e+')', weCardinal(v, 'PtrUInt', -1)); t.Add(AName, 'TIntDynArray('+p+'IntDynArray4_Int'+e+')', weDynArray(weInteger([12, 30+AOffs, 60]), 'TIntDynArray')); t.Add(AName, 'TIntDynArray('+val+')', weDynArray(weInteger([12, 30+AOffs, 60]), 'TIntDynArray')); t.Add(AName, 'TIntDynArray(Pointer('+p+'IntDynArray4_Int'+e+'))', weDynArray(weInteger([12, 30+AOffs, 60]), 'TIntDynArray')); @@ -1984,7 +1995,7 @@ StartIdx := t.Count; // tlConst => Only eval the watch. No tests t.Add(AName, 'TIntDynArray(PtrUint('+p+'IntDynArray4_Int'+e+'))', weDynArray(weInteger([12, 30+AOffs, 60]), 'TIntDynArray')); t.Add(AName, 'TIntDynArray(PtrUint('+val+'))', weDynArray(weInteger([12, 30+AOffs, 60]), 'TIntDynArray')); - val := t2.Tests[4]^.TstWatch.Values[Thread, 0].Value; + val := t2.Tests[4]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; t.Add(AName, 'PTxIntDynArray4(@'+p+'IntDynArray4'+e+')^', weDynArray(weInteger([12, 30+AOffs, 60]), 'TxIntDynArray4')); t.Add(AName, 'PTxIntDynArray4('+val+')^', weDynArray(weInteger([12, 30+AOffs, 60]), 'TxIntDynArray4')); t.Add(AName, 'PTxIntDynArray4(Pointer(@'+p+'IntDynArray4'+e+'))^', weDynArray(weInteger([12, 30+AOffs, 60]), 'TxIntDynArray4')); @@ -1996,7 +2007,7 @@ StartIdx := t.Count; // tlConst => Only eval the watch. No tests - val := t2.Tests[5]^.TstWatch.Values[Thread, 0].Value; + val := t2.Tests[5]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; t.Add(AName, 'PTxWord(@'+p+'Word'+e+')^', weCardinal(100+n, 'TxWord', 2)); t.Add(AName, 'PTxWord('+val+')^', weCardinal(100+n, 'TxWord', 2)); t.Add(AName, 'PTxWord(Pointer(@'+p+'Word'+e+'))^', weCardinal(100+n, 'TxWord', 2)); @@ -2011,7 +2022,7 @@ StartIdx := t.Count; // tlConst => Only eval the watch. No tests t.Add(AName, '^TxWord($'+IntToHex(StrToInt64Def(val, 0), 8)+')^', weCardinal(100+n, 'TxWord', 2)); - val := t2.Tests[6]^.TstWatch.Values[Thread, 0].Value; + val := t2.Tests[6]^.TstWatch.Values[Thread, 0].NumValue[wdfHex]; t.Add(AName, 'PTxFiveRec(@'+p+'FiveRec'+e+')^', weMatch('a *=.*b *= *44',skRecord)); t.Add(AName, 'PTxFiveRec('+val+')^', weMatch('a *=.*b *= *44',skRecord)); t.Add(AName, 'PTxFiveRec(Pointer(@'+p+'FiveRec'+e+'))^', weMatch('a *=.*b *= *44',skRecord)); @@ -2271,14 +2282,14 @@ procedure TTestWatches.TestWatchesExpression; .skipIf((ALoc in [tlConst]) or (ALoc2 in [tlConst])); - t.Add(AName, p+'Word'+e +' and '+ p+'LongWord'+e, weInteger((100+n) and (1000+n)) ); - t.Add(AName, p+'Word'+e +' and Byte('+ p+'Char'+e+')', weInteger((100+n) and Byte(AChr1)) ); - t.Add(AName, p+'Word'+e +' and '+ IntToStr(1002+n), weInteger((100+n) and (1002+n)) ); - t.Add(AName, p+'Word'+e +' and ShortInt('+ p+'Char'+e+')', weInteger((100+n) and Byte(AChr1)) ); + t.Add(AName, p+'Word'+e +' and '+ p+'LongWord'+e, weCardinal((100+n) and (1000+n)) ); + t.Add(AName, p+'Word'+e +' and Byte('+ p+'Char'+e+')', weCardinal((100+n) and Byte(AChr1)) ); + t.Add(AName, p+'Word'+e +' and '+ IntToStr(1002+n), weCardinal((100+n) and (1002+n)) ); + t.Add(AName, p+'Word'+e +' and ShortInt('+ p+'Char'+e+')', weCardinal((100+n) and Byte(AChr1)) ); t.Add(AName, p+'ShortInt'+e +' and '+ p+'SmallInt'+e, weInteger((50+n) and (500+n)) ); - t.Add(AName, p+'ShortInt'+e +' and '+ p+'Word'+e, weInteger((50+n) and (1000+n)) ); - t.Add(AName, p+'ShortInt'+e +' and '+ IntToStr(1002+n), weInteger((50+n) and (1002+n)) ); + t.Add(AName, p+'ShortInt'+e +' and '+ p+'Word'+e, weCardinal((50+n) and (1000+n)) ); + t.Add(AName, p+'ShortInt'+e +' and '+ IntToStr(1002+n), weCardinal((50+n) and (1002+n)) ); for i := 0 to t.Count-1 do t.Tests[i].IgnTypeName(); @@ -2320,7 +2331,7 @@ begin t.Clear; // Constant values - t.Add('Const-Expr: 107', '107', weInteger(107)); + t.Add('Const-Expr: 107', '107', weCardinal(107)); t.Add('Const-Expr: $10', '$10', weInteger(16)); t.Add('Const-Expr: -17', '-17', weInteger(-17)); t.Add('Const-Expr: True', 'True', weBool(True)); @@ -2360,27 +2371,27 @@ begin t.Add('Const-Expr: ansistring ', '#A', weAnsiStr('abc')).IgnKind.AddFlag(ehExpectError); t.Add('Const-Expr: ansistring ', '#$X', weAnsiStr('abc')).IgnKind.AddFlag(ehExpectError); - t.Add('Const-Op: ', '10', weInteger(10)); + t.Add('Const-Op: ', '10', weCardinal(10)); t.Add('Const-Op: ', '-10', weInteger(-10)); t.Add('Const-Op: ', '- -10', weInteger(10)); // 2 unary - t.Add('Const-Op: ', '+10', weInteger(10)); + t.Add('Const-Op: ', '+10', weCardinal(10)); - t.Add('Const-Op: ', '107 + 1', weInteger(108)); - t.Add('Const-Op: ', '107 - 1', weInteger(106)); + t.Add('Const-Op: ', '107 + 1', weCardinal(108)); + t.Add('Const-Op: ', '107 - 1', weCardinal(106)); t.Add('Const-Op: ', '107 + -1', weInteger(106)); - t.Add('Const-Op: ', '107 + +1', weInteger(108)); + t.Add('Const-Op: ', '107 + +1', weCardinal(108)); t.Add('Const-Op: ', '107 - -1', weInteger(108)); - t.Add('Const-Op: ', '11 * 3', weInteger(33)); + t.Add('Const-Op: ', '11 * 3', weCardinal(33)); t.Add('Const-Op: ', '11 * -3', weInteger(-33)); t.Add('Const-Op: ', '-11 * 3', weInteger(-33)); t.Add('Const-Op: ', '-11 * -3', weInteger(33)); t.Add('Const-Op: ', '11 / 3', weMatch('3\.666', skFloat)); - t.Add('Const-Op: ', '11 div 3', weInteger(3)); - t.Add('Const-Op: ', '11 mod 3', weInteger(2)); - t.Add('Const-precedence: ', '1 + 11 * 3', weInteger(34)); - t.Add('Const-precedence: ', '11 * 3 + 1', weInteger(34)); - t.Add('Const-bracket: ', '(1 + 11) * 3', weInteger(36)); - t.Add('Const-bracket: ', '11 * (3 + 1)', weInteger(44)); + t.Add('Const-Op: ', '11 div 3', weCardinal(3)); + t.Add('Const-Op: ', '11 mod 3', weCardinal(2)); + t.Add('Const-precedence: ', '1 + 11 * 3', weCardinal(34)); + t.Add('Const-precedence: ', '11 * 3 + 1', weCardinal(34)); + t.Add('Const-bracket: ', '(1 + 11) * 3', weCardinal(36)); + t.Add('Const-bracket: ', '11 * (3 + 1)', weCardinal(44)); t.Add('Const-Op: ', '1.5', weFloat(1.5)); t.Add('Const-Op: ', '-1.5', weFloat(-1.5)); @@ -2411,10 +2422,10 @@ begin t.Add('Const-Op: ', '-13.5 / 1.5', weFloat(-9)); t.Add('Const-Op: ', '-13.5 / -1.5', weFloat(9)); - t.Add('Const-Op: ', '35 And 17', weInteger(1)); - t.Add('Const-Op: ', '35 And 7', weInteger(3)); - t.Add('Const-Op: ', '35 or 7', weInteger(39)); - t.Add('Const-Op: ', '35 Xor 7', weInteger(36)); + t.Add('Const-Op: ', '35 And 17', weCardinal(1)); + t.Add('Const-Op: ', '35 And 7', weCardinal(3)); + t.Add('Const-Op: ', '35 or 7', weCardinal(39)); + t.Add('Const-Op: ', '35 Xor 7', weCardinal(36)); t.Add('Const-EQ: ', '17 = $11', weBool(True)); t.Add('Const-EQ: ', '18 = $11', weBool(False)); diff --git a/components/lazdebuggers/lazdebugtestbase/testdbgtestsuites.pas b/components/lazdebuggers/lazdebugtestbase/testdbgtestsuites.pas index 23e7a1a219..315e9f6ae8 100644 --- a/components/lazdebuggers/lazdebugtestbase/testdbgtestsuites.pas +++ b/components/lazdebuggers/lazdebugtestbase/testdbgtestsuites.pas @@ -121,9 +121,9 @@ type function TestEquals(Name: string; const Expected, Got: string; ACaseSense: Boolean; MinDbgVers: Integer = 0; AIgnoreReason: String = ''): Boolean; function TestEquals(Name: string; const Expected, Got: string; ACaseSense: Boolean; MinDbgVers: Integer; MinFpcVers: Integer; AIgnoreReason: String = ''): Boolean; - function TestEquals(Expected, Got: integer): Boolean; - function TestEquals(Name: string; Expected, Got: integer; MinDbgVers: Integer = 0; AIgnoreReason: String = ''): Boolean; - function TestEquals(Name: string; Expected, Got: integer; MinDbgVers: Integer; MinFpcVers: Integer; AIgnoreReason: String = ''): Boolean; + function TestEquals(Expected, Got: Int64): Boolean; + function TestEquals(Name: string; Expected, Got: int64; MinDbgVers: Integer = 0; AIgnoreReason: String = ''): Boolean; + function TestEquals(Name: string; Expected, Got: Int64; MinDbgVers: Integer; MinFpcVers: Integer; AIgnoreReason: String = ''): Boolean; function TestTrue(Name: string; Got: Boolean; MinDbgVers: Integer = 0; AIgnoreReason: String = ''): Boolean; function TestTrue(Name: string; Got: Boolean; MinDbgVers: Integer; MinFpcVers: Integer; AIgnoreReason: String = ''): Boolean; @@ -569,18 +569,18 @@ begin else AddTestError(Name, MinDbgVers, MinFpcVers, AIgnoreReason); end; -function TDBGTestCase.TestEquals(Expected, Got: integer): Boolean; +function TDBGTestCase.TestEquals(Expected, Got: Int64): Boolean; begin Result := TestEquals('', Expected, Got); end; -function TDBGTestCase.TestEquals(Name: string; Expected, Got: integer; +function TDBGTestCase.TestEquals(Name: string; Expected, Got: int64; MinDbgVers: Integer; AIgnoreReason: String): Boolean; begin Result := TestEquals(Name, Expected, Got, MinDbgVers, 0, AIgnoreReason); end; -function TDBGTestCase.TestEquals(Name: string; Expected, Got: integer; +function TDBGTestCase.TestEquals(Name: string; Expected, Got: Int64; MinDbgVers: Integer; MinFpcVers: Integer; AIgnoreReason: String): Boolean; begin Result := Got = Expected; diff --git a/components/lazdebuggers/lazdebugtestbase/ttestwatchutilities.pas b/components/lazdebuggers/lazdebugtestbase/ttestwatchutilities.pas index f88830f19c..c5ca4c5f32 100644 --- a/components/lazdebuggers/lazdebugtestbase/ttestwatchutilities.pas +++ b/components/lazdebuggers/lazdebugtestbase/ttestwatchutilities.pas @@ -223,7 +223,7 @@ type function TestMatches(Name: string; Expected, Got: string; ACaseSense: Boolean; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; function TestEquals(Name: string; Expected, Got: string; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; function TestEquals(Name: string; Expected, Got: string; ACaseSense: Boolean; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; - function TestEquals(Name: string; Expected, Got: integer; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; + function TestEquals(Name: string; Expected, Got: int64; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; function TestTrue(Name: string; Got: Boolean; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; function TestFalse(Name: string; Got: Boolean; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; @@ -326,6 +326,7 @@ function weDynArray(const AExpVal: Array of TWatchExpectationResult; AExpFullLen function weChar(const AExpVal: array of char; ATypeName: String=#1): TWatchExpectationResultArray; function weWideChar(const AExpVal: array of char; ATypeName: String=#1): TWatchExpectationResultArray; function weInteger(const AExpVal: array of Int64; ATypeName: String=#1; ASize: Integer = 4): TWatchExpectationResultArray; +function weCardinal(const AExpVal: array of QWord; ATypeName: String=#1; ASize: Integer = 4): TWatchExpectationResultArray; function weAnsiStr(const AExpVal: array of string; ATypeName: String=#1): TWatchExpectationResultArray; function weShortStr(const AExpVal: array of string; ATypeName: String=#1): TWatchExpectationResultArray; function weBool(const AExpVal: array of Boolean; ATypeName: String=#1): TWatchExpectationResultArray; @@ -695,6 +696,16 @@ begin Result[i] := weInteger(AExpVal[i], ATypeName, ASize); end; +function weCardinal(const AExpVal: array of QWord; ATypeName: String; + ASize: Integer): TWatchExpectationResultArray; +var + i: Integer; +begin + SetLength(Result, Length(AExpVal)); + for i := 0 to Length(AExpVal) - 1 do + Result[i] := weCardinal(AExpVal[i], ATypeName, ASize); +end; + function weAnsiStr(const AExpVal: array of string; ATypeName: String ): TWatchExpectationResultArray; var @@ -1254,7 +1265,7 @@ begin Result := FTest.TestEquals(Name, Expected, Got, ACaseSense, AContext.WatchExp.TstMinDbg, AContext.WatchExp.TstMinFpc, AIgnoreReason); end; -function TWatchExpectationList.TestEquals(Name: string; Expected, Got: integer; +function TWatchExpectationList.TestEquals(Name: string; Expected, Got: int64; AContext: TWatchExpTestCurrentData; AIgnoreReason: String): Boolean; begin Result := FTest.TestEquals(Name, Expected, Got, AContext.WatchExp.TstMinDbg, AContext.WatchExp.TstMinFpc, AIgnoreReason); @@ -1332,10 +1343,15 @@ begin if not TestTrue('TstWatch.value is valid', WatchVal.Validity = ddsValid, Context, AnIgnoreRsn) then exit; - if (not (ehNoTypeInfo in ehf)) and - TestTrue('Has TypeInfo', Context.WatchVal.TypeInfo <> nil, Context, AnIgnoreRsn) - then - Context.HasTypeInfo := True; + if (not (ehNoTypeInfo in ehf)) then begin + if (Context.WatchVal.ValidTypes * [vtNumVal, vtTypeName] = [vtNumVal, vtTypeName]) + then + Context.HasTypeInfo := True + else + if TestTrue('Has TypeInfo', Context.WatchVal.TypeInfo <> nil, Context, AnIgnoreRsn) + then + Context.HasTypeInfo := True; + end; if EvalCallTestFlags <> [] then begin TestTrue('Got eval res', EvalCallResReceived, Context, AnIgnoreRsn); @@ -1404,6 +1420,11 @@ begin if (not AContext.HasTypeInfo) then exit; + if (AContext.WatchVal.TypeInfo = nil) then begin + TestTrue('numval instead of typeinfo', vtNumVal in AContext.WatchVal.ValidTypes, AContext, AnIgnoreRsn); + exit; + end; + t := AContext.WatchVal.TypeInfo.Kind; WriteStr(s1, t); WriteStr(s2, Expect.ExpSymKind); @@ -1459,7 +1480,10 @@ begin if ehNotImplementedType in ehf then AnIgnoreRsn := AnIgnoreRsn + 'Not implemented (typename)'; - WtchTpName := AContext.WatchVal.TypeInfo.TypeName; + if vtTypeName in AContext.WatchVal.ValidTypes then + WtchTpName := AContext.WatchVal.TypeName + else + WtchTpName := AContext.WatchVal.TypeInfo.TypeName; if ehMatchTypeName in ehf then Result := TestMatches('TypeName', Expect.ExpTypeName, WtchTpName, AContext, AnIgnoreRsn) @@ -1502,12 +1526,18 @@ function TWatchExpectationList.CheckResultMatch( AContext: TWatchExpTestCurrentData; AnIgnoreRsn: String): Boolean; var Expect: TWatchExpectationResult; + s: String; begin with AContext.WatchExp do begin Result := True; Expect := AContext.Expectation; - Result := TestMatches('Data', Expect.ExpTextData, AContext.WatchVal.Value, AContext, AnIgnoreRsn); + if vtNumVal in AContext.WatchVal.ValidTypes then + s := AContext.WatchVal.NumValue[wdfDefault] + else + s := AContext.WatchVal.Value; + + Result := TestMatches('Data', Expect.ExpTextData, s, AContext, AnIgnoreRsn); end; end; @@ -1521,13 +1551,29 @@ begin with AContext.WatchExp do begin Result := True; Expect := AContext.Expectation; + //AContext.Expectation.ExpSymKind ??? - if IsCardinal then - s := IntToStr(Expect.expCardinalValue) - else - s := IntToStr(Expect.expIntValue); + //Result := TestTrue('NumVal ', vtNumVal in AContext.WatchVal.ValidTypes, AContext, AnIgnoreRsn); + + if vtNumVal in AContext.WatchVal.ValidTypes then begin + if IsCardinal then begin + Result := TestTrue('NumFlag ', AContext.WatchVal.NumFlags = [nvfUnsigned], AContext, AnIgnoreRsn); + Result := TestEquals('num Data', Int64(Expect.ExpCardinalValue), Int64(AContext.WatchVal.NumValueRaw), AContext, AnIgnoreRsn); + end + else begin + Result := TestTrue('NumFlag ', AContext.WatchVal.NumFlags = [], AContext, AnIgnoreRsn); + Result := TestEquals('num Data', Expect.ExpIntValue, Int64(AContext.WatchVal.NumValueRaw), AContext, AnIgnoreRsn); + end; + end + else begin + if IsCardinal then + s := IntToStr(Expect.expCardinalValue) + else + s := IntToStr(Expect.expIntValue); + + Result := TestEquals('Data', s, AContext.WatchVal.Value, AContext, AnIgnoreRsn); + end; - Result := TestEquals('Data', s, AContext.WatchVal.Value, AContext, AnIgnoreRsn); //if not TestEquals('DataSize', Expect.ExpIntSize, AContext.WatchVal.TypeInfo.Len, AContext, AnIgnoreRsn) then // Result := False; @@ -1742,19 +1788,19 @@ begin if (tn <> '') and (Length(Expect.ExpSubResults) = 1) and (Expect.ExpSubResults[0].ExpResultKind in [rkChar, rkAnsiString, rkWideString, rkShortString]) and - (not FTest.Matches(tn+'\(', AContext.WatchVal.Value)) + (not FTest.Matches(tn+'\(', AContext.WatchVal.NumValue[wdfDefault])) then tn := ''; // char pointer to not (always?) include the type if tn <> '' then e := tn+'\('+e+'\)'; e := '^'+e; - Result := TestMatches('Data', e, AContext.WatchVal.Value, AContext, AnIgnoreRsn); + Result := TestMatches('Data', e, AContext.WatchVal.NumValue[wdfDefault], AContext, AnIgnoreRsn); if ehIgnPointerDerefData in ehf then exit; - g := AContext.WatchVal.Value; + g := AContext.WatchVal.NumValue[wdfDefault]; i := pos(' ', g); if i > 1 then delete(g, 1, i) @@ -1815,7 +1861,7 @@ begin e := tn+'\('+e+'\)'; e := '^'+e; - Result := TestMatches('Data', e, AContext.WatchVal.Value, AContext, AnIgnoreRsn); + Result := TestMatches('Data', e, AContext.WatchVal.NumValue[wdfDefault], AContext, AnIgnoreRsn); end; end;