* Initial support for inline comment documentation

git-svn-id: trunk@29615 -
This commit is contained in:
michael 2015-02-03 21:05:05 +00:00
parent 97a6c92ea8
commit c754846815
8 changed files with 713 additions and 406 deletions

View File

@ -105,6 +105,7 @@ type
TPasElement = class(TPasElementBase)
private
FData: TObject;
FDocComment: String;
FRefCount: LongWord;
FName: string;
FParent: TPasElement;
@ -133,6 +134,7 @@ type
Property Hints : TPasMemberHints Read FHints Write FHints;
Property CustomData : TObject Read FData Write FData;
Property HintMessage : String Read FHintMessage Write FHintMessage;
Property DocComment : String Read FDocComment Write FDocComment;
end;
TPasExprKind = (pekIdent, pekNumber, pekString, pekSet, pekNil, pekBoolConst, pekRange,
@ -1306,7 +1308,7 @@ end;
function TPasElement.ElementTypeName: string; begin Result := SPasTreeElement end;
function TPasElement.HintsString: String;
Function TPasElement.HintsString: String;
Var
H : TPasmemberHint;
@ -1567,7 +1569,7 @@ begin
end;
end;
function TPasElement.GetDeclaration (full : boolean): string;
function TPasElement.GetDeclaration(full: Boolean): string;
begin
if Full then

View File

@ -68,11 +68,14 @@ type
TPasParserLogHandler = Procedure (Sender : TObject; Const Msg : String) of object;
TPParserLogEvent = (pleInterface,pleImplementation);
TPParserLogEvents = set of TPParserLogEvent;
TPasParser = Class;
{ TPasTreeContainer }
TPasTreeContainer = class
private
FCurrentParser: TPasParser;
FNeedComments: Boolean;
FOnLog: TPasParserLogHandler;
FPParserLogEvents: TPParserLogEvents;
FScannerLogEvents: TPScannerLogEvents;
@ -97,6 +100,8 @@ type
Property ScannerLogEvents : TPScannerLogEvents Read FScannerLogEvents Write FScannerLogEvents;
Property ParserLogEvents : TPParserLogEvents Read FPParserLogEvents Write FPParserLogEvents;
Property OnLog : TPasParserLogHandler Read FOnLog Write FOnLog;
Property CurrentParser : TPasParser Read FCurrentParser;
Property NeedComments : Boolean Read FNeedComments Write FNeedComments;
end;
EParserError = class(Exception)
@ -131,9 +136,12 @@ type
FEngine: TPasTreeContainer;
FCurToken: TToken;
FCurTokenString: String;
FCurComments : TStrings;
FSavedComments : String;
// UngetToken support:
FTokenBuffer: array[0..1] of TToken;
FTokenStringBuffer: array[0..1] of String;
FCommentsBuffer: array[0..1] of TStrings;
FTokenBufferIndex: Integer; // current index in FTokenBuffer
FTokenBufferSize: Integer; // maximum valid index in FTokenBuffer
FDumpIndent : String;
@ -146,6 +154,8 @@ type
procedure ParseClassLocalTypes(AType: TPasClassType; AVisibility: TPasMemberVisibility);
procedure ParseVarList(Parent: TPasElement; VarList: TFPList; AVisibility: TPasMemberVisibility; Full: Boolean);
protected
Function SaveComments : String;
Function SaveComments(Const AValue : String) : String;
function LogEvent(E : TPParserLogEvent) : Boolean; inline;
Procedure DoLog(Const Msg : String; SkipSourceInfo : Boolean = False);overload;
Procedure DoLog(Const Fmt : String; Args : Array of const;SkipSourceInfo : Boolean = False);overload;
@ -182,9 +192,12 @@ type
function CheckIfOverloaded(AParent: TPasElement; const AName: String): TPasElement;
public
constructor Create(AScanner: TPascalScanner; AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer);
Destructor Destroy; override;
// General parsing routines
function CurTokenName: String;
function CurTokenText: String;
Function CurComments : TStrings;
Function SavedComments : String;
procedure NextToken; // read next non whitespace, non space
procedure UngetToken;
procedure CheckToken(tk: TToken);
@ -539,6 +552,23 @@ begin
FScanner := AScanner;
FFileResolver := AFileResolver;
FEngine := AEngine;
FCommentsBuffer[0]:=TStringList.Create;
FCommentsBuffer[1]:=TStringList.Create;
if Assigned(FEngine) then
begin
FEngine.FCurrentParser:=Self;
If FEngine.NeedComments then
FScanner.SkipComments:=Not FEngine.NeedComments;
end;
end;
Destructor TPasParser.Destroy;
begin
FreeAndNil(FCommentsBuffer[0]);
FreeAndNil(FCommentsBuffer[1]);
if Assigned(FEngine) then
FEngine.FCurrentParser:=Nil;
inherited Destroy;
end;
function TPasParser.CurTokenName: String;
@ -559,13 +589,27 @@ begin
end;
end;
Function TPasParser.CurComments: TStrings;
begin
Result:=FCurComments;
end;
Function TPasParser.SavedComments: String;
begin
Result:=FSavedComments;
end;
procedure TPasParser.NextToken;
Var
T : TStrings;
begin
if FTokenBufferIndex < FTokenBufferSize then
begin
// Get token from buffer
FCurToken := FTokenBuffer[FTokenBufferIndex];
FCurTokenString := FTokenStringBuffer[FTokenBufferIndex];
FCurComments:=FCommentsBuffer[FTokenBufferIndex];
Inc(FTokenBufferIndex);
//writeln('TPasParser.NextToken From Buf ',CurTokenText,' id=',FTokenBufferIndex);
end else
@ -573,16 +617,22 @@ begin
{ We have to fetch a new token. But first check, wether there is space left
in the token buffer.}
if FTokenBufferSize = 2 then
begin
begin
FTokenBuffer[0] := FTokenBuffer[1];
FTokenStringBuffer[0] := FTokenStringBuffer[1];
T:=FCommentsBuffer[0];
FCommentsBuffer[0]:=FCommentsBuffer[1];
FCommentsBuffer[1]:=T;
Dec(FTokenBufferSize);
Dec(FTokenBufferIndex);
end;
end;
// Fetch new token
try
FCommentsBuffer[FTokenBufferSize].Clear;
repeat
FCurToken := Scanner.FetchToken;
if FCurToken=tkComment then
FCommentsBuffer[FTokenBufferSize].Add(Scanner.CurTokenString);
until not (FCurToken in WhitespaceTokensToIgnore);
except
on e: EScannerError do
@ -592,9 +642,10 @@ begin
FCurTokenString := Scanner.CurTokenString;
FTokenBuffer[FTokenBufferSize] := FCurToken;
FTokenStringBuffer[FTokenBufferSize] := FCurTokenString;
FCurComments:=FCommentsBuffer[FTokenBufferSize];
Inc(FTokenBufferSize);
Inc(FTokenBufferIndex);
//writeln('TPasParser.NextToken New ',CurTokenText,' id=',FTokenBufferIndex);
// writeln('TPasParser.NextToken New ',CurTokenText,' id=',FTokenBufferIndex,' comments = ',FCurComments.text);
end;
end;
@ -609,9 +660,11 @@ begin
begin
FCurToken := FTokenBuffer[FTokenBufferIndex-1];
FCurTokenString := FTokenStringBuffer[FTokenBufferIndex-1];
FCurComments:=FCommentsBuffer[FTokenBufferIndex-1];
end else begin
FCurToken := tkWhitespace;
FCurTokenString := '';
FCurComments.Clear;
end;
//writeln('TPasParser.UngetToken ',CurTokenText,' id=',FTokenBufferIndex);
end;
@ -636,7 +689,7 @@ begin
Result := CurTokenString;
end;
function TPasParser.CurTokenIsIdentifier(Const S: String): Boolean;
Function TPasParser.CurTokenIsIdentifier(Const S: String): Boolean;
begin
Result:=(Curtoken=tkidentifier) and (CompareText(S,CurtokenText)=0);
end;
@ -658,13 +711,14 @@ begin
Result:=IsCurTokenHint(dummy);
end;
function TPasParser.TokenIsCallingConvention(S: String;
out CC: TCallingConvention): Boolean;
Function TPasParser.TokenIsCallingConvention(S: String; out
CC: TCallingConvention): Boolean;
begin
Result:=IsCallingConvention(S,CC);
end;
function TPasParser.TokenIsProcedureModifier(Parent : TPasElement; S: String; out Pm: TProcedureModifier): Boolean;
Function TPasParser.TokenIsProcedureModifier(Parent: TPasElement; S: String;
Out Pm: TProcedureModifier): Boolean;
begin
Result:=IsModifier(S,PM);
if result and (pm in [pmPublic,pmForward]) then
@ -707,7 +761,7 @@ begin
ExpectToken(tkSemiColon);
end;
Function TPasParser.CheckPackMode : TPackMode;
function TPasParser.CheckPackMode: TPackMode;
begin
NextToken;
@ -750,7 +804,8 @@ begin
AName:=SimpleTypeCaseNames[I];
end;
function TPasParser.ParseStringType(Parent : TPasElement; Const TypeName : String) : TPasAliasType;
function TPasParser.ParseStringType(Parent: TPasElement; const TypeName: String
): TPasAliasType;
Var
S : String;
@ -878,17 +933,20 @@ begin
end;
end;
function TPasParser.ParseEnumType(Parent : TPasElement; Const TypeName : String) : TPasEnumType;
function TPasParser.ParseEnumType(Parent: TPasElement; const TypeName: String
): TPasEnumType;
Var
EnumValue: TPasEnumValue;
begin
Writeln('Current comments : ',SavedComments);
Result := TPasEnumType(CreateElement(TPasEnumType, TypeName, Parent));
try
while True do
begin
NextToken;
SaveComments;
EnumValue := TPasEnumValue(CreateElement(TPasEnumValue, CurTokenString, Result));
Result.Values.Add(EnumValue);
NextToken;
@ -913,7 +971,8 @@ begin
end;
end;
function TPasParser.ParseSetType(Parent: TPasElement; Const TypeName : String): TPasSetType;
function TPasParser.ParseSetType(Parent: TPasElement; const TypeName: String
): TPasSetType;
begin
Result := TPasSetType(CreateElement(TPasSetType, TypeName, Parent));
@ -1558,7 +1617,8 @@ begin
end;
end;
Function TPasParser.CheckOverloadList(AList : TFPList; AName : String; Out OldMember : TPasElement) : TPasOverloadedProc;
function TPasParser.CheckOverloadList(AList: TFPList; AName: String; out
OldMember: TPasElement): TPasOverloadedProc;
Var
I : Integer;
@ -1578,6 +1638,8 @@ begin
Result:=TPasOverloadedProc.Create(AName, OldMember.Parent);
Result.Visibility:=OldMember.Visibility;
Result.Overloads.Add(OldMember);
Result.SourceFilename:=OldMember.SourceFilename;
Result.SourceLinenumber:=OldMember.SourceLinenumber;
AList[i] := Result;
end;
end;
@ -1638,6 +1700,7 @@ procedure TPasParser.ParseMain(var Module: TPasModule);
begin
Module:=nil;
NextToken;
SaveComments;
case CurToken of
tkUnit:
ParseUnit(Module);
@ -1836,7 +1899,8 @@ begin
UngetToken;
end;
Function TPasParser.GetProcTypeFromToken(tk : TToken; IsClass : Boolean = False) : TProcType;
function TPasParser.GetProcTypeFromToken(tk: TToken; IsClass: Boolean
): TProcType;
begin
Case tk of
@ -1942,12 +2006,14 @@ begin
CurBlock := declProperty;
tkProcedure, tkFunction, tkConstructor, tkDestructor,tkOperator:
begin
SaveComments;
pt:=GetProcTypeFromToken(CurToken);
AddProcOrFunction(Declarations, ParseProcedureOrFunctionDecl(Declarations, pt));
CurBlock := declNone;
end;
tkClass:
begin
SaveComments;
NextToken;
If CurToken in [tkprocedure,tkFunction,tkConstructor, tkDestructor] then
begin
@ -1960,6 +2026,7 @@ begin
end;
tkIdentifier:
begin
SaveComments;
case CurBlock of
declConst:
begin
@ -2153,6 +2220,7 @@ end;
// Starts after the variable name
function TPasParser.ParseConstDecl(Parent: TPasElement): TPasConst;
begin
SaveComments;
Result := TPasConst(CreateElement(TPasConst, CurTokenString, Parent));
try
NextToken;
@ -2174,6 +2242,7 @@ end;
// Starts after the variable name
function TPasParser.ParseResourcestringDecl(Parent: TPasElement): TPasResString;
begin
SaveComments;
Result := TPasResString(CreateElement(TPasResString, CurTokenString, Parent));
try
ExpectToken(tkEqual);
@ -2205,7 +2274,8 @@ begin
end;
// Starts after the type name
Function TPasParser.ParseRangeType(AParent : TPasElement; Const TypeName : String; Full : Boolean = True) : TPasRangeType;
function TPasParser.ParseRangeType(AParent: TPasElement;
Const TypeName: String; Full: Boolean): TPasRangeType;
Var
PE : TPasExpr;
@ -2259,7 +2329,8 @@ begin
until (CurToken=tkSemicolon);
end;
Function TPasParser.ParseSpecializeType(Parent : TPasElement; Const TypeName : String) : TPasClassType;
function TPasParser.ParseSpecializeType(Parent: TPasElement;
Const TypeName: String): TPasClassType;
begin
Result := TPasClassType(Engine.CreateElement(TPasClassType, TypeName, Parent, Scanner.CurFilename, Scanner.CurRow));
@ -2274,7 +2345,8 @@ begin
end;
end;
Function TPasParser.ParseProcedureType(Parent : TPasElement; Const TypeName : String; Const PT : TProcType) : TPasProcedureType;
function TPasParser.ParseProcedureType(Parent: TPasElement;
const TypeName: String; const PT: TProcType): TPasProcedureType;
begin
if PT in [ptFunction,ptClassFunction] then
@ -2299,7 +2371,8 @@ begin
Result:=ParseType(Parent,TypeName,True);
end;
Function TPasParser.GetVariableValueAndLocation(Parent : TPasElement; out Value : TPasExpr; Out Location : String) : Boolean;
function TPasParser.GetVariableValueAndLocation(Parent: TPasElement; Out
Value: TPasExpr; Out Location: String): Boolean;
begin
Value:=Nil;
@ -2329,7 +2402,8 @@ begin
UngetToken;
end;
Function TPasParser.GetVariableModifiers(Out Varmods : TVariableModifiers; Out Libname,ExportName : string) : string;
function TPasParser.GetVariableModifiers(Out VarMods: TVariableModifiers; Out
Libname, ExportName: string): string;
Var
S : String;
@ -2399,11 +2473,12 @@ var
VarEl: TPasVariable;
H : TPasMemberHints;
varmods: TVariableModifiers;
Mods,Loc,alibname,aexpname : string;
D,Mods,Loc,alibname,aexpname : string;
begin
VarNames := TStringList.Create;
try
D:=SaveComments; // This means we support only one comment per 'list'.
Repeat
VarNames.Add(CurTokenString);
NextToken;
@ -2425,6 +2500,7 @@ begin
Mods:=GetVariableModifiers(varmods,alibname,aexpname)
else
NextToken;
SaveComments(D);
for i := 0 to VarNames.Count - 1 do
begin
VarEl:=TPasVariable(CreateElement(TPasVariable,VarNames[i],Parent,AVisibility));
@ -2450,12 +2526,25 @@ begin
end;
end;
Function TPasParser.SaveComments: String;
begin
if Engine.NeedComments then
FSavedComments:=CurComments.Text; // Expensive, so don't do unless needed.
Result:=FSavedComments;
end;
Function TPasParser.SaveComments(Const AValue: String): String;
begin
FSavedComments:=AValue;
Result:=FSavedComments;
end;
function TPasParser.LogEvent(E: TPParserLogEvent): Boolean;
begin
Result:=E in FLogEvents;
end;
procedure TPasParser.DoLog(const Msg: String; SkipSourceInfo: Boolean);
Procedure TPasParser.DoLog(Const Msg: String; SkipSourceInfo: Boolean);
begin
If Assigned(FOnLog) then
if SkipSourceInfo or not assigned(scanner) then
@ -2464,7 +2553,7 @@ begin
FOnLog(Self,Format('%s(%d) : %s',[Scanner.CurFilename,SCanner.CurRow,Msg]));
end;
procedure TPasParser.DoLog(const Fmt: String; Args: array of const;
Procedure TPasParser.DoLog(Const Fmt: String; Args: Array of const;
SkipSourceInfo: Boolean);
begin
DoLog(Format(Fmt,Args),SkipSourceInfo);
@ -2595,7 +2684,8 @@ begin
end;
Function TPasParser.CheckProcedureArgs(Parent : TPasElement; Args : TFPList; Mandatory : Boolean) : boolean;
function TPasParser.CheckProcedureArgs(Parent: TPasElement; Args: TFPList;
Mandatory: Boolean): boolean;
begin
NextToken;
@ -3500,7 +3590,7 @@ begin
end;
// Starts after the "procedure" or "function" token
Function TPasParser.GetProcedureClass(ProcType : TProcType) : TPTreeElement;
function TPasParser.GetProcedureClass(ProcType: TProcType): TPTreeElement;
begin
Case ProcType of
@ -3567,7 +3657,8 @@ begin
end;
// Current token is the first token after tkOf
Procedure TPasParser.ParseRecordVariantParts(ARec : TPasRecordType; AEndToken: TToken);
procedure TPasParser.ParseRecordVariantParts(ARec: TPasRecordType;
AEndToken: TToken);
Var
M : TPasRecordType;
@ -3613,7 +3704,8 @@ begin
end;
// Starts on first token after Record or (. Ends on AEndToken
Procedure TPasParser.ParseRecordFieldList(ARec : TPasRecordType; AEndToken : TToken; AllowMethods : Boolean);
procedure TPasParser.ParseRecordFieldList(ARec: TPasRecordType;
AEndToken: TToken; AllowMethods: Boolean);
Var
VN : String;
@ -3626,6 +3718,7 @@ begin
v:=visPublic;
while CurToken<>AEndToken do
begin
SaveComments;
Case CurToken of
tkProperty:
begin
@ -3722,7 +3815,8 @@ begin
end;
end;
Function TPasParser.CheckVisibility(S : String; Var AVisibility :TPasMemberVisibility) : Boolean;
function TPasParser.CheckVisibility(S: String;
var AVisibility: TPasMemberVisibility): Boolean;
Var
B : Boolean;
@ -3764,7 +3858,8 @@ begin
AType.Members.Add(Proc);
end;
procedure TPasParser.ParseClassFields(AType: TPasClassType; Const AVisibility : TPasMemberVisibility; IsClassField : Boolean);
procedure TPasParser.ParseClassFields(AType: TPasClassType;
const AVisibility: TPasMemberVisibility; IsClassField: Boolean);
Var
VarList: TFPList;
@ -3839,11 +3934,13 @@ begin
tkType:
begin
ExpectToken(tkIdentifier);
SaveComments;
ParseClassLocalTypes(AType,CurVisibility);
end;
tkConst:
begin
ExpectToken(tkIdentifier);
SaveComments;
ParseClassLocalConsts(AType,CurVisibility);
end;
tkVar,
@ -3853,17 +3950,20 @@ begin
ParseExc(SParserNoFieldsAllowed);
if CurToken=tkVar then
ExpectToken(tkIdentifier);
SaveComments;
if Not CheckVisibility(CurtokenString,CurVisibility) then
ParseClassFields(AType,CurVisibility,false);
end;
tkProcedure,tkFunction,tkConstructor,tkDestructor:
begin
SaveComments;
if (Curtoken in [tkConstructor,tkDestructor]) and (AType.ObjKind in [okInterface,okRecordHelper]) then
ParseExc(SParserNoConstructorAllowed);
ProcessMethod(AType,False,CurVisibility);
end;
tkclass:
begin
SaveComments;
NextToken;
if CurToken in [tkConstructor,tkDestructor,tkprocedure,tkFunction] then
ProcessMethod(AType,True,CurVisibility)
@ -3882,6 +3982,7 @@ begin
end;
tkProperty:
begin
SaveComments;
ExpectIdentifier;
AType.Members.Add(ParseProperty(AType,CurtokenString,CurVisibility));
end;
@ -3948,7 +4049,9 @@ begin
end;
end;
function TPasParser.ParseClassDecl(Parent: TPasElement; const AClassName: String; AObjKind: TPasObjKind; PackMode : TPackMode= pmNone): TPasType;
Function TPasParser.ParseClassDecl(Parent: TPasElement;
const AClassName: String; AObjKind: TPasObjKind; PackMode: TPackMode
): TPasType;
Var
SourcefileName : string;

View File

@ -77,6 +77,7 @@ Type
Procedure HaveHint(AHint : TPasMemberHint; AHints : TPasMemberHints);
Property Resolver : TStreamResolver Read FResolver;
Property Scanner : TPascalScanner Read FScanner;
Property Engine : TTestEngine read FEngine;
Property Parser : TTestPasParser read FParser ;
Property Source : TStrings Read FSource;
Property Module : TPasModule Read FModule;
@ -108,6 +109,11 @@ begin
Result.Visibility := AVisibility;
Result.SourceFilename := ASourceFilename;
Result.SourceLinenumber := ASourceLinenumber;
if NeedComments and Assigned(CurrentParser) then
begin
// Writeln('Saving comment : ',CurrentParser.SavedComments);
Result.DocComment:=CurrentParser.SavedComments;
end;
If not Assigned(FList) then
FList:=TFPList.Create;
FList.Add(Result);

View File

@ -60,12 +60,14 @@ type
Property Const2 : TPasConst Index 1 Read GetC;
published
procedure TestEmpty;
procedure TestEmptyComment;
procedure TestEmptyDeprecated;
procedure TestEmptyEnd;
procedure TestEmptyEndNoParent;
Procedure TestOneInterface;
Procedure TestTwoInterfaces;
Procedure TestOneField;
Procedure TestOneFieldComment;
Procedure TestOneVarField;
Procedure TestOneClassField;
Procedure TestOneFieldVisibility;
@ -83,7 +85,9 @@ type
procedure TestHintFieldLibraryError;
procedure TestHintFieldUninmplemented;
Procedure TestMethodSimple;
Procedure TestMethodSimpleComment;
Procedure TestClassMethodSimple;
Procedure TestClassMethodSimpleComment;
Procedure TestConstructor;
Procedure TestClassConstructor;
Procedure TestDestructor;
@ -108,6 +112,7 @@ type
Procedure Test2Methods;
Procedure Test2MethodsDifferentVisibility;
Procedure TestPropertyRedeclare;
Procedure TestPropertyRedeclareComment;
Procedure TestPropertyRedeclareDefault;
Procedure TestPropertyReadOnly;
Procedure TestPropertyReadWrite;
@ -306,11 +311,17 @@ Procedure TTestClassType.ParseClass;
begin
EndClass;
Add('Type');
if AddComment then
begin
Add('// A comment');
engine.NeedComments:=True;
end;
Add(' '+TrimRight(FDecl.Text)+';');
ParseDeclarations;
AssertEquals('One class type definition',1,Declarations.Classes.Count);
AssertEquals('First declaration is type definition.',TPasClassType,TObject(Declarations.Classes[0]).ClassType);
FClass:=TObject(Declarations.Classes[0]) as TPasClassType;
TheType:=FClass; // So assertcomment can get to it
if (FParent<>'') then
begin
AssertNotNull('Have parent class',TheClass.AncestorType);
@ -323,6 +334,7 @@ begin
AssertNull('No helperfortype if not helper',TheClass.HelperForType);
if TheClass.Members.Count>0 then
FMember1:=TObject(TheClass.Members[0]) as TPaselement;
end;
procedure TTestClassType.SetUp;
@ -385,6 +397,13 @@ begin
AssertEquals('No members',0,TheClass.Members.Count);
end;
procedure TTestClassType.TestEmptyComment;
begin
AddComment:=True;
TestEmpty;
AssertComment;
end;
procedure TTestClassType.TestEmptyDeprecated;
begin
EndClass('end deprecated');
@ -438,6 +457,16 @@ begin
AssertVisibility;
end;
Procedure TTestClassType.TestOneFieldComment;
begin
AddComment:=true;
AddMember('{c}a : integer');
ParseClass;
AssertNotNull('Have 1 field',Field1);
AssertEquals('field comment','c'+sLineBreak,Field1.DocComment);
AssertVisibility;
end;
Procedure TTestClassType.TestOneVarField;
begin
StartVisibility(visPublished);
@ -640,6 +669,18 @@ begin
AssertEquals('No arguments',0,Method1.ProcType.Args.Count)
end;
Procedure TTestClassType.TestMethodSimpleComment;
begin
AddComment:=True;
AddMember('{c} Procedure DoSomething');
ParseClass;
AssertEquals('1 members',1,TheClass.members.Count);
AssertEquals('Default visibility',visDefault,Method1.Visibility);
AssertNotNull('Have method',Method1);
AssertMemberName('DoSomething');
AssertEquals('Comment','c'+sLineBreak,Method1.DocComment);
end;
Procedure TTestClassType.TestClassMethodSimple;
begin
AddMember('Class Procedure DoSomething');
@ -654,6 +695,14 @@ begin
AssertEquals('No arguments',0,TPasClassProcedure(Members[0]).ProcType.Args.Count)
end;
Procedure TTestClassType.TestClassMethodSimpleComment;
begin
AddComment:=True;
AddMember('{c} Class Procedure DoSomething');
ParseClass;
AssertEquals('Comment','c'+sLineBreak,Members[0].DocComment);
end;
Procedure TTestClassType.TestConstructor;
begin
AddMember('Constructor Create');
@ -967,6 +1016,16 @@ begin
Assertequals('No default value','',Property1.DefaultValue);
end;
Procedure TTestClassType.TestPropertyRedeclareComment;
begin
StartVisibility(visPublished);
AddComment:=True;
AddMember('{p} Property Something');
ParseClass;
AssertProperty(Property1,visPublished,'Something','','','','',0,False,False);
AssertEquals('comment','p'+sLineBreak,Property1.DocComment);
end;
Procedure TTestClassType.TestPropertyRedeclareDefault;
begin
StartVisibility(visPublic);

View File

@ -13,6 +13,7 @@ type
TTestProcedureFunction= class(TTestParser)
private
FAddComment: Boolean;
FFunc: TPasFunction;
FHint: String;
FProc: TPasProcedure;
@ -35,6 +36,8 @@ type
protected
procedure SetUp; override;
procedure TearDown; override;
Procedure AssertComment;
Property AddComment : Boolean Read FAddComment Write FAddComment;
Property Hint : String Read FHint Write FHint;
Property Proc : TPasProcedure Read FProc;
Property ProcType : TPasProcedureType Read GetPT;
@ -42,7 +45,9 @@ type
Property FuncType : TPasFunctionType Read GetFT;
published
procedure TestEmptyProcedure;
procedure TestEmptyProcedureComment;
Procedure TestEmptyFunction;
Procedure TestEmptyFunctionComment;
procedure TestEmptyProcedureDeprecated;
Procedure TestEmptyFunctionDeprecated;
procedure TestEmptyProcedurePlatform;
@ -156,7 +161,8 @@ type
implementation
procedure TTestProcedureFunction.AddDeclaration(Const ASource : string; Const AHint : String = '');
procedure TTestProcedureFunction.AddDeclaration(const ASource: string;
const AHint: String);
Var
D : String;
@ -176,16 +182,24 @@ begin
Result:=Proc.ProcType;
end;
Function TTestProcedureFunction.ParseProcedure(Const ASource : string; Const AHint : String = '') : TPasProcedure;
function TTestProcedureFunction.ParseProcedure(const ASource: string;
const AHint: String): TPasProcedure;
begin
If AddComment then
begin
Add('// A comment');
Engine.NeedComments:=True;
end;
AddDeclaration('procedure A '+ASource,AHint);
Self.ParseProcedure;
Result:=Fproc;
If AddComment then
AssertComment;
end;
procedure TTestProcedureFunction.ParseProcedure;
Procedure TTestProcedureFunction.ParseProcedure;
begin
// Writeln(source.text);
@ -216,7 +230,7 @@ begin
AssertEquals('Correct function result type name',AResult,FuncType.ResultEl.ResultType.Name);
end;
procedure TTestProcedureFunction.ParseFunction;
Procedure TTestProcedureFunction.ParseFunction;
begin
// Writeln(source.text);
ParseDeclarations;
@ -261,7 +275,9 @@ begin
AssertEquals('Not is nested',False,P.ProcType.IsNested);
end;
Function TTestProcedureFunction.BaseAssertArg(ProcType : TPasProcedureType; AIndex : Integer; AName : String; AAccess : TArgumentAccess; AValue : String='') : TPasArgument;
function TTestProcedureFunction.BaseAssertArg(ProcType: TPasProcedureType;
AIndex: Integer; AName: String; AAccess: TArgumentAccess; AValue: String
): TPasArgument;
Var
A : TPasArgument;
@ -287,7 +303,9 @@ begin
Result:=A;
end;
procedure TTestProcedureFunction.AssertArg(ProcType : TPasProcedureType; AIndex : Integer; AName : String; AAccess : TArgumentAccess; Const TypeName : String; AValue : String='');
procedure TTestProcedureFunction.AssertArg(ProcType: TPasProcedureType;
AIndex: Integer; AName: String; AAccess: TArgumentAccess;
const TypeName: String; AValue: String);
Var
A : TPasArgument;
@ -343,19 +361,31 @@ begin
AssertProc([],ccDefault,0);
end;
procedure TTestProcedureFunction.TestEmptyFunction;
procedure TTestProcedureFunction.TestEmptyProcedureComment;
begin
AddComment:=True;
TestEmptyProcedure;
end;
Procedure TTestProcedureFunction.TestEmptyFunction;
begin
ParseFunction('');
AssertFunc([],ccDefault,0);
end;
Procedure TTestProcedureFunction.TestEmptyFunctionComment;
begin
AddComment:=True;
TestEmptyProcedure;
end;
procedure TTestProcedureFunction.TestEmptyProcedureDeprecated;
begin
ParseProcedure('','deprecated');
AssertProc([],ccDefault,0);
end;
procedure TTestProcedureFunction.TestEmptyFunctionDeprecated;
Procedure TTestProcedureFunction.TestEmptyFunctionDeprecated;
begin
ParseFunction('','deprecated');
AssertFunc([],ccDefault,0);
@ -367,7 +397,7 @@ begin
AssertProc([],ccDefault,0);
end;
procedure TTestProcedureFunction.TestEmptyFunctionPlatform;
Procedure TTestProcedureFunction.TestEmptyFunctionPlatform;
begin
ParseFunction('','platform');
AssertFunc([],ccDefault,0);
@ -379,7 +409,7 @@ begin
AssertProc([],ccDefault,0);
end;
procedure TTestProcedureFunction.TestEmptyFunctionExperimental;
Procedure TTestProcedureFunction.TestEmptyFunctionExperimental;
begin
ParseFunction('','experimental');
AssertFunc([],ccDefault,0);
@ -391,7 +421,7 @@ begin
AssertProc([],ccDefault,0);
end;
procedure TTestProcedureFunction.TestEmptyFunctionUnimplemented;
Procedure TTestProcedureFunction.TestEmptyFunctionUnimplemented;
begin
ParseFunction('','unimplemented');
AssertFunc([],ccDefault,0);
@ -407,7 +437,7 @@ begin
AssertArg(ProcType,0,'B',argDefault,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionOneArg;
Procedure TTestProcedureFunction.TestFunctionOneArg;
begin
ParseFunction('(B : Integer)');
AssertFunc([],ccDefault,1);
@ -421,7 +451,7 @@ begin
AssertArg(ProcType,0,'B',argVar,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionOneVarArg;
Procedure TTestProcedureFunction.TestFunctionOneVarArg;
begin
ParseFunction('(Var B : Integer)');
AssertFunc([],ccDefault,1);
@ -435,7 +465,7 @@ begin
AssertArg(ProcType,0,'B',argConst,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionOneConstArg;
Procedure TTestProcedureFunction.TestFunctionOneConstArg;
begin
ParseFunction('(Const B : Integer)');
AssertFunc([],ccDefault,1);
@ -449,7 +479,7 @@ begin
AssertArg(ProcType,0,'B',argOut,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionOneOutArg;
Procedure TTestProcedureFunction.TestFunctionOneOutArg;
begin
ParseFunction('(Out B : Integer)');
AssertFunc([],ccDefault,1);
@ -463,7 +493,7 @@ begin
AssertArg(ProcType,0,'B',argConstRef,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionOneConstRefArg;
Procedure TTestProcedureFunction.TestFunctionOneConstRefArg;
begin
ParseFunction('(ConstRef B : Integer)');
AssertFunc([],ccDefault,1);
@ -478,7 +508,7 @@ begin
AssertArg(ProcType,1,'C',argDefault,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionTwoArgs;
Procedure TTestProcedureFunction.TestFunctionTwoArgs;
begin
ParseFunction('(B,C : Integer)');
AssertFunc([],ccDefault,2);
@ -494,7 +524,7 @@ begin
AssertArg(ProcType,1,'C',argDefault,'Integer','');
end;
procedure TTestProcedureFunction.TestFunctionTwoArgsSeparate;
Procedure TTestProcedureFunction.TestFunctionTwoArgsSeparate;
begin
ParseFunction('(B : Integer;C : Integer)');
AssertFunc([],ccDefault,2);
@ -509,7 +539,7 @@ begin
AssertArg(ProcType,0,'B',argDefault,'Integer','1');
end;
procedure TTestProcedureFunction.TestFunctionOneArgDefault;
Procedure TTestProcedureFunction.TestFunctionOneArgDefault;
begin
ParseFunction('(B : Integer = 1)');
AssertFunc([],ccDefault,1);
@ -523,7 +553,7 @@ begin
AssertArg(ProcType,0,'B',argDefault,'MySet','[1, 2]');
end;
procedure TTestProcedureFunction.TestFunctionOneArgDefaultSet;
Procedure TTestProcedureFunction.TestFunctionOneArgDefaultSet;
begin
ParseFunction('(B : MySet = [1,2])');
AssertFunc([],ccDefault,1);
@ -537,7 +567,7 @@ begin
AssertArg(ProcType,0,'B',argDefault,'Integer','1 + 2');
end;
procedure TTestProcedureFunction.TestFunctionOneArgDefaultExpr;
Procedure TTestProcedureFunction.TestFunctionOneArgDefaultExpr;
begin
ParseFunction('(B : Integer = 1 + 2)');
AssertFunc([],ccDefault,1);
@ -552,7 +582,7 @@ begin
AssertArg(ProcType,1,'C',argDefault,'Integer','2');
end;
procedure TTestProcedureFunction.TestFunctionTwoArgsDefault;
Procedure TTestProcedureFunction.TestFunctionTwoArgsDefault;
begin
ParseFunction('(B : Integer = 1; C : Integer = 2)');
AssertFunc([],ccDefault,2);
@ -567,7 +597,7 @@ begin
AssertArg(ProcType,0,'B',argVar,'','');
end;
procedure TTestProcedureFunction.TestFunctionOneUntypedVarArg;
Procedure TTestProcedureFunction.TestFunctionOneUntypedVarArg;
begin
ParseFunction('(Var B)');
AssertFunc([],ccDefault,1);
@ -582,7 +612,7 @@ begin
AssertArg(ProcType,1,'C',argVar,'','');
end;
procedure TTestProcedureFunction.TestFunctionTwoUntypedVarArgs;
Procedure TTestProcedureFunction.TestFunctionTwoUntypedVarArgs;
begin
ParseFunction('(Var B; Var C)');
AssertFunc([],ccDefault,2);
@ -597,7 +627,7 @@ begin
AssertArg(ProcType,0,'B',argConst,'','');
end;
procedure TTestProcedureFunction.TestFunctionOneUntypedConstArg;
Procedure TTestProcedureFunction.TestFunctionOneUntypedConstArg;
begin
ParseFunction('(Const B)');
AssertFunc([],ccDefault,1);
@ -612,7 +642,7 @@ begin
AssertArg(ProcType,1,'C',argConst,'','');
end;
procedure TTestProcedureFunction.TestFunctionTwoUntypedConstArgs;
Procedure TTestProcedureFunction.TestFunctionTwoUntypedConstArgs;
begin
ParseFunction('(Const B; Const C)');
AssertFunc([],ccDefault,2);
@ -627,7 +657,7 @@ begin
AssertArrayArg(ProcType,0,'B',argDefault,'Integer');
end;
procedure TTestProcedureFunction.TestFunctionOpenArrayArg;
Procedure TTestProcedureFunction.TestFunctionOpenArrayArg;
begin
ParseFunction('(B : Array of Integer)');
AssertFunc([],ccDefault,1);
@ -642,7 +672,7 @@ begin
AssertArrayArg(ProcType,1,'C',argDefault,'Integer');
end;
procedure TTestProcedureFunction.TestFunctionTwoOpenArrayArgs;
Procedure TTestProcedureFunction.TestFunctionTwoOpenArrayArgs;
begin
ParseFunction('(B : Array of Integer;C : Array of Integer)');
AssertFunc([],ccDefault,2);
@ -657,7 +687,7 @@ begin
AssertArrayArg(ProcType,0,'B',argConst,'Integer');
end;
procedure TTestProcedureFunction.TestFunctionConstOpenArrayArg;
Procedure TTestProcedureFunction.TestFunctionConstOpenArrayArg;
begin
ParseFunction('(Const B : Array of Integer)');
AssertFunc([],ccDefault,1);
@ -671,7 +701,7 @@ begin
AssertArrayArg(ProcType,0,'B',argVar,'Integer');
end;
procedure TTestProcedureFunction.TestFunctionVarOpenArrayArg;
Procedure TTestProcedureFunction.TestFunctionVarOpenArrayArg;
begin
ParseFunction('(Var B : Array of Integer)');
AssertFunc([],ccDefault,1);
@ -685,7 +715,7 @@ begin
AssertArrayArg(ProcType,0,'B',argDefault,'');
end;
procedure TTestProcedureFunction.TestFunctionArrayOfConstArg;
Procedure TTestProcedureFunction.TestFunctionArrayOfConstArg;
begin
ParseFunction('(B : Array of Const)');
AssertFunc([],ccDefault,1);
@ -699,100 +729,100 @@ begin
AssertArrayArg(ProcType,0,'B',argConst,'');
end;
procedure TTestProcedureFunction.TestFunctionConstArrayOfConstArg;
Procedure TTestProcedureFunction.TestFunctionConstArrayOfConstArg;
begin
ParseFunction('(Const B : Array of Const)');
AssertFunc([],ccDefault,1);
AssertArrayArg(FuncType,0,'B',argConst,'');
end;
procedure TTestProcedureFunction.TestProcedureCdecl;
Procedure TTestProcedureFunction.TestProcedureCdecl;
begin
ParseProcedure('; cdecl');
AssertProc([],ccCdecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCdecl;
Procedure TTestProcedureFunction.TestFunctionCdecl;
begin
ParseFunction('','','',ccCdecl);
AssertFunc([],ccCdecl,0);
end;
procedure TTestProcedureFunction.TestProcedureCdeclDeprecated;
Procedure TTestProcedureFunction.TestProcedureCdeclDeprecated;
begin
ParseProcedure('; cdecl;','deprecated');
AssertProc([],ccCdecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCdeclDeprecated;
Procedure TTestProcedureFunction.TestFunctionCdeclDeprecated;
begin
ParseFunction('','','deprecated',ccCdecl);
AssertFunc([],ccCdecl,0);
end;
procedure TTestProcedureFunction.TestProcedureSafeCall;
Procedure TTestProcedureFunction.TestProcedureSafeCall;
begin
ParseProcedure('; safecall;','');
AssertProc([],ccSafeCall,0);
end;
procedure TTestProcedureFunction.TestFunctionSafeCall;
Procedure TTestProcedureFunction.TestFunctionSafeCall;
begin
ParseFunction('','','',ccSafecall);
AssertFunc([],ccSafecall,0);
end;
procedure TTestProcedureFunction.TestProcedurePascal;
Procedure TTestProcedureFunction.TestProcedurePascal;
begin
ParseProcedure('; pascal;','');
AssertProc([],ccPascal,0);
end;
procedure TTestProcedureFunction.TestFunctionPascal;
Procedure TTestProcedureFunction.TestFunctionPascal;
begin
ParseFunction('','','',ccPascal);
AssertFunc([],ccPascal,0);
end;
procedure TTestProcedureFunction.TestProcedureStdCall;
Procedure TTestProcedureFunction.TestProcedureStdCall;
begin
ParseProcedure('; stdcall;','');
AssertProc([],ccstdcall,0);
end;
procedure TTestProcedureFunction.TestFunctionStdCall;
Procedure TTestProcedureFunction.TestFunctionStdCall;
begin
ParseFunction('','','',ccStdCall);
AssertFunc([],ccStdCall,0);
end;
procedure TTestProcedureFunction.TestProcedureOldFPCCall;
Procedure TTestProcedureFunction.TestProcedureOldFPCCall;
begin
ParseProcedure('; oldfpccall;','');
AssertProc([],ccoldfpccall,0);
end;
procedure TTestProcedureFunction.TestFunctionOldFPCCall;
Procedure TTestProcedureFunction.TestFunctionOldFPCCall;
begin
ParseFunction('','','',ccOldFPCCall);
AssertFunc([],ccOldFPCCall,0);
end;
procedure TTestProcedureFunction.TestProcedurePublic;
Procedure TTestProcedureFunction.TestProcedurePublic;
begin
ParseProcedure('; public name ''myfunc'';','');
AssertProc([pmPublic],ccDefault,0);
AssertExpression('Public name',Proc.PublicName,pekString,'''myfunc''');
end;
procedure TTestProcedureFunction.TestProcedurePublicIdent;
Procedure TTestProcedureFunction.TestProcedurePublicIdent;
begin
ParseProcedure('; public name exportname;','');
AssertProc([pmPublic],ccDefault,0);
AssertExpression('Public name',Proc.PublicName,pekIdent,'exportname');
end;
procedure TTestProcedureFunction.TestFunctionPublic;
Procedure TTestProcedureFunction.TestFunctionPublic;
begin
AddDeclaration('function A : Integer; public name exportname');
ParseFunction;
@ -800,14 +830,14 @@ begin
AssertExpression('Public name',Func.PublicName,pekIdent,'exportname');
end;
procedure TTestProcedureFunction.TestProcedureCdeclPublic;
Procedure TTestProcedureFunction.TestProcedureCdeclPublic;
begin
ParseProcedure('; cdecl; public name exportname;','');
AssertProc([pmPublic],ccCDecl,0);
AssertExpression('Public name',Proc.PublicName,pekIdent,'exportname');
end;
procedure TTestProcedureFunction.TestFunctionCdeclPublic;
Procedure TTestProcedureFunction.TestFunctionCdeclPublic;
begin
AddDeclaration('function A : Integer; cdecl; public name exportname');
ParseFunction;
@ -815,58 +845,58 @@ begin
AssertExpression('Public name',Func.PublicName,pekIdent,'exportname');
end;
procedure TTestProcedureFunction.TestProcedureOverload;
Procedure TTestProcedureFunction.TestProcedureOverload;
begin
ParseProcedure('; overload;','');
AssertProc([pmOverload],ccDefault,0);
end;
procedure TTestProcedureFunction.TestFunctionOverload;
Procedure TTestProcedureFunction.TestFunctionOverload;
begin
AddDeclaration('function A : Integer; overload');
ParseFunction;
AssertFunc([pmOverload],ccDefault,0);
end;
procedure TTestProcedureFunction.TestProcedureVarargs;
Procedure TTestProcedureFunction.TestProcedureVarargs;
begin
ParseProcedure('; varargs;','');
AssertProc([pmVarArgs],ccDefault,0);
end;
procedure TTestProcedureFunction.TestFunctionVarArgs;
Procedure TTestProcedureFunction.TestFunctionVarArgs;
begin
AddDeclaration('function A : Integer; varargs');
ParseFunction;
AssertFunc([pmVarArgs],ccDefault,0);
end;
procedure TTestProcedureFunction.TestProcedureCDeclVarargs;
Procedure TTestProcedureFunction.TestProcedureCDeclVarargs;
begin
ParseProcedure(';cdecl; varargs;','');
AssertProc([pmVarArgs],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCDeclVarArgs;
Procedure TTestProcedureFunction.TestFunctionCDeclVarArgs;
begin
AddDeclaration('function A : Integer; cdecl; varargs');
ParseFunction;
AssertFunc([pmVarArgs],ccCdecl,0);
end;
procedure TTestProcedureFunction.TestProcedureForwardInterface;
Procedure TTestProcedureFunction.TestProcedureForwardInterface;
begin
AddDeclaration('procedure A; forward;');
AssertException(EParserError,@ParseProcedure);
end;
procedure TTestProcedureFunction.TestFunctionForwardInterface;
Procedure TTestProcedureFunction.TestFunctionForwardInterface;
begin
AddDeclaration('function A : integer; forward;');
AssertException(EParserError,@ParseFunction);
end;
procedure TTestProcedureFunction.TestProcedureForward;
Procedure TTestProcedureFunction.TestProcedureForward;
begin
UseImplementation:=True;
AddDeclaration('procedure A; forward;');
@ -874,7 +904,7 @@ begin
AssertProc([pmforward],ccDefault,0);
end;
procedure TTestProcedureFunction.TestFunctionForward;
Procedure TTestProcedureFunction.TestFunctionForward;
begin
UseImplementation:=True;
AddDeclaration('function A : integer; forward;');
@ -882,7 +912,7 @@ begin
AssertFunc([pmforward],ccDefault,0);
end;
procedure TTestProcedureFunction.TestProcedureCdeclForward;
Procedure TTestProcedureFunction.TestProcedureCdeclForward;
begin
UseImplementation:=True;
AddDeclaration('procedure A; cdecl; forward;');
@ -890,7 +920,7 @@ begin
AssertProc([pmforward],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCDeclForward;
Procedure TTestProcedureFunction.TestFunctionCDeclForward;
begin
UseImplementation:=True;
AddDeclaration('function A : integer; cdecl; forward;');
@ -898,92 +928,92 @@ begin
AssertFunc([pmforward],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestProcedureCompilerProc;
Procedure TTestProcedureFunction.TestProcedureCompilerProc;
begin
ParseProcedure(';compilerproc;','');
AssertProc([pmCompilerProc],ccDefault,0);
end;
procedure TTestProcedureFunction.TestFunctionCompilerProc;
Procedure TTestProcedureFunction.TestFunctionCompilerProc;
begin
AddDeclaration('function A : Integer; compilerproc');
ParseFunction;
AssertFunc([pmCompilerProc],ccDefault,0);
end;
procedure TTestProcedureFunction.TestProcedureCDeclCompilerProc;
Procedure TTestProcedureFunction.TestProcedureCDeclCompilerProc;
begin
ParseProcedure(';cdecl;compilerproc;','');
AssertProc([pmCompilerProc],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCDeclCompilerProc;
Procedure TTestProcedureFunction.TestFunctionCDeclCompilerProc;
begin
AddDeclaration('function A : Integer; cdecl; compilerproc');
ParseFunction;
AssertFunc([pmCompilerProc],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestProcedureAssembler;
Procedure TTestProcedureFunction.TestProcedureAssembler;
begin
ParseProcedure(';assembler;','');
AssertProc([pmAssembler],ccDefault,0);
end;
procedure TTestProcedureFunction.TestFunctionAssembler;
Procedure TTestProcedureFunction.TestFunctionAssembler;
begin
AddDeclaration('function A : Integer; assembler');
ParseFunction;
AssertFunc([pmAssembler],ccDefault,0);
end;
procedure TTestProcedureFunction.TestProcedureCDeclAssembler;
Procedure TTestProcedureFunction.TestProcedureCDeclAssembler;
begin
ParseProcedure(';cdecl;assembler;','');
AssertProc([pmAssembler],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCDeclAssembler;
Procedure TTestProcedureFunction.TestFunctionCDeclAssembler;
begin
AddDeclaration('function A : Integer; cdecl; assembler');
ParseFunction;
AssertFunc([pmAssembler],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestProcedureExport;
Procedure TTestProcedureFunction.TestProcedureExport;
begin
ParseProcedure(';export;','');
AssertProc([pmExport],ccDefault,0);
end;
procedure TTestProcedureFunction.TestFunctionExport;
Procedure TTestProcedureFunction.TestFunctionExport;
begin
AddDeclaration('function A : Integer; export');
ParseFunction;
AssertFunc([pmExport],ccDefault,0);
end;
procedure TTestProcedureFunction.TestProcedureCDeclExport;
Procedure TTestProcedureFunction.TestProcedureCDeclExport;
begin
ParseProcedure('cdecl;export;','');
AssertProc([pmExport],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestFunctionCDeclExport;
Procedure TTestProcedureFunction.TestFunctionCDeclExport;
begin
AddDeclaration('function A : Integer; cdecl; export');
ParseFunction;
AssertFunc([pmExport],ccCDecl,0);
end;
procedure TTestProcedureFunction.TestProcedureExternal;
Procedure TTestProcedureFunction.TestProcedureExternal;
begin
ParseProcedure(';external','');
AssertProc([pmExternal],ccDefault,0);
AssertNull('No Library name expression',Proc.LibraryExpr);
end;
procedure TTestProcedureFunction.TestFunctionExternal;
Procedure TTestProcedureFunction.TestFunctionExternal;
begin
AddDeclaration('function A : Integer; external');
ParseFunction;
@ -991,14 +1021,14 @@ begin
AssertNull('No Library name expression',Func.LibraryExpr);
end;
procedure TTestProcedureFunction.TestProcedureExternalLibName;
Procedure TTestProcedureFunction.TestProcedureExternalLibName;
begin
ParseProcedure(';external ''libname''','');
AssertProc([pmExternal],ccDefault,0);
AssertExpression('Library name expression',Proc.LibraryExpr,pekString,'''libname''');
end;
procedure TTestProcedureFunction.TestFunctionExternalLibName;
Procedure TTestProcedureFunction.TestFunctionExternalLibName;
begin
AddDeclaration('function A : Integer; external ''libname''');
ParseFunction;
@ -1006,7 +1036,7 @@ begin
AssertExpression('Library name expression',Func.LibraryExpr,pekString,'''libname''');
end;
procedure TTestProcedureFunction.TestProcedureExternalLibNameName;
Procedure TTestProcedureFunction.TestProcedureExternalLibNameName;
begin
ParseProcedure(';external ''libname'' name ''symbolname''','');
AssertProc([pmExternal],ccDefault,0);
@ -1014,7 +1044,7 @@ begin
AssertExpression('Library symbol expression',Proc.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestFunctionExternalLibNameName;
Procedure TTestProcedureFunction.TestFunctionExternalLibNameName;
begin
AddDeclaration('function A : Integer; external ''libname'' name ''symbolname''');
ParseFunction;
@ -1023,7 +1053,7 @@ begin
AssertExpression('Library symbol expression',Func.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestProcedureExternalName;
Procedure TTestProcedureFunction.TestProcedureExternalName;
begin
ParseProcedure(';external name ''symbolname''','');
AssertProc([pmExternal],ccDefault,0);
@ -1031,7 +1061,7 @@ begin
AssertExpression('Library symbol expression',Proc.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestFunctionExternalName;
Procedure TTestProcedureFunction.TestFunctionExternalName;
begin
AddDeclaration('function A : Integer; external name ''symbolname''');
ParseFunction;
@ -1040,14 +1070,14 @@ begin
AssertExpression('Library symbol expression',Func.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestProcedureCdeclExternal;
Procedure TTestProcedureFunction.TestProcedureCdeclExternal;
begin
ParseProcedure('; cdecl; external','');
AssertProc([pmExternal],ccCdecl,0);
AssertNull('No Library name expression',Proc.LibraryExpr);
end;
procedure TTestProcedureFunction.TestFunctionCdeclExternal;
Procedure TTestProcedureFunction.TestFunctionCdeclExternal;
begin
AddDeclaration('function A : Integer; cdecl; external');
ParseFunction;
@ -1055,14 +1085,14 @@ begin
AssertNull('No Library name expression',Func.LibraryExpr);
end;
procedure TTestProcedureFunction.TestProcedureCdeclExternalLibName;
Procedure TTestProcedureFunction.TestProcedureCdeclExternalLibName;
begin
ParseProcedure('; cdecl; external ''libname''','');
AssertProc([pmExternal],ccCdecl,0);
AssertExpression('Library name expression',Proc.LibraryExpr,pekString,'''libname''');
end;
procedure TTestProcedureFunction.TestFunctionCdeclExternalLibName;
Procedure TTestProcedureFunction.TestFunctionCdeclExternalLibName;
begin
AddDeclaration('function A : Integer; cdecl; external ''libname''');
ParseFunction;
@ -1070,7 +1100,7 @@ begin
AssertExpression('Library name expression',Func.LibraryExpr,pekString,'''libname''');
end;
procedure TTestProcedureFunction.TestProcedureCdeclExternalLibNameName;
Procedure TTestProcedureFunction.TestProcedureCdeclExternalLibNameName;
begin
ParseProcedure('; cdecl; external ''libname'' name ''symbolname''','');
AssertProc([pmExternal],ccCdecl,0);
@ -1078,7 +1108,7 @@ begin
AssertExpression('Library symbol expression',Proc.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestFunctionCdeclExternalLibNameName;
Procedure TTestProcedureFunction.TestFunctionCdeclExternalLibNameName;
begin
AddDeclaration('function A : Integer; cdecl; external ''libname'' name ''symbolname''');
ParseFunction;
@ -1087,7 +1117,7 @@ begin
AssertExpression('Library symbol expression',Func.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestProcedureCdeclExternalName;
Procedure TTestProcedureFunction.TestProcedureCdeclExternalName;
begin
ParseProcedure('; cdecl; external name ''symbolname''','');
AssertProc([pmExternal],ccCdecl,0);
@ -1095,7 +1125,7 @@ begin
AssertExpression('Library symbol expression',Proc.LibrarySymbolName,pekString,'''symbolname''');
end;
procedure TTestProcedureFunction.TestFunctionCdeclExternalName;
Procedure TTestProcedureFunction.TestFunctionCdeclExternalName;
begin
AddDeclaration('function A : Integer; cdecl; external name ''symbolname''');
ParseFunction;
@ -1114,6 +1144,11 @@ begin
Inherited;
end;
Procedure TTestProcedureFunction.AssertComment;
begin
AssertEquals('Correct comment',' A comment'+sLineBreak,FProc.DocComment);
end;
initialization
RegisterTest(TTestProcedureFunction);

View File

@ -31,12 +31,15 @@ Type
Procedure TestEmptyStatement;
Procedure TestEmptyStatements;
Procedure TestBlock;
Procedure TestBlockComment;
Procedure TestBlock2Comments;
Procedure TestAssignment;
Procedure TestAssignmentAdd;
Procedure TestAssignmentMinus;
Procedure TestAssignmentMul;
Procedure TestAssignmentDivision;
Procedure TestCall;
Procedure TestCallComment;
Procedure TestCallQualified;
Procedure TestCallQualified2;
Procedure TestCallNoArgs;
@ -95,19 +98,19 @@ implementation
{ TTestStatementParser }
procedure TTestStatementParser.SetUp;
Procedure TTestStatementParser.SetUp;
begin
inherited SetUp;
FVariables:=TStringList.Create;
end;
procedure TTestStatementParser.TearDown;
Procedure TTestStatementParser.TearDown;
begin
FreeAndNil(FVariables);
inherited TearDown;
end;
procedure TTestStatementParser.AddStatements(ASource: array of string);
procedure TTestStatementParser.AddStatements(ASource: Array of string);
Var
I :Integer;
@ -124,8 +127,8 @@ begin
Add(' '+ASource[i]);
end;
procedure TTestStatementParser.DeclareVar(const AVarType: String;
const AVarName: String);
Procedure TTestStatementParser.DeclareVar(Const AVarType: String;
Const AVarName: String);
begin
FVariables.Add(AVarName+' : '+AVarType+';');
end;
@ -135,7 +138,8 @@ begin
Result:=TestStatement([ASource]);
end;
function TTestStatementParser.TestStatement(ASource: array of string): TPasImplElement;
function TTestStatementParser.TestStatement(ASource: Array of string
): TPasImplElement;
begin
@ -152,19 +156,19 @@ begin
Result:=FStatement;
end;
procedure TTestStatementParser.ExpectParserError(Const Msg : string);
Procedure TTestStatementParser.ExpectParserError(Const Msg: string);
begin
AssertException(Msg,EParserError,@ParseModule);
end;
procedure TTestStatementParser.ExpectParserError(const Msg: string;
ASource: array of string);
Procedure TTestStatementParser.ExpectParserError(Const Msg: string;
ASource: Array of string);
begin
AddStatements(ASource);
ExpectParserError(Msg);
end;
function TTestStatementParser.AssertStatement(Msg: String; AClass: TClass;
Function TTestStatementParser.AssertStatement(Msg: String; AClass: TClass;
AIndex: Integer): TPasImplBlock;
begin
if not (AIndex<PasProgram.InitializationSection.Elements.Count) then
@ -174,26 +178,26 @@ begin
Result:=TObject(PasProgram.InitializationSection.Elements[AIndex]) as TPasImplBlock;
end;
procedure TTestStatementParser.TestEmpty;
Procedure TTestStatementParser.TestEmpty;
begin
//TestStatement(';');
TestStatement('');
AssertEquals('No statements',0,PasProgram.InitializationSection.Elements.Count);
end;
procedure TTestStatementParser.TestEmptyStatement;
Procedure TTestStatementParser.TestEmptyStatement;
begin
TestStatement(';');
AssertEquals('0 statement',0,PasProgram.InitializationSection.Elements.Count);
end;
procedure TTestStatementParser.TestEmptyStatements;
Procedure TTestStatementParser.TestEmptyStatements;
begin
TestStatement(';;');
AssertEquals('0 statement',0,PasProgram.InitializationSection.Elements.Count);
end;
procedure TTestStatementParser.TestBlock;
Procedure TTestStatementParser.TestBlock;
Var
B : TPasImplBeginBlock;
@ -207,7 +211,37 @@ begin
AssertEquals('Empty block',0,B.Elements.Count);
end;
procedure TTestStatementParser.TestAssignment;
Procedure TTestStatementParser.TestBlockComment;
Var
B : TPasImplBeginBlock;
begin
Engine.NeedComments:=True;
TestStatement(['{ This is a comment }','begin','end']);
AssertEquals('1 statement',1,PasProgram.InitializationSection.Elements.Count);
AssertNotNull('Statement assigned',PasProgram.InitializationSection.Elements[0]);
AssertEquals('Block statement',TPasImplBeginBlock,Statement.ClassType);
B:= Statement as TPasImplBeginBlock;
AssertEquals('Empty block',0,B.Elements.Count);
AssertEquals('No DocComment','',B.DocComment);
end;
Procedure TTestStatementParser.TestBlock2Comments;
Var
B : TPasImplBeginBlock;
begin
Engine.NeedComments:=True;
TestStatement(['{ This is a comment }','// Another comment','begin','end']);
AssertEquals('1 statement',1,PasProgram.InitializationSection.Elements.Count);
AssertNotNull('Statement assigned',PasProgram.InitializationSection.Elements[0]);
AssertEquals('Block statement',TPasImplBeginBlock,Statement.ClassType);
B:= Statement as TPasImplBeginBlock;
AssertEquals('Empty block',0,B.Elements.Count);
AssertEquals('No DocComment','',B.DocComment);
end;
Procedure TTestStatementParser.TestAssignment;
Var
A : TPasImplAssign;
@ -223,7 +257,7 @@ begin
AssertExpression('Left side is variable',A.Left,pekIdent,'a');
end;
procedure TTestStatementParser.TestAssignmentAdd;
Procedure TTestStatementParser.TestAssignmentAdd;
Var
A : TPasImplAssign;
@ -240,7 +274,7 @@ begin
AssertExpression('Left side is variable',A.Left,pekIdent,'a');
end;
procedure TTestStatementParser.TestAssignmentMinus;
Procedure TTestStatementParser.TestAssignmentMinus;
Var
A : TPasImplAssign;
@ -256,7 +290,7 @@ begin
AssertExpression('Left side is variable',A.Left,pekIdent,'a');
end;
procedure TTestStatementParser.TestAssignmentMul;
Procedure TTestStatementParser.TestAssignmentMul;
Var
A : TPasImplAssign;
@ -272,7 +306,7 @@ begin
AssertExpression('Left side is variable',A.Left,pekIdent,'a');
end;
procedure TTestStatementParser.TestAssignmentDivision;
Procedure TTestStatementParser.TestAssignmentDivision;
Var
A : TPasImplAssign;
@ -288,7 +322,7 @@ begin
AssertExpression('Left side is variable',A.Left,pekIdent,'a');
end;
procedure TTestStatementParser.TestCall;
Procedure TTestStatementParser.TestCall;
Var
S : TPasImplSimple;
@ -301,7 +335,22 @@ begin
AssertExpression('Doit call',S.Expr,pekIdent,'Doit');
end;
procedure TTestStatementParser.TestCallQualified;
Procedure TTestStatementParser.TestCallComment;
Var
S : TPasImplSimple;
begin
Engine.NeedComments:=True;
TestStatement(['//comment line','Doit;']);
AssertEquals('1 statement',1,PasProgram.InitializationSection.Elements.Count);
AssertEquals('Simple statement',TPasImplSimple,Statement.ClassType);
AssertEquals('1 statement',1,PasProgram.InitializationSection.Elements.Count);
S:=Statement as TPasImplSimple;
AssertExpression('Doit call',S.Expr,pekIdent,'Doit');
AssertEquals('No DocComment','',S.DocComment);
end;
Procedure TTestStatementParser.TestCallQualified;
Var
S : TPasImplSimple;
@ -319,7 +368,7 @@ begin
end;
procedure TTestStatementParser.TestCallQualified2;
Procedure TTestStatementParser.TestCallQualified2;
Var
S : TPasImplSimple;
B : TBinaryExpr;
@ -338,7 +387,7 @@ begin
AssertExpression('Doit call',B.Right,pekIdent,'Doit');
end;
procedure TTestStatementParser.TestCallNoArgs;
Procedure TTestStatementParser.TestCallNoArgs;
Var
S : TPasImplSimple;
@ -355,7 +404,7 @@ begin
AssertEquals('No params',0,Length(P.Params));
end;
procedure TTestStatementParser.TestCallOneArg;
Procedure TTestStatementParser.TestCallOneArg;
Var
S : TPasImplSimple;
P : TParamsExpr;
@ -372,7 +421,7 @@ begin
AssertExpression('Parameter is constant',P.Params[0],pekNumber,'1');
end;
procedure TTestStatementParser.TestIf;
Procedure TTestStatementParser.TestIf;
Var
I : TPasImplIfElse;
@ -386,7 +435,7 @@ begin
AssertNull('No if branch',I.IfBranch);
end;
procedure TTestStatementParser.TestIfBlock;
Procedure TTestStatementParser.TestIfBlock;
Var
I : TPasImplIfElse;
@ -401,7 +450,7 @@ begin
AssertEquals('begin end block',TPasImplBeginBlock,I.ifBranch.ClassType);
end;
procedure TTestStatementParser.TestIfAssignment;
Procedure TTestStatementParser.TestIfAssignment;
Var
I : TPasImplIfElse;
@ -416,7 +465,7 @@ begin
AssertEquals('assignment statement',TPasImplAssign,I.ifBranch.ClassType);
end;
procedure TTestStatementParser.TestIfElse;
Procedure TTestStatementParser.TestIfElse;
Var
I : TPasImplIfElse;
@ -431,7 +480,7 @@ begin
AssertEquals('begin end block',TPasImplBeginBlock,I.ifBranch.ClassType);
end;
procedure TTestStatementParser.TestIfElseBlock;
Procedure TTestStatementParser.TestIfElseBlock;
Var
I : TPasImplIfElse;
@ -446,14 +495,14 @@ begin
AssertEquals('begin end block',TPasImplBeginBlock,I.ElseBranch.ClassType);
end;
procedure TTestStatementParser.TestIfSemiColonElseError;
Procedure TTestStatementParser.TestIfSemiColonElseError;
begin
DeclareVar('boolean');
ExpectParserError('No semicolon before else',['if a then',' begin',' end;','else',' begin',' end']);
end;
procedure TTestStatementParser.TestNestedIf;
Procedure TTestStatementParser.TestNestedIf;
Var
I : TPasImplIfElse;
begin
@ -470,7 +519,7 @@ begin
end;
procedure TTestStatementParser.TestNestedIfElse;
Procedure TTestStatementParser.TestNestedIfElse;
Var
I : TPasImplIfElse;
@ -488,7 +537,7 @@ begin
AssertEquals('begin end block',TPasImplBeginBlock,I.ElseBranch.ClassType);
end;
procedure TTestStatementParser.TestWhile;
Procedure TTestStatementParser.TestWhile;
Var
W : TPasImplWhileDo;
@ -501,7 +550,7 @@ begin
AssertNull('Empty body',W.Body);
end;
procedure TTestStatementParser.TestWhileBlock;
Procedure TTestStatementParser.TestWhileBlock;
Var
W : TPasImplWhileDo;
@ -515,7 +564,7 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(W.Body).ELements.Count);
end;
procedure TTestStatementParser.TestWhileNested;
Procedure TTestStatementParser.TestWhileNested;
Var
W : TPasImplWhileDo;
@ -535,7 +584,7 @@ begin
AssertEquals('Empty nested block',0,TPasImplBeginBlock(W.Body).ELements.Count);
end;
procedure TTestStatementParser.TestRepeat;
Procedure TTestStatementParser.TestRepeat;
Var
R : TPasImplRepeatUntil;
@ -548,7 +597,7 @@ begin
AssertEquals('Empty body',0,R.Elements.Count);
end;
procedure TTestStatementParser.TestRepeatBlock;
Procedure TTestStatementParser.TestRepeatBlock;
Var
R : TPasImplRepeatUntil;
@ -578,7 +627,7 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(R.Elements[0]).ELements.Count);
end;
procedure TTestStatementParser.TestRepeatNested;
Procedure TTestStatementParser.TestRepeatNested;
Var
R : TPasImplRepeatUntil;
@ -598,7 +647,7 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(R.Elements[0]).ELements.Count);
end;
procedure TTestStatementParser.TestFor;
Procedure TTestStatementParser.TestFor;
Var
F : TPasImplForLoop;
@ -615,7 +664,7 @@ begin
AssertNull('Empty body',F.Body);
end;
procedure TTestStatementParser.TestForIn;
Procedure TTestStatementParser.TestForIn;
Var
F : TPasImplForLoop;
@ -632,7 +681,7 @@ begin
AssertNull('Empty body',F.Body);
end;
procedure TTestStatementParser.TestForExpr;
Procedure TTestStatementParser.TestForExpr;
Var
F : TPasImplForLoop;
B : TBinaryExpr;
@ -654,7 +703,7 @@ begin
AssertNull('Empty body',F.Body);
end;
procedure TTestStatementParser.TestForBlock;
Procedure TTestStatementParser.TestForBlock;
Var
F : TPasImplForLoop;
@ -690,7 +739,7 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(F.Body).ELements.Count);
end;
procedure TTestStatementParser.TestForNested;
Procedure TTestStatementParser.TestForNested;
Var
F : TPasImplForLoop;
@ -715,7 +764,7 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(F.Body).ELements.Count);
end;
procedure TTestStatementParser.TestWith;
Procedure TTestStatementParser.TestWith;
Var
W : TpasImplWithDo;
@ -731,7 +780,7 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(W.Body).ELements.Count);
end;
procedure TTestStatementParser.TestWithMultiple;
Procedure TTestStatementParser.TestWithMultiple;
Var
W : TpasImplWithDo;
@ -748,14 +797,14 @@ begin
AssertEquals('Empty block',0,TPasImplBeginBlock(W.Body).ELements.Count);
end;
procedure TTestStatementParser.TestCaseEmpty;
Procedure TTestStatementParser.TestCaseEmpty;
begin
DeclareVar('integer');
AddStatements(['case a of','end;']);
ExpectParserError('Empty case not allowed');
end;
procedure TTestStatementParser.TestCaseOneInteger;
Procedure TTestStatementParser.TestCaseOneInteger;
Var
C : TPasImplCaseOf;
@ -777,7 +826,7 @@ begin
AssertNull('Empty case label statement',S.Body);
end;
procedure TTestStatementParser.TestCaseTwoIntegers;
Procedure TTestStatementParser.TestCaseTwoIntegers;
Var
C : TPasImplCaseOf;
@ -800,7 +849,7 @@ begin
AssertNull('Empty case label statement',S.Body);
end;
procedure TTestStatementParser.TestCaseRange;
Procedure TTestStatementParser.TestCaseRange;
Var
C : TPasImplCaseOf;
S : TPasImplCaseStatement;
@ -821,7 +870,7 @@ begin
AssertNull('Empty case label statement',S.Body);
end;
procedure TTestStatementParser.TestCaseRangeSeparate;
Procedure TTestStatementParser.TestCaseRangeSeparate;
Var
C : TPasImplCaseOf;
S : TPasImplCaseStatement;
@ -843,7 +892,7 @@ begin
AssertNull('Empty case label statement',S.Body);
end;
procedure TTestStatementParser.TestCase2Cases;
Procedure TTestStatementParser.TestCase2Cases;
Var
C : TPasImplCaseOf;
S : TPasImplCaseStatement;
@ -871,7 +920,7 @@ begin
AssertNull('Empty case label statement 2',S.Body);
end;
procedure TTestStatementParser.TestCaseBlock;
Procedure TTestStatementParser.TestCaseBlock;
Var
C : TPasImplCaseOf;
@ -897,7 +946,7 @@ begin
end;
procedure TTestStatementParser.TestCaseElseBlockEmpty;
Procedure TTestStatementParser.TestCaseElseBlockEmpty;
Var
C : TPasImplCaseOf;
@ -924,7 +973,7 @@ begin
AssertEquals('Zero statements ',0,TPasImplCaseElse(C.ElseBranch).Elements.Count);
end;
procedure TTestStatementParser.TestCaseElseBlockAssignment;
Procedure TTestStatementParser.TestCaseElseBlockAssignment;
Var
C : TPasImplCaseOf;
S : TPasImplCaseStatement;
@ -950,7 +999,7 @@ begin
AssertEquals('1 statement in else branch ',1,TPasImplCaseElse(C.ElseBranch).Elements.Count);
end;
procedure TTestStatementParser.TestCaseElseBlock2Assignments;
Procedure TTestStatementParser.TestCaseElseBlock2Assignments;
Var
C : TPasImplCaseOf;
@ -977,7 +1026,7 @@ begin
AssertEquals('2 statements in else branch ',2,TPasImplCaseElse(C.ElseBranch).Elements.Count);
end;
procedure TTestStatementParser.TestCaseIfCaseElse;
Procedure TTestStatementParser.TestCaseIfCaseElse;
Var
C : TPasImplCaseOf;
@ -995,7 +1044,7 @@ begin
AssertEquals('0 statement in else branch ',0,TPasImplCaseElse(C.ElseBranch).Elements.Count);
end;
procedure TTestStatementParser.TestCaseIfElse;
Procedure TTestStatementParser.TestCaseIfElse;
Var
C : TPasImplCaseOf;
S : TPasImplCaseStatement;
@ -1017,7 +1066,7 @@ begin
AssertNotNull('If statement has else block',TPasImplIfElse(S.Elements[0]).ElseBranch);
end;
procedure TTestStatementParser.TestRaise;
Procedure TTestStatementParser.TestRaise;
Var
R : TPasImplRaise;
@ -1032,7 +1081,7 @@ begin
AssertExpression('Expression object',R.ExceptObject,pekIdent,'A');
end;
procedure TTestStatementParser.TestRaiseEmpty;
Procedure TTestStatementParser.TestRaiseEmpty;
Var
R : TPasImplRaise;
@ -1044,7 +1093,7 @@ begin
AssertNull(R.ExceptAddr);
end;
procedure TTestStatementParser.TestRaiseAt;
Procedure TTestStatementParser.TestRaiseAt;
Var
R : TPasImplRaise;
@ -1060,7 +1109,7 @@ begin
AssertExpression('Expression object',R.ExceptAddr,pekIdent,'B');
end;
procedure TTestStatementParser.TestTryFinally;
Procedure TTestStatementParser.TestTryFinally;
Var
T : TPasImplTry;
@ -1086,7 +1135,7 @@ begin
AssertExpression('DoSomethingElse call',S.Expr,pekIdent,'DoSomethingElse');
end;
procedure TTestStatementParser.TestTryFinallyEmpty;
Procedure TTestStatementParser.TestTryFinallyEmpty;
Var
T : TPasImplTry;
F : TPasImplTryFinally;
@ -1102,7 +1151,7 @@ begin
AssertEquals(0,F.Elements.Count);
end;
procedure TTestStatementParser.TestTryFinallyNested;
Procedure TTestStatementParser.TestTryFinallyNested;
Var
T : TPasImplTry;
S : TPasImplSimple;
@ -1230,7 +1279,7 @@ begin
AssertEquals(0,E.Elements.Count);
end;
procedure TTestStatementParser.TestTryExceptOn;
Procedure TTestStatementParser.TestTryExceptOn;
Var
T : TPasImplTry;
@ -1264,7 +1313,7 @@ begin
end;
procedure TTestStatementParser.TestTryExceptOn2;
Procedure TTestStatementParser.TestTryExceptOn2;
Var
T : TPasImplTry;
@ -1309,7 +1358,7 @@ begin
AssertExpression('DoSomethingElse call',S.Expr,pekIdent,'DoSomethingElse2');
end;
procedure TTestStatementParser.TestTryExceptOnElse;
Procedure TTestStatementParser.TestTryExceptOnElse;
Var
T : TPasImplTry;
S : TPasImplSimple;
@ -1356,7 +1405,7 @@ begin
AssertExpression('DoSomething call',S.Expr,pekIdent,'DoSomethingMore');
end;
procedure TTestStatementParser.TestTryExceptOnIfElse;
Procedure TTestStatementParser.TestTryExceptOnIfElse;
Var
T : TPasImplTry;
S : TPasImplSimple;

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="--suite=TTestRecordTypeParser.TestVisibilityAndMethods"/>
<CommandLineParams Value="--suite=TTestStatementParser.TestCallComment"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@ -42,7 +42,6 @@
<Unit0>
<Filename Value="testpassrc.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="testpassrc"/>
</Unit0>
<Unit1>
<Filename Value="tcscanner.pas"/>
@ -67,17 +66,14 @@
<Unit5>
<Filename Value="tcmoduleparser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tcmoduleparser"/>
</Unit5>
<Unit6>
<Filename Value="tconstparser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tconstparser"/>
</Unit6>
<Unit7>
<Filename Value="tcvarparser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="tcvarparser"/>
</Unit7>
<Unit8>
<Filename Value="tcclasstype.pas"/>
@ -107,12 +103,6 @@
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../src"/>
</SearchPaths>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">