mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 18:29:09 +02:00
* Case else without semicolon in front (bug ID 31284)
git-svn-id: trunk@35362 -
This commit is contained in:
parent
a51efe50b7
commit
f55215f53a
@ -3938,9 +3938,14 @@ begin
|
|||||||
CloseBlock;
|
CloseBlock;
|
||||||
CloseStatement(false);
|
CloseStatement(false);
|
||||||
end;
|
end;
|
||||||
|
// Case ... else without semicolon in front.
|
||||||
|
end else if (CurBlock is TPasImplCaseStatement) then
|
||||||
|
begin
|
||||||
|
UngetToken;
|
||||||
|
CloseStatement(False);
|
||||||
|
exit;
|
||||||
end else if (CurBlock is TPasImplWhileDo) then
|
end else if (CurBlock is TPasImplWhileDo) then
|
||||||
begin
|
begin
|
||||||
//if .. then while .. do smt else ..
|
|
||||||
CloseBlock;
|
CloseBlock;
|
||||||
UngetToken;
|
UngetToken;
|
||||||
end else if (CurBlock is TPasImplForLoop) then
|
end else if (CurBlock is TPasImplForLoop) then
|
||||||
|
@ -96,6 +96,7 @@ Type
|
|||||||
Procedure TestCaseElseBlock2Assignments;
|
Procedure TestCaseElseBlock2Assignments;
|
||||||
Procedure TestCaseIfCaseElse;
|
Procedure TestCaseIfCaseElse;
|
||||||
Procedure TestCaseIfElse;
|
Procedure TestCaseIfElse;
|
||||||
|
Procedure TestCaseElseNoSemicolon;
|
||||||
Procedure TestRaise;
|
Procedure TestRaise;
|
||||||
Procedure TestRaiseEmpty;
|
Procedure TestRaiseEmpty;
|
||||||
Procedure TestRaiseAt;
|
Procedure TestRaiseAt;
|
||||||
@ -1206,6 +1207,31 @@ begin
|
|||||||
AssertNotNull('If statement has else block',TPasImplIfElse(S.Elements[0]).ElseBranch);
|
AssertNotNull('If statement has else block',TPasImplIfElse(S.Elements[0]).ElseBranch);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestStatementParser.TestCaseElseNoSemicolon;
|
||||||
|
Var
|
||||||
|
C : TPasImplCaseOf;
|
||||||
|
S : TPasImplCaseStatement;
|
||||||
|
B : TPasImplbeginBlock;
|
||||||
|
|
||||||
|
begin
|
||||||
|
DeclareVar('integer');
|
||||||
|
TestStatement(['case a of','1 : dosomething;','2 : dosomethingmore','else','a:=1;','end;']);
|
||||||
|
C:=AssertStatement('Case statement',TpasImplCaseOf) as TpasImplCaseOf;
|
||||||
|
AssertNotNull('Have case expression',C.CaseExpr);
|
||||||
|
AssertExpression('Case expression',C.CaseExpr,pekIdent,'a');
|
||||||
|
AssertEquals('case label count',3,C.Elements.Count);
|
||||||
|
S:=TPasImplCaseStatement(C.Elements[0]);
|
||||||
|
AssertEquals('case 1',1,S.Expressions.Count);
|
||||||
|
AssertExpression('Case With identifier 1',TPasExpr(S.Expressions[0]),pekNumber,'1');
|
||||||
|
S:=TPasImplCaseStatement(C.Elements[1]);
|
||||||
|
AssertEquals('case 2',1,S.Expressions.Count);
|
||||||
|
AssertExpression('Case With identifier 1',TPasExpr(S.Expressions[0]),pekNumber,'2');
|
||||||
|
AssertEquals('third is else',TPasImplCaseElse,TObject(C.Elements[2]).ClassType);
|
||||||
|
AssertNotNull('Have else branch',C.ElseBranch);
|
||||||
|
AssertEquals('Correct else branch class',TPasImplCaseElse,C.ElseBranch.ClassType);
|
||||||
|
AssertEquals('1 statements in else branch ',1,TPasImplCaseElse(C.ElseBranch).Elements.Count);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestStatementParser.TestRaise;
|
procedure TTestStatementParser.TestRaise;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
|
Loading…
Reference in New Issue
Block a user