mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 23:19:26 +02:00
fcl-passrc: try except on do else end without semicolon at do statement
git-svn-id: trunk@45473 -
This commit is contained in:
parent
e0d2651a61
commit
766ccac8df
packages/fcl-passrc
@ -5955,7 +5955,8 @@ begin
|
||||
else if (CurBlock is TPasImplWhileDo)
|
||||
or (CurBlock is TPasImplForLoop)
|
||||
or (CurBlock is TPasImplWithDo)
|
||||
or (CurBlock is TPasImplRaise) then
|
||||
or (CurBlock is TPasImplRaise)
|
||||
or (CurBlock is TPasImplExceptOn) then
|
||||
// simply close block
|
||||
else
|
||||
ParseExcSyntaxError;
|
||||
|
@ -115,6 +115,7 @@ Type
|
||||
Procedure TestTryExceptOn2;
|
||||
Procedure TestTryExceptOnElse;
|
||||
Procedure TestTryExceptOnIfElse;
|
||||
Procedure TestTryExceptOnElseNoSemicolo;
|
||||
procedure TestTryExceptRaise;
|
||||
Procedure TestAsm;
|
||||
Procedure TestAsmBlock;
|
||||
@ -1705,6 +1706,44 @@ begin
|
||||
AssertExpression('DoSomething call',S.Expr,pekIdent,'DoSomethingMore');
|
||||
end;
|
||||
|
||||
procedure TTestStatementParser.TestTryExceptOnElseNoSemicolo;
|
||||
Var
|
||||
T : TPasImplTry;
|
||||
S : TPasImplSimple;
|
||||
E : TPasImplTryExcept;
|
||||
O : TPasImplExceptOn;
|
||||
EE : TPasImplTryExceptElse;
|
||||
begin
|
||||
TestStatement(['Try',' DoSomething;','except','On E : Exception do','DoSomethingElse','else','DoSomethingMore','end']);
|
||||
T:=AssertStatement('Try statement',TPasImplTry) as TPasImplTry;
|
||||
AssertEquals(1,T.Elements.Count);
|
||||
AssertNotNull(T.FinallyExcept);
|
||||
AssertNotNull(T.ElseBranch);
|
||||
AssertNotNull(T.Elements[0]);
|
||||
AssertEquals('Simple statement',TPasImplSimple,TPasElement(T.Elements[0]).ClassType);
|
||||
S:=TPasImplSimple(T.Elements[0]);
|
||||
AssertExpression('DoSomething call',S.Expr,pekIdent,'DoSomething');
|
||||
AssertEquals('Simple statement',TPasImplSimple,TPasElement(T.Elements[0]).ClassType);
|
||||
AssertEquals('Except statement',TPasImplTryExcept,T.FinallyExcept.ClassType);
|
||||
E:=TPasImplTryExcept(T.FinallyExcept);
|
||||
AssertEquals(1,E.Elements.Count);
|
||||
AssertEquals('Except on handler',TPasImplExceptOn,TPasElement(E.Elements[0]).ClassType);
|
||||
O:=TPasImplExceptOn(E.Elements[0]);
|
||||
AssertEquals('Exception Variable name','E',O.VariableName);
|
||||
AssertEquals('Exception Type name','Exception',O.TypeName);
|
||||
AssertEquals(1,O.Elements.Count);
|
||||
AssertEquals('Simple statement',TPasImplSimple,TPasElement(O.Elements[0]).ClassType);
|
||||
S:=TPasImplSimple(O.Elements[0]);
|
||||
AssertExpression('DoSomethingElse call',S.Expr,pekIdent,'DoSomethingElse');
|
||||
AssertEquals('Except Else statement',TPasImplTryExceptElse,T.ElseBranch.ClassType);
|
||||
EE:=TPasImplTryExceptElse(T.ElseBranch);
|
||||
AssertEquals(1,EE.Elements.Count);
|
||||
AssertNotNull(EE.Elements[0]);
|
||||
AssertEquals('Simple statement',TPasImplSimple,TPasElement(EE.Elements[0]).ClassType);
|
||||
S:=TPasImplSimple(EE.Elements[0]);
|
||||
AssertExpression('DoSomething call',S.Expr,pekIdent,'DoSomethingMore');
|
||||
end;
|
||||
|
||||
procedure TTestStatementParser.TestTryExceptRaise;
|
||||
Var
|
||||
T : TPasImplTry;
|
||||
|
Loading…
Reference in New Issue
Block a user