Skip to content

Commit de48ab1

Browse files
committed
Fix parsing else and else if inside of for loop
1 parent bb79336 commit de48ab1

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

atest/robot/running/if/complex_if.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ If creating variable
4040
If inside if
4141
Check Test Case ${TESTNAME}
4242

43-
For loop for loop if else if else early exit
43+
For loop if else early exit
44+
Check Test Case ${TESTNAME}
45+
46+
For loop if else if early exit
4447
Check Test Case ${TESTNAME}

atest/testdata/running/if/complex_if.robot

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,28 @@ Nesting insanity
9494
END
9595
Should be equal ${assumption} 2 5 9 8 7 8 9 5 2
9696

97-
For loop for loop if else if else early exit
97+
For loop if else early exit
98+
[Documentation] PASS From the condition
9899
FOR ${iter1} IN 1 2 3
99100
IF 1 > 2
100101
Fail should not execute if branch
101-
ELSE IF 3 > 5
102-
Fail should not execute else if branch
103102
ELSE
104103
Pass Execution From the condition
105104
END
106105
END
107106
Fail should not execute end of test
108107

108+
For loop if else if early exit
109+
[Documentation] PASS From the condition
110+
FOR ${iter1} IN 1 2 3
111+
IF 1 > 2
112+
Fail should not execute if branch
113+
ELSE IF ${iter1} == 2
114+
Pass Execution From the condition
115+
END
116+
END
117+
Fail should not execute end of test
118+
109119
Recursive if
110120
Recurse 1
111121

src/robot/parsing/lexer/blocklexers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def input(self, statement):
224224
statement.pop(0)
225225

226226
def lexer_classes(self):
227-
return (ForLoopHeaderLexer, IfStatementLexer, EndLexer, KeywordCallLexer)
227+
return (ForLoopHeaderLexer, IfStatementLexer, ElseIfStatementLexer, ElseLexer, EndLexer, KeywordCallLexer)
228228

229229

230230
class IfBlockLexer(BlockLexer):

0 commit comments

Comments
 (0)