Browse Source

* Test for bug ID #27760

git-svn-id: trunk@47016 -
michael 4 years ago
parent
commit
4ad6c98d82
1 changed files with 27 additions and 0 deletions
  1. 27 0
      packages/fcl-passrc/tests/tcstatements.pas

+ 27 - 0
packages/fcl-passrc/tests/tcstatements.pas

@@ -71,6 +71,7 @@ Type
     procedure TestIfWithBlock;
     procedure TestIfWithBlock;
     Procedure TestNestedIf;
     Procedure TestNestedIf;
     Procedure TestNestedIfElse;
     Procedure TestNestedIfElse;
+    Procedure TestNestedIfElseElse;
     Procedure TestWhile;
     Procedure TestWhile;
     Procedure TestWhileBlock;
     Procedure TestWhileBlock;
     Procedure TestWhileNested;
     Procedure TestWhileNested;
@@ -714,6 +715,32 @@ begin
   AssertEquals('begin end block',TPasImplBeginBlock,I.ElseBranch.ClassType);
   AssertEquals('begin end block',TPasImplBeginBlock,I.ElseBranch.ClassType);
 end;
 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;
 procedure TTestStatementParser.TestWhile;
 
 
 Var
 Var