codetools: added test

This commit is contained in:
mattias 2024-07-18 12:09:27 +02:00
parent 1c61ed510e
commit 3e38d50ffa
2 changed files with 72 additions and 3 deletions

View File

@ -136,6 +136,7 @@ type
procedure TestFindDeclaration_GenericsDelphi_InterfaceAncestor;
procedure TestFindDeclaration_GenericsDelphi_FuncParam;
procedure TestFindDeclaration_GenericsDelphi_PublicProcType;
procedure TestFindDeclaration_GenericsDelphi_MultiGenParams;
procedure TestFindDeclaration_ForIn;
procedure TestFindDeclaration_FileAtCursor;
procedure TestFindDeclaration_CBlocks;
@ -307,7 +308,6 @@ var
NewExprType: TExpressionType;
ListOfPCodeXYPosition: TFPList;
Cache: TFindIdentifierReferenceCache;
CodePos: PCodeXYPosition;
begin
FMainCode:=aCode;
DoParseModule(MainCode,FMainTool);
@ -899,8 +899,7 @@ begin
FindDeclarations(Code);
end;
procedure TTestFindDeclaration.
TestFindDeclaration_GenericsDelphi_PublicProcType;
procedure TTestFindDeclaration.TestFindDeclaration_GenericsDelphi_PublicProcType;
begin
StartProgram;
Add([
@ -924,6 +923,36 @@ begin
FindDeclarations(Code);
end;
procedure TTestFindDeclaration.TestFindDeclaration_GenericsDelphi_MultiGenParams;
begin
StartProgram;
Add([
'{$mode delphi}',
'type',
' TBird = class',
' A: boolean;',
' function Fly: boolean;',
' end;',
' TBird<T> = class',
' B: T;',
' function Fly: T;',
' end;',
'function TBird.Fly: boolean;',
'begin',
'end;',
'function TBird<T>.Fly: T;',
'begin',
'end;',
'var',
' One: TBird;',
' Two: TBird<word>;',
'begin',
' One.Fly;',
' Two.Fly;',
'end.']);
FindDeclarations(Code);
end;
procedure TTestFindDeclaration.TestFindDeclaration_ForIn;
begin
FindDeclarations('moduletests/fdt_for_in.pas');

View File

@ -37,6 +37,7 @@ type
procedure TestMethodJump_SingleMethod;
procedure TestMethodJump_MultiMethodWrongName;
procedure TestMethodJump_DelphiGenericClass;
procedure TestMethodJump_DelphiGenericClass_GenOverload; // todo
procedure TestMethodJump_DelphiGenericMethod;
procedure TestMethodJump_ObjFPCGenericMethod;
procedure TestMethodJump_ParamWithAttribute;
@ -274,6 +275,45 @@ begin
TestJumpToMethod('b',false,'d',true,0);
end;
procedure TTestMethodJumpTool.TestMethodJump_DelphiGenericClass_GenOverload;
begin
exit;
Add([
'unit Test1;',
'{$mode delphi}{$H+}',
'interface',
'type',
' TBird = class',
' procedure {a1}DoIt(s: word);',
' procedure {b1}DoIt;',
' end;',
' TBird<T> = class',
' procedure {c1}DoIt(s: T);',
' procedure {d1}DoIt;',
' end;',
'implementation',
'procedure TBird.{a2}Do2It(s: word);',
'begin',
'end;',
'procedure TBird.DoIt;',
'begin',
'{b2}',
'end;',
'procedure TBird<T>.{c2}Do2It(s: T);',
'begin',
'end;',
'procedure TBird<T>.DoIt;',
'begin',
'{d2}',
'end;',
'end.']);
TestJumpToMethod('a1',false,'a2',false,2);
TestJumpToMethod('b1',false,'b2',true,0);
TestJumpToMethod('c1',false,'c2',false,2);
TestJumpToMethod('d1',false,'d2',true,0);
end;
procedure TTestMethodJumpTool.TestMethodJump_DelphiGenericMethod;
begin
Add([