mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-17 13:59:29 +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;
|
||||
CloseStatement(false);
|
||||
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
|
||||
begin
|
||||
//if .. then while .. do smt else ..
|
||||
CloseBlock;
|
||||
UngetToken;
|
||||
end else if (CurBlock is TPasImplForLoop) then
|
||||
|
@ -96,6 +96,7 @@ Type
|
||||
Procedure TestCaseElseBlock2Assignments;
|
||||
Procedure TestCaseIfCaseElse;
|
||||
Procedure TestCaseIfElse;
|
||||
Procedure TestCaseElseNoSemicolon;
|
||||
Procedure TestRaise;
|
||||
Procedure TestRaiseEmpty;
|
||||
Procedure TestRaiseAt;
|
||||
@ -1206,6 +1207,31 @@ begin
|
||||
AssertNotNull('If statement has else block',TPasImplIfElse(S.Elements[0]).ElseBranch);
|
||||
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;
|
||||
|
||||
Var
|
||||
|
Loading…
Reference in New Issue
Block a user