mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 15:19:40 +02:00
tests: added tests for cfgscripts
git-svn-id: trunk@37388 -
This commit is contained in:
parent
7d0c629373
commit
8d1cb5ba75
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6343,6 +6343,7 @@ test/bugs/testfileproc.pas svneol=native#text/plain
|
||||
test/bugs/testfileutil.pas svneol=native#text/plain
|
||||
test/bugtestcase.pas svneol=native#text/plain
|
||||
test/codetoolstests/testbasiccodetools.pas svneol=native#text/plain
|
||||
test/codetoolstests/testcfgscript.pas svneol=native#text/plain
|
||||
test/codetoolstests/testcompleteblock.pas svneol=native#text/plain
|
||||
test/codetoolstests/testcth2pas.pas svneol=native#text/pascal
|
||||
test/codetoolstests/testctrangescan.pas svneol=native#text/plain
|
||||
|
70
test/codetoolstests/testcfgscript.pas
Normal file
70
test/codetoolstests/testcfgscript.pas
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
Test with:
|
||||
./runtests --format=plain --suite=TTestCodetoolsCfgScript
|
||||
./runtests --format=plain --suite=TestCfgScript
|
||||
}
|
||||
unit TestCfgScript;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$DEFINE VerboseTestCfgScript}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testglobals, FileProcs,
|
||||
CodeToolsCfgScript;
|
||||
|
||||
type
|
||||
|
||||
{ TTestCodetoolsCfgScript }
|
||||
|
||||
TTestCodetoolsCfgScript = class(TTestCase)
|
||||
protected
|
||||
procedure TestResult(Script, ExpectedResult: string);
|
||||
published
|
||||
procedure TestCfgScript;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestCodetoolsCfgScript }
|
||||
|
||||
procedure TTestCodetoolsCfgScript.TestResult(Script, ExpectedResult: string);
|
||||
var
|
||||
Engine: TCTConfigScriptEngine;
|
||||
ScriptResult: String;
|
||||
i: Integer;
|
||||
begin
|
||||
Engine:=TCTConfigScriptEngine.Create;
|
||||
try
|
||||
Engine.MaxErrorCount:=1;
|
||||
if not Engine.Execute(Script) then begin
|
||||
writeln('Script failed to run:');
|
||||
for i:=0 to Engine.ErrorCount-1 do
|
||||
writeln(Engine.GetErrorStr(i));
|
||||
AssertEquals('Syntax error in script "'+Script+'"',true,false);
|
||||
end else begin
|
||||
ScriptResult:=Engine.Variables['Result'];
|
||||
if ScriptResult<>ExpectedResult then
|
||||
Engine.Variables.WriteDebugReport('Variables');
|
||||
AssertEquals(Script,ExpectedResult,ScriptResult);
|
||||
end;
|
||||
finally
|
||||
Engine.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestCodetoolsCfgScript.TestCfgScript;
|
||||
begin
|
||||
TestResult('Result:=2;','2');
|
||||
TestResult('a:=2; b:=a; Result:=b;','2');
|
||||
TestResult('Result:=1+2;','3');
|
||||
//TestResult('Result:=1+2*3;','7');
|
||||
end;
|
||||
|
||||
initialization
|
||||
AddToCodetoolsTestSuite(TTestCodetoolsCfgScript);
|
||||
|
||||
end.
|
||||
|
@ -96,9 +96,9 @@
|
||||
<UnitName Value="TestCTXMLFixFragments"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="codetoolstests\testcth2pas.pas"/>
|
||||
<Filename Value="codetoolstests\testcfgscript.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestCTH2Pas"/>
|
||||
<UnitName Value="TestCfgScript"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="codetoolstests\teststdcodetools.pas"/>
|
||||
|
@ -33,7 +33,7 @@ uses
|
||||
TestLazUtils, TestLazUTF8, TestAvgLvlTree,
|
||||
// codetools
|
||||
TestBasicCodetools, TestCTXMLFixFragments, TestCTRangeScan, TestCTH2Pas,
|
||||
TestCompleteBlock, TestStdCodetools,
|
||||
TestCompleteBlock, TestStdCodetools, TestCfgScript,
|
||||
// lcltests
|
||||
testunicode, testpen, TestPreferredSize
|
||||
{$IFNDEF NoSemiAutomatedTests}
|
||||
|
Loading…
Reference in New Issue
Block a user