codetools: added tests unit order and namespaces

git-svn-id: trunk@50269 -
This commit is contained in:
mattias 2015-11-10 11:01:59 +00:00
parent ba310dcf48
commit 40480bf39d
11 changed files with 115 additions and 8 deletions

6
.gitattributes vendored
View File

@ -1026,6 +1026,12 @@ components/codetools/tests/laztests/bug28876.pas svneol=native#text/plain
components/codetools/tests/laztests/bug28877.pas svneol=native#text/plain components/codetools/tests/laztests/bug28877.pas svneol=native#text/plain
components/codetools/tests/laztests/delphi_autodereference1.pas svneol=native#text/plain components/codetools/tests/laztests/delphi_autodereference1.pas svneol=native#text/plain
components/codetools/tests/laztests/tdefaultproperty1.pas svneol=native#text/plain components/codetools/tests/laztests/tdefaultproperty1.pas svneol=native#text/plain
components/codetools/tests/laztests/unit_order_a.pas svneol=native#text/plain
components/codetools/tests/laztests/unit_order_b.pas svneol=native#text/plain
components/codetools/tests/laztests/unit_order_test.pas svneol=native#text/plain
components/codetools/tests/laztests/unitdots.dot.pas svneol=native#text/plain
components/codetools/tests/laztests/unitdots.main.pas svneol=native#text/plain
components/codetools/tests/laztests/unitdots.pas svneol=native#text/plain
components/codetools/tests/parsertbase.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.lpi svneol=native#text/plain
components/codetools/tests/parsertest.lpr svneol=native#text/plain components/codetools/tests/parsertest.lpr svneol=native#text/plain

View File

@ -232,12 +232,16 @@ var
Info: TSearchRec; Info: TSearchRec;
aFilename, Param, aFileMask: String; aFilename, Param, aFileMask: String;
i: Integer; i: Integer;
Verbose: Boolean;
begin begin
aFileMask:='t*.p*'; aFileMask:='t*.p*';
Verbose:=false;
for i:=1 to ParamCount do begin for i:=1 to ParamCount do begin
Param:=ParamStr(i); Param:=ParamStr(i);
if LeftStr(Param,length(fmparam))=fmparam then if LeftStr(Param,length(fmparam))=fmparam then
aFileMask:=copy(Param,length(fmparam)+1,100); aFileMask:=copy(Param,length(fmparam)+1,100);
if Param='-v' then
Verbose:=true;
end; end;
Directory:=AppendPathDelim(Directory); Directory:=AppendPathDelim(Directory);
@ -246,6 +250,8 @@ begin
if faDirectory and Info.Attr>0 then continue; if faDirectory and Info.Attr>0 then continue;
aFilename:=Info.Name; aFilename:=Info.Name;
if not FilenameIsPascalUnit(aFilename) then continue; if not FilenameIsPascalUnit(aFilename) then continue;
if Verbose then
debugln(['TTestFindDeclaration.TestFiles File="',aFilename,'"']);
FindDeclarations(Directory+aFilename); FindDeclarations(Directory+aFilename);
until FindNextUTF8(Info)<>0; until FindNextUTF8(Info)<>0;
end; end;

View File

@ -10,16 +10,16 @@ procedure t;
implementation implementation
uses uses
tudots{ todo declaration:tudots}, tudots.dot.next{ todo declaration:tudots.dot.next}; tudots{declaration:tudots}, tudots.dot.next{ todo declaration:tudots.dot.next};
// test that type is resolved // test that type is resolved
var var
test1: tudots.dot.next.ttest{ todo declaration:tudots.dot.next.ttest}; test1: tudots.dot.next.ttest{declaration:tudots.dot.next.ttest};
procedure t; procedure t;
begin begin
// test that we resolved the next identifier to the local variable test // test that we resolve the next identifier to the local variable test
tudots.dot.test{ todo declaration:tudots.dot.test} := 'c'; tudots.dot.test{declaration:tudots.dot.test} := 'c';
end; end;
end. end.

View File

@ -5,11 +5,11 @@ program tudots.dot.prog;
{$mode delphi} {$mode delphi}
uses uses
tudots{ todo declaration:tudots}; tudots{declaration:tudots};
begin begin
// this must fail because we have a namespace tudots.dot and it has no unit test // this must fail because we have a namespace tudots.dot and it has no unit test
tudots.dot.test{ todo } := 1; tudots.dot.test{ todo declaration:tudots.dot.test} := 1;
end. end.

View File

@ -5,12 +5,12 @@ interface
// this must fail // this must fail
var var
test: tudots.dot.next.ttest{ todo }; test: tudots.dot.next.ttest{declaration:-};
implementation implementation
uses uses
tudots.dot.next{ todo declaration:tudots.dot.next}; tudots.dot.next{declaration:tudots.dot.next};
end. end.

View File

@ -0,0 +1,14 @@
unit unit_order_a;
{$mode objfpc}{$H+}
interface
var
unit_order_b: char;
implementation
end.

View File

@ -0,0 +1,14 @@
unit unit_order_b;
{$mode objfpc}{$H+}
interface
var
unit_order_a: integer;
implementation
end.

View File

@ -0,0 +1,16 @@
unit unit_order_test;
{$mode objfpc}{$H+}
interface
uses
unit_order_a, unit_order_b;
implementation
begin
unit_order_b.unit_order_a{declaration:unit_order_b.unit_order_a}:=3;
unit_order_a.unit_order_b{declaration:unit_order_a.unit_order_b}:='3';
end.

View File

@ -0,0 +1,14 @@
unit unitdots.dot;
{$mode objfpc}{$H+}
interface
var
test: integer;
foo: integer;
implementation
end.

View File

@ -0,0 +1,19 @@
unit unitdots.main;
{$mode objfpc}{$H+}
interface
uses
unitdots.dot, unitdots; // unit names (with or without namespaces) win over interface identifiers
// even though the 'unitdots.dot' is left of 'unitdots'
implementation
begin
unitdots.dot.test{declaration:unitdots.dot.test}:=3;
unitdots.dot.foo{declaration:unitdots.dot.foo}:=4;
//unitdots.dot.bar:='5'; fail!
unitdots.my{declaration:unitdots.my}:=false;
end.

View File

@ -0,0 +1,18 @@
unit unitdots;
{$mode objfpc}{$H+}
interface
type
dots = record
test: char;
bar: char;
end;
var
my: boolean;
implementation
end.