* Test for otherwise without semicolon before it (laz sources)

git-svn-id: trunk@45462 -
This commit is contained in:
michael 2020-05-22 12:44:34 +00:00
parent b1e78f1e75
commit 4247c8b1d0
2 changed files with 37 additions and 6 deletions

View File

@ -101,6 +101,7 @@ Type
Procedure TestCaseIfElse; Procedure TestCaseIfElse;
Procedure TestCaseElseNoSemicolon; Procedure TestCaseElseNoSemicolon;
Procedure TestCaseIfElseNoSemicolon; Procedure TestCaseIfElseNoSemicolon;
procedure TestCaseIfOtherwiseNoSemicolon;
Procedure TestRaise; Procedure TestRaise;
Procedure TestRaiseEmpty; Procedure TestRaiseEmpty;
Procedure TestRaiseAt; Procedure TestRaiseAt;
@ -1301,6 +1302,31 @@ begin
AssertEquals('1 statements in else branch ',1,TPasImplCaseElse(C.ElseBranch).Elements.Count); AssertEquals('1 statements in else branch ',1,TPasImplCaseElse(C.ElseBranch).Elements.Count);
end; end;
procedure TTestStatementParser.TestCaseIfOtherwiseNoSemicolon;
Var
C : TPasImplCaseOf;
S : TPasImplCaseStatement;
begin
DeclareVar('integer');
TestStatement(['case a of','1 : dosomething;','2: if b then',' dosomething','else dosomethingmore','otherwise','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

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="12"/>
<General> <General>
<Flags> <Flags>
<SaveOnlyProjectUnits Value="True"/> <SaveOnlyProjectUnits Value="True"/>
<SaveJumpHistory Value="False"/> <SaveJumpHistory Value="False"/>
<SaveFoldState Value="False"/> <SaveFoldState Value="False"/>
<CompatibilityMode Value="True"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<UseAppBundle Value="False"/> <UseAppBundle Value="False"/>
<ResourceType Value="res"/> <ResourceType Value="res"/>
</General> </General>
@ -21,14 +21,19 @@
</BuildModes> </BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <CommandLineParams Value="--suite=TTestStatementParser.TestCaseIfElseNoSemicolon"/>
<CommandLineParams Value="--suite=TTestRecordTypeParser.TestFieldAndClassVar"/>
</local> </local>
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default">
<local>
<CommandLineParams Value="--suite=TTestStatementParser.TestCaseIfElseNoSemicolon"/>
</local>
</Mode0>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
<Item1> <Item1>