mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 22:59:15 +02:00
codetools: test scan program without name
git-svn-id: trunk@56010 -
This commit is contained in:
parent
b18d4bfc2a
commit
fccd4f7546
@ -29,14 +29,16 @@ const
|
|||||||
ctrsCommentOfProc1 = 'comment of Proc1';
|
ctrsCommentOfProc1 = 'comment of Proc1';
|
||||||
type
|
type
|
||||||
TCTRgSrcFlag = (
|
TCTRgSrcFlag = (
|
||||||
|
crsfProgram,
|
||||||
|
crsfLibrary,
|
||||||
|
crsfNoSrcName,
|
||||||
crsfWithProc1,
|
crsfWithProc1,
|
||||||
crsfWithProc1Modified,
|
crsfWithProc1Modified,
|
||||||
crsfWithCommentAtEnd,
|
crsfWithCommentAtEnd,
|
||||||
crsfWithInitialization,
|
crsfWithInitialization,
|
||||||
crsfWithInitializationStatement1,
|
crsfWithInitializationStatement1,
|
||||||
crsfWithInitializationStatement2,
|
crsfWithInitializationStatement2,
|
||||||
crsfWithFinalization,
|
crsfWithFinalization
|
||||||
crsLibrary
|
|
||||||
);
|
);
|
||||||
TCTRgSrcFlags = set of TCTRgSrcFlag;
|
TCTRgSrcFlags = set of TCTRgSrcFlag;
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ type
|
|||||||
procedure TestCTScanRangeInitializationModified;
|
procedure TestCTScanRangeInitializationModified;
|
||||||
procedure TestCTScanRangeLibraryInitializationModified;
|
procedure TestCTScanRangeLibraryInitializationModified;
|
||||||
procedure TestCTScanRangeScannerAtEnd;
|
procedure TestCTScanRangeScannerAtEnd;
|
||||||
|
procedure TestCTScanRangeProgramNoName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -68,10 +71,18 @@ var
|
|||||||
begin
|
begin
|
||||||
IsUnit:=true;
|
IsUnit:=true;
|
||||||
Result:='unit';
|
Result:='unit';
|
||||||
if crsLibrary in Flags then begin
|
if crsfLibrary in Flags then begin
|
||||||
Result:='library';
|
Result:='library';
|
||||||
IsUnit:=false;
|
IsUnit:=false;
|
||||||
|
end
|
||||||
|
else if crsfProgram in Flags then begin
|
||||||
|
if crsfNoSrcName in Flags then
|
||||||
|
Result:=''
|
||||||
|
else
|
||||||
|
Result:='program';
|
||||||
|
IsUnit:=false;
|
||||||
end;
|
end;
|
||||||
|
if not (crsfNoSrcName in Flags) then
|
||||||
Result+=' TestRangeScan;'+LineEnding;
|
Result+=' TestRangeScan;'+LineEnding;
|
||||||
if IsUnit then
|
if IsUnit then
|
||||||
Result+='interface'+LineEnding;
|
Result+='interface'+LineEnding;
|
||||||
@ -223,7 +234,8 @@ begin
|
|||||||
lsrInit: ;
|
lsrInit: ;
|
||||||
lsrSourceType:
|
lsrSourceType:
|
||||||
AssertEquals('source type scanned',true,RootNode<>nil);
|
AssertEquals('source type scanned',true,RootNode<>nil);
|
||||||
lsrSourceName: ;
|
lsrSourceName:
|
||||||
|
AssertEquals('source name scanned',true,RootNode<>nil);
|
||||||
lsrInterfaceStart:
|
lsrInterfaceStart:
|
||||||
AssertEquals('interface start scanned',true,Tool.FindInterfaceNode<>nil);
|
AssertEquals('interface start scanned',true,Tool.FindInterfaceNode<>nil);
|
||||||
lsrMainUsesSectionStart:
|
lsrMainUsesSectionStart:
|
||||||
@ -350,12 +362,12 @@ begin
|
|||||||
Tool:=CodeToolBoss.GetCodeToolForSource(Code,false,true) as TCodeTool;
|
Tool:=CodeToolBoss.GetCodeToolForSource(Code,false,true) as TCodeTool;
|
||||||
|
|
||||||
// scan source with initialization
|
// scan source with initialization
|
||||||
Code.Source:=GetSource([crsLibrary,crsfWithInitialization,crsfWithInitializationStatement1]);
|
Code.Source:=GetSource([crsfLibrary,crsfWithInitialization,crsfWithInitializationStatement1]);
|
||||||
Tool.BuildTree(lsrEnd);
|
Tool.BuildTree(lsrEnd);
|
||||||
AssertEquals('step1: end found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil);
|
AssertEquals('step1: end found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil);
|
||||||
|
|
||||||
// scan source with a modified initialization
|
// scan source with a modified initialization
|
||||||
Code.Source:=GetSource([crsLibrary,crsfWithInitialization,crsfWithInitializationStatement2]);
|
Code.Source:=GetSource([crsfLibrary,crsfWithInitialization,crsfWithInitializationStatement2]);
|
||||||
Tool.BuildTree(lsrEnd);
|
Tool.BuildTree(lsrEnd);
|
||||||
AssertEquals('step2: end found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil);
|
AssertEquals('step2: end found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil);
|
||||||
|
|
||||||
@ -391,6 +403,52 @@ begin
|
|||||||
AssertEquals('scanner and tool at end',true,Tool.Scanner.ScannedRange=lsrEnd);
|
AssertEquals('scanner and tool at end',true,Tool.Scanner.ScannedRange=lsrEnd);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestCodetoolsRangeScan.TestCTScanRangeProgramNoName;
|
||||||
|
var
|
||||||
|
Code: TCodeBuffer;
|
||||||
|
Tool: TCodeTool;
|
||||||
|
r: TLinkScannerRange;
|
||||||
|
RootNode: TCodeTreeNode;
|
||||||
|
begin
|
||||||
|
Code:=CodeToolBoss.CreateFile('TestRangeScan.pas');
|
||||||
|
Tool:=CodeToolBoss.GetCodeToolForSource(Code,false,true) as TCodeTool;
|
||||||
|
Tool.BuildTree(lsrInit);
|
||||||
|
Code.Source:=GetSource([crsfProgram,crsfNoSrcName]);
|
||||||
|
Tool.BuildTree(lsrImplementationUsesSectionEnd);
|
||||||
|
RootNode:=nil;
|
||||||
|
for r in TLinkScannerRange do begin
|
||||||
|
{$IFDEF VerboseTestCTRangeScan}
|
||||||
|
debugln(['TTestCodetoolsRangeScan.TestCTScanRangeProgramNoName Range=',dbgs(r)]);
|
||||||
|
{$ENDIF}
|
||||||
|
Tool.BuildTree(r);
|
||||||
|
if RootNode<>nil then begin
|
||||||
|
AssertEquals('RootNode must stay for ascending range '+dbgs(r),true,RootNode=Tool.Tree.Root);
|
||||||
|
end;
|
||||||
|
RootNode:=Tool.Tree.Root;
|
||||||
|
//Tool.WriteDebugTreeReport;
|
||||||
|
case r of
|
||||||
|
lsrNone: ;
|
||||||
|
lsrInit: ;
|
||||||
|
lsrSourceType:
|
||||||
|
AssertEquals('source type scanned',true,RootNode<>nil);
|
||||||
|
lsrSourceName:
|
||||||
|
AssertEquals('source name scanned',true,RootNode<>nil);
|
||||||
|
lsrInterfaceStart: ;
|
||||||
|
lsrMainUsesSectionStart:
|
||||||
|
AssertEquals('main uses section start scanned',true,Tool.FindMainUsesNode<>nil);
|
||||||
|
lsrMainUsesSectionEnd:
|
||||||
|
AssertEquals('main uses section end scanned',true,Tool.FindMainUsesNode.FirstChild<>nil);
|
||||||
|
lsrImplementationStart: ;
|
||||||
|
lsrImplementationUsesSectionStart: ;
|
||||||
|
lsrImplementationUsesSectionEnd: ;
|
||||||
|
lsrInitializationStart: ;
|
||||||
|
lsrFinalizationStart: ;
|
||||||
|
lsrEnd:
|
||||||
|
AssertEquals('end. found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterTest(TTestCodetoolsRangeScan);
|
RegisterTest(TTestCodetoolsRangeScan);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user