* Test for bug ID #27760

git-svn-id: trunk@47016 -
This commit is contained in:
michael 2020-09-30 13:33:16 +00:00
parent d72170f9a3
commit 4ad6c98d82

View File

@ -71,6 +71,7 @@ Type
procedure TestIfWithBlock;
Procedure TestNestedIf;
Procedure TestNestedIfElse;
Procedure TestNestedIfElseElse;
Procedure TestWhile;
Procedure TestWhileBlock;
Procedure TestWhileNested;
@ -714,6 +715,32 @@ begin
AssertEquals('begin end block',TPasImplBeginBlock,I.ElseBranch.ClassType);
end;
procedure TTestStatementParser.TestNestedIfElseElse;
// Bug ID 37760
Var
I,I2 : TPasImplIfElse;
begin
DeclareVar('boolean');
TestStatement(['if a then',
' if b then',
' DoA ',
' else',
' else',
' DoB']);
I:=AssertStatement('If statement',TPasImplIfElse) as TPasImplIfElse;
AssertExpression('IF condition',I.ConditionExpr,pekIdent,'a');
AssertNotNull('if branch',I.IfBranch);
AssertNotNull('Have else for outer if',I.ElseBranch);
AssertEquals('Have if in if branch',TPasImplIfElse,I.ifBranch.ClassType);
I2:=I.Ifbranch as TPasImplIfElse;
AssertExpression('IF condition',I2.ConditionExpr,pekIdent,'b');
AssertNotNull('Have then for inner if',I2.ifBranch);
AssertNull('Empty else for inner if',I2.ElseBranch);
end;
procedure TTestStatementParser.TestWhile;
Var