mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 14:37:48 +02:00
codetools: tests: added objccategory
git-svn-id: trunk@49660 -
This commit is contained in:
parent
be9ce3be19
commit
2c559c3ecb
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -986,6 +986,7 @@ components/codetools/stdcodetools.pas svneol=native#text/pascal
|
||||
components/codetools/tests/fdt_basic.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_classhelper.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_nestedclasses.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_objccategory.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdtbase.pas svneol=native#text/plain
|
||||
components/codetools/tests/finddeclarationtest.lpi svneol=native#text/plain
|
||||
components/codetools/tests/finddeclarationtest.lpr svneol=native#text/plain
|
||||
|
57
components/codetools/tests/fdt_objccategory.pas
Normal file
57
components/codetools/tests/fdt_objccategory.pas
Normal file
@ -0,0 +1,57 @@
|
||||
unit fdt_objccategory;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$ModeSwitch objectivec1}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
type
|
||||
|
||||
{ ta }
|
||||
|
||||
ta = objcclass(NSObject)
|
||||
end;
|
||||
|
||||
{ ca }
|
||||
|
||||
ca = objccategory(NSObject)
|
||||
procedure categoryAmethod; message 'categoryAmethod';
|
||||
end;
|
||||
|
||||
{ cb }
|
||||
|
||||
cb = objccategory(ta)
|
||||
procedure categoryBmethod; message 'categoryBmethod';
|
||||
end;
|
||||
|
||||
procedure DoIt;
|
||||
|
||||
implementation
|
||||
|
||||
{ ca }
|
||||
|
||||
procedure ca.categoryAmethod;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
{ cb }
|
||||
|
||||
procedure cb.categoryBmethod;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure DoIt;
|
||||
var
|
||||
a: NSObject;
|
||||
begin
|
||||
a:=ta(ta.alloc).init;
|
||||
a.categoryAmethod{declaration:fdt_objccategory.ca.categoryAmethod};
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -4,11 +4,14 @@
|
||||
./finddeclarationtest --format=plain --suite=TestFindDeclaration_Base
|
||||
./finddeclarationtest --format=plain --suite=TestFindDeclaration_NestedClasses
|
||||
./finddeclarationtest --format=plain --suite=TestFindDeclaration_ClassHelper
|
||||
./finddeclarationtest --format=plain --suite=TestFindDeclaration_ObjCCategory
|
||||
}
|
||||
unit fdtbase;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{off $define VerboseFindDeclarationTests}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
@ -27,6 +30,7 @@ type
|
||||
procedure TestFindDeclaration_Base;
|
||||
procedure TestFindDeclaration_NestedClasses;
|
||||
procedure TestFindDeclaration_ClassHelper;
|
||||
procedure TestFindDeclaration_ObjCCategory;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -76,6 +80,9 @@ var
|
||||
Marker: String;
|
||||
begin
|
||||
Filename:=TrimAndExpandFilename(Filename);
|
||||
{$IFDEF VerboseFindDeclarationTests}
|
||||
debugln(['TTestFindDeclaration.FindDeclarations File=',Filename]);
|
||||
{$ENDIF}
|
||||
Code:=CodeToolBoss.LoadFile(Filename,true,false);
|
||||
if Code=nil then
|
||||
raise Exception.Create('unable to load '+Filename);
|
||||
@ -106,11 +113,15 @@ begin
|
||||
if Marker='declaration' then begin
|
||||
ExpectedPath:=copy(Src,PathPos,CommentP-1-PathPos);
|
||||
//debugln(['TTestFindDeclaration.FindDeclarations ExpectedPath=',ExpectedPath]);
|
||||
{ $IFDEF VerboseFindDeclarationTests}
|
||||
debugln(['TTestFindDeclaration.FindDeclarations searching "',Marker,'" at ',Tool.CleanPosToStr(NameStartPos-1),' ExpectedPath=',ExpectedPath]);
|
||||
{ $ENDIF}
|
||||
Tool.CleanPosToCaret(NameStartPos-1,CursorPos);
|
||||
if not CodeToolBoss.FindDeclaration(CursorPos.Code,CursorPos.X,CursorPos.Y,
|
||||
FoundCursorPos.Code,FoundCursorPos.X,FoundCursorPos.Y,FoundTopLine)
|
||||
then begin
|
||||
AssertEquals('find declaration failed at '+Tool.CleanPosToStr(NameStartPos-1)+': '+CodeToolBoss.ErrorMessage,false,true);
|
||||
if ExpectedPath<>'' then
|
||||
AssertEquals('find declaration failed at '+Tool.CleanPosToStr(NameStartPos-1)+': '+CodeToolBoss.ErrorMessage,false,true);
|
||||
continue;
|
||||
end else begin
|
||||
FoundTool:=CodeToolBoss.GetCodeToolForSource(FoundCursorPos.Code,true,true) as TFindDeclarationTool;
|
||||
@ -158,6 +169,11 @@ begin
|
||||
FindDeclarations('fdt_classhelper.pas');
|
||||
end;
|
||||
|
||||
procedure TTestFindDeclaration.TestFindDeclaration_ObjCCategory;
|
||||
begin
|
||||
FindDeclarations('fdt_objccategory.pas');
|
||||
end;
|
||||
|
||||
initialization
|
||||
GetTestRegistry.TestName := 'All tests';
|
||||
BugsTestSuite := TTestSuite.Create('Bugs');
|
||||
|
@ -41,7 +41,7 @@
|
||||
<PackageName Value="fpcunitconsolerunner"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="5">
|
||||
<Units Count="6">
|
||||
<Unit0>
|
||||
<Filename Value="finddeclarationtest.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -49,23 +49,23 @@
|
||||
<Unit1>
|
||||
<Filename Value="fdtbase.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fdtbase"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="fdt_classhelper.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fdt_classhelper"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="fdt_nestedclasses.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fdt_nestedclasses"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="fdt_basic.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fdt_basic"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="fdt_objccategory.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit5>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -22,6 +22,9 @@ program finddeclarationtest;
|
||||
uses
|
||||
Classes, sysutils, consoletestrunner, dom, fpcunit, CodeToolManager,
|
||||
CodeToolsConfig, LazLogger, fdtbase, fdt_classhelper, fdt_nestedclasses,
|
||||
{$IFDEF Darwin}
|
||||
fdt_objccategory,
|
||||
{$ENDIF}
|
||||
fdt_basic;
|
||||
|
||||
const
|
||||
|
Loading…
Reference in New Issue
Block a user