mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 02:16:14 +02:00
FpDebug: add error message
git-svn-id: trunk@63384 -
This commit is contained in:
parent
a667bbd318
commit
f97bb256fd
@ -2119,6 +2119,7 @@ end;
|
||||
function TFpPascalExpressionPart.DoGetResultValue: TFpValue;
|
||||
begin
|
||||
Result := nil;
|
||||
SetError('Can not evaluate: "'+GetText+'"');
|
||||
end;
|
||||
|
||||
procedure TFpPascalExpressionPart.ResetEvaluation;
|
||||
|
@ -22,6 +22,7 @@ type
|
||||
procedure TestWatchesAddressOf;
|
||||
procedure TestWatchesTypeCast;
|
||||
procedure TestWatchesExpression;
|
||||
procedure TestWatchesErrors;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -29,7 +30,7 @@ implementation
|
||||
var
|
||||
ControlTestWatch, ControlTestWatchScope, ControlTestWatchValue,
|
||||
ControlTestWatchAddressOf, ControlTestWatchTypeCast,
|
||||
ControlTestExpression: Pointer;
|
||||
ControlTestExpression, ControlTestErrors: Pointer;
|
||||
|
||||
procedure TTestWatches.RunToPause(var ABrk: TDBGBreakPoint);
|
||||
begin
|
||||
@ -2176,6 +2177,62 @@ begin
|
||||
|
||||
|
||||
|
||||
finally
|
||||
t.Free;
|
||||
Debugger.ClearDebuggerMonitors;
|
||||
Debugger.FreeDebugger;
|
||||
|
||||
AssertTestErrors;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestWatches.TestWatchesErrors;
|
||||
var
|
||||
ExeName: String;
|
||||
t: TWatchExpectationList;
|
||||
Src: TCommonSource;
|
||||
BrkPrg, BrkFoo, BrkFooVar, BrkFooConstRef: TDBGBreakPoint;
|
||||
begin
|
||||
if SkipTest then exit;
|
||||
if not TestControlCanTest(ControlTestErrors) then exit;
|
||||
t := nil;
|
||||
|
||||
Src := GetCommonSourceFor('WatchesValuePrg.Pas');
|
||||
TestCompile(Src, ExeName);
|
||||
|
||||
AssertTrue('Start debugger', Debugger.StartDebugger(AppDir, ExeName));
|
||||
|
||||
try
|
||||
t := TWatchExpectationList.Create(Self);
|
||||
t.AcceptSkSimple := [skInteger, skCardinal, skBoolean, skChar, skFloat,
|
||||
skString, skAnsiString, skCurrency, skVariant, skWideString,
|
||||
skInterface];
|
||||
t.AddTypeNameAlias('integer', 'integer|longint');
|
||||
t.AddTypeNameAlias('ShortStr255', 'ShortStr255|ShortString');
|
||||
t.AddTypeNameAlias('TEnumSub', 'TEnum|TEnumSub');
|
||||
|
||||
BrkPrg := Debugger.SetBreakPoint(Src, 'Prg');
|
||||
//BrkFoo := Debugger.SetBreakPoint(Src, 'Foo');
|
||||
//BrkFooVar := Debugger.SetBreakPoint(Src, 'FooVar');
|
||||
//BrkFooConstRef := Debugger.SetBreakPoint(Src, 'FooConstRef');
|
||||
AssertDebuggerNotInErrorState;
|
||||
|
||||
(* ************ Nested Functions ************* *)
|
||||
|
||||
RunToPause(BrkPrg);
|
||||
|
||||
t.Clear;
|
||||
// Constant values
|
||||
//t.Add('', '^char(1)^+[1]', weMatchErr('Can not evaluate: "\[1\]"'));
|
||||
t.Add('', '^char(1)^+[1]', weMatchErr('Can not evaluate: "\['));
|
||||
|
||||
|
||||
t.EvaluateWatches;
|
||||
t.CheckResults;
|
||||
|
||||
|
||||
|
||||
|
||||
finally
|
||||
t.Free;
|
||||
Debugger.ClearDebuggerMonitors;
|
||||
@ -2194,6 +2251,8 @@ initialization
|
||||
ControlTestWatchAddressOf := TestControlRegisterTest('AddressOf', ControlTestWatch);
|
||||
ControlTestWatchTypeCast := TestControlRegisterTest('TypeCast', ControlTestWatch);
|
||||
ControlTestExpression := TestControlRegisterTest('Expression', ControlTestWatch);
|
||||
ControlTestErrors := TestControlRegisterTest('Errors', ControlTestWatch);
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
@ -38,6 +38,7 @@ type
|
||||
|
||||
ehExpectNotFound,
|
||||
ehExpectError, // watch is invalid (less specific, than not found / maybe invalid expression ?)
|
||||
ehExpectErrorText, // watch is invalid // still test for Expected test
|
||||
|
||||
ehNotImplemented, // The debugger is known to fail this test // same as ehIgnAll
|
||||
ehNotImplementedKind, // skSimple...
|
||||
@ -286,6 +287,7 @@ type
|
||||
|
||||
|
||||
function weMatch(AExpVal: String; ASymKind: TDBGSymbolKind; ATypeName: String=''): TWatchExpectationResult;
|
||||
function weMatchErr(AExpVal: String): TWatchExpectationResult;
|
||||
|
||||
function weInteger(AExpVal: Int64; ATypeName: String=#1; ASize: Integer = 4): TWatchExpectationResult;
|
||||
function weCardinal(AExpVal: QWord; ATypeName: String=#1; ASize: Integer = 4): TWatchExpectationResult;
|
||||
@ -407,6 +409,15 @@ begin
|
||||
Result.ExpTextData := AExpVal;
|
||||
end;
|
||||
|
||||
function weMatchErr(AExpVal: String): TWatchExpectationResult;
|
||||
begin
|
||||
Result := Default(TWatchExpectationResult);
|
||||
Result.ExpResultKind := rkMatch;
|
||||
Result.ExpSymKind := skNone;
|
||||
Result.ExpTextData := AExpVal;
|
||||
Result.AddFlag(ehExpectErrorText);
|
||||
end;
|
||||
|
||||
function weInteger(AExpVal: Int64; ATypeName: String; ASize: Integer
|
||||
): TWatchExpectationResult;
|
||||
begin
|
||||
@ -1259,6 +1270,11 @@ begin
|
||||
Result := TestTrue('TstWatch.value is NOT valid', WatchVal.Validity in [ddsError, ddsInvalid], Context, AnIgnoreRsn);
|
||||
exit;
|
||||
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);
|
||||
exit;
|
||||
end;
|
||||
if ehExpectNotFound in ehf then begin
|
||||
Result := TestMatches('TstWatch.value NOT found', 'not found', WatchVal.Value, Context, AnIgnoreRsn);
|
||||
Result := TestTrue('TstWatch.value NOT found', WatchVal.Validity in [ddsError, ddsInvalid], Context, AnIgnoreRsn);
|
||||
|
Loading…
Reference in New Issue
Block a user