1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
{
Test with:
./parsertest --format=plain --suite=TTestParseFPCTestUnits
./parsertest --format=plain --suite=TestParse_ugenconstraints
}
unit parsertbase;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, CodeToolManager, ExprEval, CodeCache, LazFileUtils,
LazLogger, fpcunit, testregistry;
type
{ TTestParseFPCTestUnits }
TTestParseFPCTestUnits = class(TTestCase)
private
published
procedure TestParse_ugenconstraints;
end;
var
BugsTestSuite: TTestSuite;
ParserTestSuite: TTestSuite;
procedure AddToBugsTestSuite(ATest: TTest);
procedure AddToParserTestSuite(ATestClass: TClass);
implementation
procedure AddToBugsTestSuite(ATest: TTest);
begin
BugsTestSuite.AddTest(ATest);
end;
procedure AddToParserTestSuite(ATestClass: TClass);
begin
ParserTestSuite.AddTestSuiteFromClass(ATestClass);
end;
{ TTestParseFPCTestUnits }
procedure TTestParseFPCTestUnits.TestParse_ugenconstraints;
var
FPCDir: String;
Filename: String;
Code: TCodeBuffer;
Tool: TCodeTool;
begin
FPCDir:=TrimFilename(CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'FPCSrcDir']);
if not DirPathExists(FPCDir) then
raise Exception.Create('FPCDIR not found: '+FPCDir);
Filename:=AppendPathDelim(FPCDir)+'tests/test/ugenconstraints.pas';
//debugln(['TTestParseFPCTestUnits.TestParse_ugenconstraints ',Filename]);
Code:=CodeToolBoss.LoadFile(Filename,true,false);
if Code=nil then
raise Exception.Create('unable to load '+Filename);
if not CodeToolBoss.Explore(Code,Tool,true) then begin
debugln(['TTestParseFPCTestUnits.TestParse_ugenconstraints ',CodeToolBoss.ErrorMessage]);
end;
end;
initialization
GetTestRegistry.TestName := 'All tests';
BugsTestSuite := TTestSuite.Create('Bugs');
GetTestRegistry.AddTest(BugsTestSuite);
ParserTestSuite := TTestSuite.Create('Parser');
GetTestRegistry.AddTest(ParserTestSuite);
AddToParserTestSuite(TTestParseFPCTestUnits);
end.
|