mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:19:16 +02:00
codetools: added test for FindCodeContext of attribute params
git-svn-id: trunk@56512 -
This commit is contained in:
parent
fa28ac6748
commit
4a688b6468
@ -45,6 +45,7 @@ type
|
|||||||
procedure Test_GetValuesOfCaseVariable_Enum;
|
procedure Test_GetValuesOfCaseVariable_Enum;
|
||||||
procedure Test_FindCodeContext_ProcParams;
|
procedure Test_FindCodeContext_ProcParams;
|
||||||
procedure Test_FindCodeContext_ProcTypeParams;
|
procedure Test_FindCodeContext_ProcTypeParams;
|
||||||
|
procedure Test_FindCodeContext_AttributeParams;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -134,7 +135,6 @@ var
|
|||||||
SrcMark: TFDMarker;
|
SrcMark: TFDMarker;
|
||||||
CursorPos: TCodeXYPosition;
|
CursorPos: TCodeXYPosition;
|
||||||
CodeContexts: TCodeContextInfo;
|
CodeContexts: TCodeContextInfo;
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
StartProgram;
|
StartProgram;
|
||||||
Add([
|
Add([
|
||||||
@ -156,14 +156,54 @@ begin
|
|||||||
Fail('CodeToolBoss.FindCodeContext');
|
Fail('CodeToolBoss.FindCodeContext');
|
||||||
end;
|
end;
|
||||||
AssertEquals('CodeContexts.Count',1,CodeContexts.Count);
|
AssertEquals('CodeContexts.Count',1,CodeContexts.Count);
|
||||||
for i:=0 to CodeContexts.Count-1 do
|
//for i:=0 to CodeContexts.Count-1 do
|
||||||
debugln(['TTestIdentCompletion.Test_FindCodeContext_ProcParams ',i,' ',CodeContexts[i].AsDebugString(true)]);
|
// debugln(['TTestIdentCompletion.Test_FindCodeContext_ProcParams ',i,' ',CodeContexts[i].AsDebugString(true)]);
|
||||||
CheckCodeContext(CodeContexts[0],'p');
|
CheckCodeContext(CodeContexts[0],'p');
|
||||||
finally
|
finally
|
||||||
CodeContexts.Free;
|
CodeContexts.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestIdentCompletion.Test_FindCodeContext_AttributeParams;
|
||||||
|
var
|
||||||
|
SrcMark: TFDMarker;
|
||||||
|
CursorPos: TCodeXYPosition;
|
||||||
|
CodeContexts: TCodeContextInfo;
|
||||||
|
begin
|
||||||
|
StartProgram;
|
||||||
|
Add([
|
||||||
|
'{$modeswitch prefixedattributes}',
|
||||||
|
'type',
|
||||||
|
' BirdAttribute = class',
|
||||||
|
' {#a}constructor Create; overload;',
|
||||||
|
' {#b}constructor Create(i,j: longint); overload;',
|
||||||
|
' end;',
|
||||||
|
' [Bird({#c})]',
|
||||||
|
' TColor = 1..3;',
|
||||||
|
'begin',
|
||||||
|
'end.']);
|
||||||
|
ParseSimpleMarkers(Code);
|
||||||
|
SrcMark:=FindMarker('c','#');
|
||||||
|
AssertNotNull('missing src marker #c',SrcMark);
|
||||||
|
MainTool.CleanPosToCaret(SrcMark.CleanPos,CursorPos);
|
||||||
|
CodeContexts:=nil;
|
||||||
|
try
|
||||||
|
if not CodeToolBoss.FindCodeContext(Code,CursorPos.X,CursorPos.Y,CodeContexts)
|
||||||
|
then begin
|
||||||
|
WriteSource(CursorPos);
|
||||||
|
Fail('CodeToolBoss.FindCodeContext');
|
||||||
|
end;
|
||||||
|
//for i:=0 to CodeContexts.Count-1 do
|
||||||
|
// debugln(['TTestIdentCompletion.Test_FindCodeContext_ProcParams ',i,' ',CodeContexts[i].AsDebugString(true)]);
|
||||||
|
AssertEquals('CodeContexts.Count',3,CodeContexts.Count);
|
||||||
|
CheckCodeContext(CodeContexts[0],'b');
|
||||||
|
CheckCodeContext(CodeContexts[1],'a');
|
||||||
|
// last entry is the default TObject.Create in unit objpas
|
||||||
|
finally
|
||||||
|
CodeContexts.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterTests([TTestIdentCompletion]);
|
RegisterTests([TTestIdentCompletion]);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user