Revision: 3832
Author: pekka.klarck
Date: Mon Aug 16 13:54:44 2010
Log: relaxed for loop parsing rules as backwards compatibility with rf <
2.5 (issue 611)
http://code.google.com/p/robotframework/source/detail?r=3832
Modified:
/trunk/atest/robot/core/for.txt
/trunk/atest/testdata/core/for.txt
/trunk/src/robot/parsing/datarow.py
/trunk/src/robot/parsing/model.py
=======================================
--- /trunk/atest/robot/core/for.txt Mon May 24 03:39:10 2010
+++ /trunk/atest/robot/core/for.txt Mon Aug 16 13:54:44 2010
@@ -243,6 +243,13 @@
For In Range With None As Range
Check Test Case ${TESTNAME}
+
+For loops are case and space insensitive
+ Check Test Case ${TESTNAME}
+
+For word can have many colons
+ Check Test Case ${TESTNAME}
+
*** Keywords ***
Should Be For Keyword
=======================================
--- /trunk/atest/testdata/core/for.txt Thu May 27 11:12:49 2010
+++ /trunk/atest/testdata/core/for.txt Mon Aug 16 13:54:44 2010
@@ -1,4 +1,5 @@
*** Settings ***
+Documentation NO RIDE because we want to test different formatting
*** Variables ***
@{NUMS} 1 2 3 4 5
@@ -282,6 +283,25 @@
:FOR ${i} IN RANGE ${NONE}
\ Fail Not executed
+For loops are case and space insensitive
+ ${result} = Set Variable ${EMPTY}
+ : f o r ${c} i n a b c
+ \ ${result} = Set Variable ${result}${c}
+ : F o R ${i} i n r a n g e 1 2
+ \ ${result} = Set Variable ${result}${i}
+ :for ${i} inrange 2 4
+ \ ${result} = Set Variable ${result}${i}
+ Should Be Equal ${result} abc123
+
+For word can have many colons
+ ${result} = Set Variable ${EMPTY}
+ ::::::::FOR ${i} IN 0 1 2 3
+ \ ${result} = Set Variable ${result}${i}
+ :::f:o:r::: ${i} inrange 4 10
+ \ ${result} = Set Variable ${result}${i}
+ Should Be Equal ${result} 0123456789
+
+
*** Keywords ***
My UK
No Operation
=======================================
--- /trunk/src/robot/parsing/datarow.py Wed Jun 9 04:26:40 2010
+++ /trunk/src/robot/parsing/datarow.py Mon Aug 16 13:54:44 2010
@@ -56,7 +56,7 @@
def starts_for_loop(self):
if self.head and self.head.startswith(':'):
- return self.head.replace(':', '').upper().strip() == 'FOR'
+ return self.head.replace(':', '').replace(' ', '').upper()
== 'FOR'
return False
def starts_test_or_user_keyword_setting(self):
=======================================
--- /trunk/src/robot/parsing/model.py Tue Jun 29 10:28:37 2010
+++ /trunk/src/robot/parsing/model.py Mon Aug 16 13:54:44 2010
@@ -504,8 +504,9 @@
def _get_range_and_index(self, content):
for index, item in enumerate(content):
- if item.upper() in ['IN', 'IN RANGE']:
- return item.upper() == 'IN RANGE', index
+ item = item.upper().replace(' ', '')
+ if item in ['IN', 'INRANGE']:
+ return item == 'INRANGE', index
return False, len(content)
def is_comment(self):