From 1125a0b9308f243f77cea17de604defc0e9ff12c Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 16 Oct 2015 08:09:57 +0000 Subject: [PATCH] codetools: test for default property git-svn-id: trunk@50079 - --- .gitattributes | 1 + components/codetools/tests/fdtbase.pas | 53 ++++++++++++------- .../tests/laztests/tdefaultproperty1.pas | 36 +++++++++++++ 3 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 components/codetools/tests/laztests/tdefaultproperty1.pas diff --git a/.gitattributes b/.gitattributes index ccc0b884fd..8a25e73da9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1011,6 +1011,7 @@ components/codetools/tests/fpctests/tchlp53.pp svneol=native#text/plain components/codetools/tests/fpctests/tchlp6.pp svneol=native#text/plain components/codetools/tests/fpctests/tchlp7.pp svneol=native#text/plain components/codetools/tests/laztests/README.txt svneol=native#text/plain +components/codetools/tests/laztests/tdefaultproperty1.pas svneol=native#text/plain components/codetools/tests/parsertbase.pas svneol=native#text/plain components/codetools/tests/parsertest.lpi svneol=native#text/plain components/codetools/tests/parsertest.lpr svneol=native#text/plain diff --git a/components/codetools/tests/fdtbase.pas b/components/codetools/tests/fdtbase.pas index eeb83f3b6f..1dddf3f3ab 100644 --- a/components/codetools/tests/fdtbase.pas +++ b/components/codetools/tests/fdtbase.pas @@ -39,6 +39,7 @@ type TTestFindDeclaration = class(TTestCase) private procedure FindDeclarations(Filename: string); + procedure TestFiles(Directory: string); published procedure TestFindDeclaration_Basic; procedure TestFindDeclaration_With; @@ -48,6 +49,7 @@ type procedure TestFindDeclaration_ObjCClass; procedure TestFindDeclaration_ObjCCategory; procedure TestFindDeclaration_FPCTests; + procedure TestFindDeclaration_LazTests; end; var @@ -236,6 +238,32 @@ begin end; end; +procedure TTestFindDeclaration.TestFiles(Directory: string); +const + fmparam = '--filemask='; +var + Info: TSearchRec; + aFilename, Param, aFileMask: String; + i: Integer; +begin + aFileMask:='t*.p*'; + for i:=1 to ParamCount do begin + Param:=ParamStr(i); + if LeftStr(Param,length(fmparam))=fmparam then + aFileMask:=copy(Param,length(fmparam)+1,100); + end; + Directory:=AppendPathDelim(Directory); + + if FindFirstUTF8(Directory+aFileMask,faAnyFile,Info)=0 then begin + repeat + if faDirectory and Info.Attr>0 then continue; + aFilename:=Info.Name; + if not FilenameIsPascalUnit(aFilename) then continue; + FindDeclarations(Directory+aFilename); + until FindNextUTF8(Info)<>0; + end; +end; + procedure TTestFindDeclaration.TestFindDeclaration_Basic; begin FindDeclarations('fdt_basic.pas'); @@ -272,28 +300,13 @@ begin end; procedure TTestFindDeclaration.TestFindDeclaration_FPCTests; -const - fmparam = '--filemask='; -var - Info: TSearchRec; - aFilename, Param, aFileMask: String; - i: Integer; begin - aFileMask:='t*.p*'; - for i:=1 to ParamCount do begin - Param:=ParamStr(i); - if LeftStr(Param,length(fmparam))=fmparam then - aFileMask:=copy(Param,length(fmparam)+1,100); - end; + TestFiles('fpctests'); +end; - if FindFirstUTF8('fpctests'+PathDelim+aFileMask,faAnyFile,Info)=0 then begin - repeat - if faDirectory and Info.Attr>0 then continue; - aFilename:=Info.Name; - if not FilenameIsPascalUnit(aFilename) then continue; - FindDeclarations('fpctests'+PathDelim+aFilename); - until FindNextUTF8(Info)<>0; - end; +procedure TTestFindDeclaration.TestFindDeclaration_LazTests; +begin + TestFiles('laztests'); end; initialization diff --git a/components/codetools/tests/laztests/tdefaultproperty1.pas b/components/codetools/tests/laztests/tdefaultproperty1.pas new file mode 100644 index 0000000000..3eb3fddfa8 --- /dev/null +++ b/components/codetools/tests/laztests/tdefaultproperty1.pas @@ -0,0 +1,36 @@ +unit tdefaultproperty1; + +{$mode objfpc}{$H+} + +interface + +type + TNamedObj = class + public + Name: string; + end; + + + { TBaseObject } + + TBaseObject = class + private + function GetObject(Index: Integer): TNamedObj; + public + property Objects[Index: Integer]: TNamedObj read GetObject; default; + end; + +implementation + +{ TBaseObject } + +function TBaseObject.GetObject(Index: Integer): TNamedObj; +var + I: Integer; +begin + Self.Objects{declaration:tdefaultproperty1.TBaseObject.Objects}[I].Name{declaration:tdefaultproperty1.TNamedObj.Name}:=''; + Self[I].Name{declaration:tdefaultproperty1.TNamedObj.Name}:=''; +end; + +end. +