From ce19f7ed356ff9de221146905fd8fcee7c33b3ca Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 4 Apr 2011 10:54:46 +0000 Subject: [PATCH] tests: compile to units/targetcpu-targetos, added codetools test for modified initialization section git-svn-id: trunk@30176 - --- test/codetoolstests/testctrangescan.pas | 36 ++++++++++++++++++++++--- test/runtestsgui.lpi | 12 ++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/test/codetoolstests/testctrangescan.pas b/test/codetoolstests/testctrangescan.pas index d6daf8d37f..0c807d0ba5 100644 --- a/test/codetoolstests/testctrangescan.pas +++ b/test/codetoolstests/testctrangescan.pas @@ -24,6 +24,8 @@ type crsfWithProc1Modified, crsfWithCommentAtEnd, crsfWithInitialization, + crsfWithInitializationStatement1, + crsfWithInitializationStatement2, crsfWithFinalization ); TCTRgSrcFlags = set of TCTRgSrcFlag; @@ -39,6 +41,7 @@ type procedure TestCTScanRangeDescending; procedure TestCTScanRangeProcModified; procedure TestCTScanRangeImplementationToEnd; + procedure TestCTScanRangeInitializationModified; end; implementation @@ -66,8 +69,13 @@ begin +'begin'+LineEnding +' // comment'+LineEnding +'end;'+LineEnding; - if crsfWithInitialization in Flags then + if crsfWithInitialization in Flags then begin Result:=Result+'initialization'+LineEnding; + if crsfWithInitializationStatement1 in Flags then + Result:=Result+'i:=3;'+LineEnding; + if crsfWithInitializationStatement2 in Flags then + Result:=Result+'i:=5;'+LineEnding; + end; if crsfWithFinalization in Flags then Result:=Result+'finalization'+LineEnding; Result:=Result+'end.'; @@ -190,6 +198,8 @@ begin Tool:=CodeToolBoss.GetCodeToolForSource(Code,false,true) as TCodeTool; // scan source + Code.Source:='begin end.'; + Tool.BuildTree(lsrEnd); Code.Source:=GetSource([]); MinRange:=low(TLinkScannerRange); MaxRange:=high(TLinkScannerRange); @@ -237,14 +247,34 @@ begin // scan source Code.Source:=GetSource([crsfWithProc1]); Tool.BuildTree(lsrImplementationStart); - Tool.WriteDebugTreeReport; + //Tool.WriteDebugTreeReport; AssertEquals('step1: implementation found',true,Tool.FindImplementationNode<>nil); Tool.BuildTree(lsrEnd); - Tool.WriteDebugTreeReport; + //Tool.WriteDebugTreeReport; AssertEquals('step2: end. found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil); end; +procedure TTestCodetoolsRangeScan.TestCTScanRangeInitializationModified; +var + Code: TCodeBuffer; + Tool: TCodeTool; +begin + Code:=CodeToolBoss.CreateFile('TestRangeScan.pas'); + Tool:=CodeToolBoss.GetCodeToolForSource(Code,false,true) as TCodeTool; + + // scan source with initialization + Code.Source:=GetSource([crsfWithInitialization,crsfWithInitializationStatement1]); + Tool.BuildTree(lsrEnd); + AssertEquals('step1: end found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil); + + // scan source with a modified initialization + Code.Source:=GetSource([crsfWithInitialization,crsfWithInitializationStatement2]); + Tool.BuildTree(lsrEnd); + AssertEquals('step2: end found',true,Tool.Tree.FindRootNode(ctnEndPoint)<>nil); + //Tool.WriteDebugTreeReport; +end; + initialization AddToCodetoolsTestSuite(TTestCodetoolsRangeScan); diff --git a/test/runtestsgui.lpi b/test/runtestsgui.lpi index 396e0a4c4a..f9165a49ab 100644 --- a/test/runtestsgui.lpi +++ b/test/runtestsgui.lpi @@ -5,7 +5,6 @@ - @@ -23,7 +22,7 @@ - + @@ -104,10 +103,14 @@ - + + + + + @@ -121,6 +124,9 @@ + + +